Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix - failing CI test for MW 1.39 #113

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env-39
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MW_VERSION?=1.39
PHP_VERSION?=8.1
DB_TYPE?=mysql
DB_IMAGE?="mariadb:latest"
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ jobs:
database_image: "mariadb:latest"
coverage: false
experimental: true
- mediawiki_version: '1.40'
smw_version: dev-master
php_version: 8.1
database_type: mysql
database_image: "mariadb:latest"
coverage: false
experimental: true
# - mediawiki_version: '1.40'
# smw_version: dev-master
# php_version: 8.1
# database_type: mysql
# database_image: "mariadb:latest"
# coverage: false
# experimental: true

env:
MW_VERSION: ${{ matrix.mediawiki_version }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-include .env
-include .env-39
export

# setup for docker-compose-ci build directory
Expand Down
6 changes: 5 additions & 1 deletion src/ApiSemanticFormsSelectRequestProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public function getJsonDecodedResultValuesForRequestParameters( array $parameter
throw new InvalidArgumentException( 'Missing an query parameter' );
}

if ( !isset( $parameters['query'] ) || !isset( $parameters['sep'] ) ) {
throw new InvalidArgumentException( 'Missing an query parameter' );
}

$this->parser->firstCallInit();
$json = [];

Expand Down Expand Up @@ -147,7 +151,7 @@ private function doProcessFunctionFor( $query, $sep = "," ) {

private function getFormattedValuesFrom( $sep, $values ) {

if ( strpos( $values, $sep ) === false ) {
if ( strpos( $values ?? '', $sep ) === false ) {
return [ $values ];
}

Expand Down
2 changes: 1 addition & 1 deletion src/SelectField.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct( & $parser ) {
/**
* Convenience function to process all parameters at once
*/
public function processParameters( $input_name = "", $other_args ) {
public function processParameters( $other_args, $input_name = "" ) {
if ( array_key_exists( "query", $other_args ) ) {
$this->setQuery( $other_args );
} elseif ( array_key_exists( "function", $other_args ) ) {
Expand Down
6 changes: 3 additions & 3 deletions src/SemanticFormsSelectInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public function getResourceModuleNames() {
* This is currently just a wrapper for getHTML().
*/
public function getHtmlText() {
return self::getHTML( $this->mCurrentValue, $this->mInputName, $this->mIsMandatory, $this->mIsDisabled,
$this->mOtherArgs );
return self::getHTML( $this->mIsMandatory, $this->mIsDisabled,
$this->mOtherArgs, $this->mCurrentValue, $this->mInputName );
}

/**
Expand All @@ -69,7 +69,7 @@ public function getHtmlText() {
* @param string[] $other_args Array of other field parameters
* @return string
*/
public function getHTML( $cur_value = "", $input_name = "", $is_mandatory, $is_disabled, Array $other_args ) {
public function getHTML( $is_mandatory, $is_disabled, Array $other_args, $cur_value = "", $input_name = "" ) {
global $wgPageFormsFieldNum, $wgUser;

// shortcut to the SelectField object
Expand Down
19 changes: 16 additions & 3 deletions tests/phpunit/Unit/SelectFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testCanConstruct() {
public function testProcessParameters_Query() {

$this->selectField->processParameters(
"", $this->other_args_query_parametrized
$this->other_args_query_parametrized, ""
);
$this->assertTrue(
array_key_exists( "query", $this->other_args_query_parametrized )
Expand All @@ -48,7 +48,7 @@ public function testProcessParameters_Query() {
public function testProcessParameters_Function() {

$this->selectField->processParameters(
"", $this->other_args_function_parametrized
$this->other_args_function_parametrized, ""
);
$this->assertArrayHasKey(
"function", $this->other_args_function_parametrized
Expand Down Expand Up @@ -250,10 +250,23 @@ public function testSetWgPageFormsListSeparator_keyExistTrue() {

protected function setUp(): void {
parent::setUp();
$user = $this->getMockBuilder( 'MediaWiki\User\UserIdentity' )
->disableOriginalConstructor()
->getMock();
$name = $user->getName();
$parserOption;

if ( version_compare( MW_VERSION, '1.39', '>=' ) ) {
//check if version is higher than 1.39, or the same (the getOption() function within ParserOptions is different then in MW 1.35)
$parserOption = new ParserOptions( $user );
} else {
//if MW version is lower than 1.39
$parserOption = new ParserOptions( $name );
}
$parser = MediaWikiServices::getInstance()->getParser();
$parser->setOutputType(Parser::OT_HTML);
$parser->setTitle( Title::newFromText( 'NO TITLE' ) );
$parser->mOptions = new ParserOptions();
$parser->setOptions($parserOption);
$parser->resetOutput();
$parser->clearState();
$this->selectField = new SelectField( $parser );
Expand Down
Loading