Last modified: 2012-05-02 16:52:58 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 T32975, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 30975 - API import of pages with invalid characters in this wiki leads to Fatal Error
API import of pages with invalid characters in this wiki leads to Fatal Error
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
1.17.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-18 19:13 UTC by Daniel A. R. Werner
Modified: 2012-05-02 16:52 UTC (History)
8 users (show)

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


Attachments
Import test data (3.22 KB, text/xml)
2011-09-20 17:12 UTC, Mark A. Hershberger
Details

Description Daniel A. R. Werner 2011-09-18 19:13:51 UTC
When using the API to import pages and one of the pages has invalid characters in the page title, this will result in an Fatal Error, the API also won't return the result properly then.

Fatal error: Call to a member function getNamespace() on a non-object in '...\includes\api\ApiQueryBase.php' on line 297

Here the call stack trace:

#	Time	Memory	Function	Location
1	0.0006	366264	{main}( )	..\api.php:0
2	0.2134	15054240	ApiMain->execute( )	..\api.php:104
3	0.2134	15054272	ApiMain->executeActionWithErrorHandling( )	..\ApiMain.php:323
4	0.2134	15095600	ApiMain->executeAction( )	..\ApiMain.php:339
5	0.2515	16244760	ApiImport->execute( )	..\ApiMain.php:657
6	0.2562	16731304	WikiImporter->doImport( )	..\ApiImport.php:84
7	0.2564	16731448	WikiImporter->handlePage( )	..\Import.php:370
8	0.2687	17866176	WikiImporter->pageOutCallback( )	..\Import.php:507
9	0.2687	17867064	call_user_func_array ( )	..\Import.php:246
10	0.2687	17867456	ApiImportReporter->reportPage( )	..\Import.php:246
11	0.2700	18041056	ApiQueryBase::addTitleInfo( )	..\ApiImport.php:177


I would say, this is due to the fact that the Title object was not created, contained null and was given to the next function anyway.

The special page import doesn't have this error, there, the title is validated properly.
I guess the problem lays within WikiImporter::handlePage() and/or WikiImporter::processTitle()
In another run I also got the notices:

Undefined variable: origTitle in WikiImporter::handlePage()
and
Undefined index: _title in WikiImporter::handlePage()
Comment 1 Sam Reed (reedy) 2011-09-18 19:14:33 UTC
Can you link to what query you were actually requesting?
Comment 2 Daniel A. R. Werner 2011-09-19 16:42:32 UTC
Query contains post data, url:
http://localhost/wiki/api.php?action=import&format=php

POST data:
token: normal edit token
xml: '@importtest.xml'
summary: 'summary'

The XML file can be seen here:
http://rpg-dev.org/importtest.xml

It works if you remove the '|' from the 'title' tag.
Comment 3 Mark A. Hershberger 2011-09-20 17:12:03 UTC
Created attachment 9082 [details]
Import test data

Attaching import test to the bug in case the server disappears.
Comment 4 db [inactive,noenotif] 2012-01-10 20:18:18 UTC
ImportReporter::reportPage has

if ( $title === null ) {
 # Invalid or non-importable title; a notice is already displayed
 return;
}

The api extends ImportReporter with ApiImportReporter, but does not respect a null in $title in reportPage . The api is calling ApiQueryBase::addTitleInfo and that gives the reported fatal error.

When $title is null you have to set a info in the api result (something like invalid="" and the original title) and than returning.
Comment 5 Umherirrender 2012-04-29 18:18:11 UTC
a patch submitted with Gerrit change #6095
Comment 6 Umherirrender 2012-05-02 16:52:58 UTC
successfully merged

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


Navigation
Links