Last modified: 2014-11-05 15:06:06 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 38222 - UploadBase::checkWarnings could throw exception on null object access
UploadBase::checkWarnings could throw exception on null object access
Product: MediaWiki
Classification: Unclassified
Uploading (Other open bugs)
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: easy
: 43832 (view as bug list)
Depends on:
Blocks: code_quality
  Show dependency treegraph
Reported: 2012-07-06 18:52 UTC by Christian Neubauer
Modified: 2014-11-05 15:06 UTC (History)
6 users (show)

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


Description Christian Neubauer 2012-07-06 18:52:15 UTC
The function checkWarnings() in UploadBase.php calls:

	$localFile = $this->getLocalFile();
	$filename = $localFile->getName();

But getLocalFile() will return null if the title of the upload is invalid for some reason (like it contains a blacklisted extension). This can cause an exception to be thrown. There should be a null check in there.
Comment 1 Bryan Tong Minh 2013-12-24 17:52:46 UTC
*** Bug 43832 has been marked as a duplicate of this bug. ***
Comment 2 Bryan Tong Minh 2013-12-24 18:16:46 UTC
This should never happen because you should always call verifyUpload() before checkWarnings() (should be documented). 

ApiUpload allows you to call checkWarnings() if you use async=true, which is I think the reason for the exceptions we see in production.
Comment 3 Christian Neubauer 2013-12-24 19:28:28 UTC
cc'd Andre and Quim. Seems like this would be an easy task for the code-in...
Comment 4 Quim Gil 2013-12-27 06:53:56 UTC
Thank you very much! Google Code-in task created. We hope to get code reviewers when a patch arrives.
Comment 5 Gerrit Notification Bot 2013-12-27 09:39:20 UTC
Change 104012 had a related patch set uploaded by Mayankmadan:
verifyUpload should be called before checkWarnings
Comment 6 Gerrit Notification Bot 2014-01-02 23:35:39 UTC
Change 105111 had a related patch set uploaded by Mayankmadan:
getApiWarnings() throws an exception if upload is invalid
Comment 7 Gerrit Notification Bot 2014-01-03 21:56:27 UTC
Change 104012 abandoned by Mayankmadan:
verifyUpload should be called before checkWarnings

Added a new patch for this bug
Comment 8 Andre Klapper 2014-10-26 17:27:50 UTC
Patch by Mayank in needs rework. 
Newcomers: See
Comment 9 Andre Klapper 2014-11-05 15:06:06 UTC
Would anybody be willing to be a mentor for fixing the existing patch as part of Google Code-in 2014?  If yes, could you add it to until
Sunday (we can still improve the description until December 1st)?
If time is spare I can also do that - I just need a statement who
would mentor it.

See for more information. Don't hesitate to ask if you have questions!

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