Last modified: 2010-11-10 00:54:53 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T27580, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 25580 - Missing argument 5 for WikiImporter::finishImportPage() during xml dump import via API
Missing argument 5 for WikiImporter::finishImportPage() during xml dump impor...
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
1.17.x
All All
: Normal minor (vote)
: ---
Assigned To: Roan Kattouw
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-10-19 06:18 UTC by Dmitriy Sintsov
Modified: 2010-11-10 00:54 UTC (History)
6 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Dmitriy Sintsov 2010-10-19 06:18:50 UTC
I develop an extension which uses API to export XML dump to remote wiki. In r75001 I get the following warning:

[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP Warning:  Missing argument 5 for WikiImporter::finishImportPage() in /var/www/wiki/phase3/includes/ImportXMLReader.php on line 182
[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP Stack trace:
[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP   1. {main}() /var/www/wiki/phase3/api.php:0
[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP   2. ApiMain->execute() /var/www/wiki/phase3/api.php:116
[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP   3. ApiMain->executeActionWithErrorHandling() /var/www/wiki/phase3/includes/api/ApiMain.php:322
[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP   4. ApiMain->executeAction() /var/www/wiki/phase3/includes/api/ApiMain.php:338
[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP   5. ApiImport->execute() /var/www/wiki/phase3/includes/api/ApiMain.php:656
[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP   6. WikiImporter->doImport() /var/www/wiki/phase3/includes/api/ApiImport.php:88
[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP   7. WikiImporter->handlePage() /var/www/wiki/phase3/includes/ImportXMLReader.php:333
[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP   8. WikiImporter->pageOutCallback() /var/www/wiki/phase3/includes/ImportXMLReader.php:470
[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP   9. call_user_func_array() /var/www/wiki/phase3/includes/ImportXMLReader.php:225
[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP  10. ApiImportReporter->reportPage() /var/www/wiki/phase3/includes/ImportXMLReader.php:0
[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP  11. ImportReporter->reportPage() /var/www/wiki/phase3/includes/api/ApiImport.php:192
[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP  12. call_user_func_array() /var/www/wiki/phase3/includes/specials/SpecialImport.php:314
[Tue Oct 19 10:12:41 2010] [error] [client 10.1.1.119] PHP  13. WikiImporter->finishImportPage() /var/www/wiki/phase3/includes/specials/SpecialImport.php:0

I've incloded the xdebug stack trace, maybe it will help to easier spot the problem.

Also I get the following warning:
[Tue Oct 19 10:07:49 2010] [error] [client 10.1.1.119] PHP Warning:  filemtime(): stat failed for /var/www/wiki/phase3/Array in /var/www/wiki/phase3/includes/ResourceLoaderModule.php on line 565, referer: http://phase3.wiki2.uniyar.ac.ru/index.php/%D0%9F%D1%80%D0%B0%D0%BA%D1%82%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B0%D1%8F_%D0%BF%D1%81%D0%B8%D1%85%D0%BE%D0%BB%D0%BE%D0%B3%D0%B8%D1%8F
[Tue Oct 19 10:07:49 2010] [error] [client 10.1.1.119] PHP Stack trace:, referer: http://phase3.wiki2.uniyar.ac.ru/index.php/%D0%9F%D1%80%D0%B0%D0%BA%D1%82%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B0%D1%8F_%D0%BF%D1%81%D0%B8%D1%85%D0%BE%D0%BB%D0%BE%D0%B3%D0%B8%D1%8F
[Tue Oct 19 10:07:49 2010] [error] [client 10.1.1.119] PHP   1. {main}() /var/www/wiki/phase3/load.php:0, referer: http://phase3.wiki2.uniyar.ac.ru/index.php/%D0%9F%D1%80%D0%B0%D0%BA%D1%82%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B0%D1%8F_%D0%BF%D1%81%D0%B8%D1%85%D0%BE%D0%BB%D0%BE%D0%B3%D0%B8%D1%8F
[Tue Oct 19 10:07:49 2010] [error] [client 10.1.1.119] PHP   2. ResourceLoader->respond() /var/www/wiki/phase3/load.php:49, referer: http://phase3.wiki2.uniyar.ac.ru/index.php/%D0%9F%D1%80%D0%B0%D0%BA%D1%82%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B0%D1%8F_%D0%BF%D1%81%D0%B8%D1%85%D0%BE%D0%BB%D0%BE%D0%B3%D0%B8%D1%8F
[Tue Oct 19 10:07:49 2010] [error] [client 10.1.1.119] PHP   3. ResourceLoaderFileModule->getModifiedTime() /var/www/wiki/phase3/includes/ResourceLoader.php:285, referer: http://phase3.wiki2.uniyar.ac.ru/index.php/%D0%9F%D1%80%D0%B0%D0%BA%D1%82%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B0%D1%8F_%D0%BF%D1%81%D0%B8%D1%85%D0%BE%D0%BB%D0%BE%D0%B3%D0%B8%D1%8F
[Tue Oct 19 10:07:49 2010] [error] [client 10.1.1.119] PHP   4. array_map() /var/www/wiki/phase3/includes/ResourceLoaderModule.php:565, referer: http://phase3.wiki2.uniyar.ac.ru/index.php/%D0%9F%D1%80%D0%B0%D0%BA%D1%82%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B0%D1%8F_%D0%BF%D1%81%D0%B8%D1%85%D0%BE%D0%BB%D0%BE%D0%B3%D0%B8%D1%8F

The first one is a hook, I guess that it's being called with not enough of arguments (probably).
Comment 1 Dmitriy Sintsov 2010-10-19 06:27:58 UTC
Oops.. Could you remote the http links to my testing wiki (phase3), please? I've posted in haste and forgot to conceal them.
Comment 2 Sam Reed (reedy) 2010-10-19 13:01:08 UTC
I don't think we can easily.

As for the above, the second half is a Resource loader issue

Which hook are you calling?
Comment 3 Dmitriy Sintsov 2010-10-20 05:36:23 UTC
I am not calling any hook remotely. I use that 1.17 wiki remotely via API action=import&xml&token:

	static function importXML( $dstImportToken, $xmldata ) {
		if ( self::$directionToLocal ) {
			$json_result = new WikiSyncJSONresult( false );
// TODO: unfinished..
			return $json_result->getResult();
		} else {
			$APIparams = array(
				'action' => 'import',
				'format' => 'json',
				'token' => $dstImportToken,
			);
			list( $fname, $fp ) = self::tempnam_sfx( '', '.xml' );
			fwrite( $fp, $xmldata, strlen( $xmldata ) );
			fclose( $fp );
			$APIfiles = array(
				'xml'=>$fname
			);
			$jr = self::remoteAPIget( self::$remoteContextJSON, $APIparams, $APIfiles, false, true );
			return $jr;
		}
	}

	static function remoteAPIget() {
		# get params
		$args = func_get_args();
		// by default will encode JSON result to string
		$encodeResult = count( $args ) < 4 || $args[3] !== false;
		// by default will NOT use 'multipart/form-data' encoding
		$useMultipart = count( $args ) > 4 && $args[4] === true;
		$json_result = new WikiSyncJSONresult( $encodeResult );
		if ( !WikiSyncSetup::initUser() ) {
			# not enough priviledges to run this method
			return $json_result->getResult( 'noaccess' );
		}
		# snoopy api_params are associative array
		$api_params = is_array( $args[1] ) ? $args[1] : json_decode( $args[1], true );
		$api_files = count( $args ) > 2 ? $args[2] : '';
		$snoopy = new WikiSnoopy();
		$snoopy->setContext( $args[0] );
		if ( $useMultipart ) {
			$snoopy->set_submit_multipart();
			$snoopy->httpmethod = "POST";
		} else {
			$snoopy->set_submit_normal();
			$snoopy->httpmethod = "GET";
		}
		$snoopy->submitToApi( $api_params, $api_files );
		# transport level error ?
		if ( $snoopy->error != '' ) {
			return $json_result->getResult( 'http', $snoopy->error );
		}
		$response = json_decode( $snoopy->results, true );
		# proxy returned html instead of json ?
		if ( $response === null ) {
			return $json_result->getResult( 'http' );
		}
		$json_result->append( $response ); // no HTTP error & valid AJAX
		if ( isset( $response['error'] ) ) {
			return $json_result->getResult( $response['error']['code'], $response['error']['info'] ); // API reported error
		}
		$json_result->setStatus( '1' ); // API success
		return $json_result->getResult();
	}

XML seems to be remotely imported fine, but with warnings in error_log file.
Comment 4 Roan Kattouw 2010-10-20 13:58:35 UTC
Andrew, could this be related to your import rewrite?
Comment 5 Dmitriy Sintsov 2010-10-25 05:26:47 UTC
Roan, after a brief observation, the first bug seems to be very simple:

includes/specials/SpecialImport.php

	function reportPage( $title, $origTitle, $revisionCount, $successCount ) {
		global $wgOut, $wgUser, $wgLang, $wgContLang;
		
		$args = func_get_args();
		call_user_func_array( $this->mOriginalPageOutCallback, $args );

There is a call_user_func_array with $args, where $args is a four reportPage arguments, while the callback has been modified to include 5th parameter:

includes/ImportXMLReader.php

	/**
	 * Mostly for hook use
	 */
	public function finishImportPage( $title, $origTitle, $revCount, $sRevCount, $pageInfo ) {
		$args = func_get_args();
		return wfRunHooks( 'AfterImportPage', $args );
	}

which expects five parameters. Thus, the warning is produced. Either, the 5th parameter should be added to SpecialImport's reportPage; or the default value for finishImportPage should be provided.
Comment 6 Dmitriy Sintsov 2010-10-25 05:46:17 UTC
Roan, it seems that ResourceLoader bug is quite simple, too. My 1.17 testing site uses Monobook skin, not Vector. and in 
ResourceLoaderFileModule::getModifiedTime() there is a following line:

		$filesMtime = max( array_map( 'filemtime', array_map( array( __CLASS__, 'remapFilename' ), $files ) ) );

which produced a warning with bad consequences, because $files[] elements might be Array, not just strings:

$files=array(1) {
  [0]=>
  string(23) "skins/vector/screen.css"
}

$files=array(1) {
  [0]=>
  string(28) "skins/common/commonPrint.css"
}

$files=array(1) {
  [0]=>
  string(23) "skins/common/shared.css"
}

$files=array(2) {
  [0]=>
  string(23) "skins/monobook/main.css"
  [1]=>
  array(1) {
    ["media"]=>
    string(8) "handheld"
  }
} 


note that in last case resourceloadermodule $files[1] is array which indicates media type of stylesheet. One should not do direct array_map() on such arrays to expect valid string result. "Array" string is produced and of course it is not a valid file name so one could not filemtime() it.
Comment 7 Roan Kattouw 2010-10-26 20:22:45 UTC
(In reply to comment #6)
> $files=array(2) {
>   [0]=>
>   string(23) "skins/monobook/main.css"
>   [1]=>
>   array(1) {
>     ["media"]=>
>     string(8) "handheld"
>   }
> } 
> 
This one should no longer be there as of r75006.
Comment 8 Dmitriy Sintsov 2010-11-09 18:51:39 UTC
Yes, ResourceLoader issue has disappeared. However, SpecialImport issue is still here:
[09-Nov-2010 20:43:13] PHP Warning:  Missing argument 5 for WikiImporter::finishImportPage() in C:\www\phase3\includes\ImportXMLReader.php on line 182

[09-Nov-2010 20:43:13] PHP Warning:  Missing argument 5 for WikiImporter::finishImportPage() in C:\www\phase3\includes\ImportXMLReader.php on line 182

[09-Nov-2010 20:43:13] PHP Warning:  Missing argument 5 for WikiImporter::finishImportPage() in C:\www\phase3\includes\ImportXMLReader.php on line 182

[09-Nov-2010 20:43:14] PHP Warning:  Missing argument 5 for WikiImporter::finishImportPage() in C:\www\phase3\includes\ImportXMLReader.php on line 182

[09-Nov-2010 20:43:15] PHP Warning:  Missing argument 5 for WikiImporter::finishImportPage() in C:\www\phase3\includes\ImportXMLReader.php on line 182

[09-Nov-2010 20:43:15] PHP Warning:  Missing argument 5 for WikiImporter::finishImportPage() in C:\www\phase3\includes\ImportXMLReader.php on line 182

Besides ImportReporter, also ApiImportReporter uses only four parameters while WikiImporter::finishImportPage() expects five parameters and not providing the default value for 5th parameter.

Sounds like this bug is very easy to fix. The question is, what is better - to provide the default value of 5th parameter in WikiImporter::finishImportPage(), or to modify calls to provide proper value of $pageInfo in ImportReporter and ApiImportReporter.
Comment 9 Andrew Garrett 2010-11-10 00:54:53 UTC
Should be fixed by r76420.

If not, let me know and I'll investigate in depth.

Thanks for the bug report!

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links