Page MenuHomePhabricator

Invalid titles just lead to InvalidArgumentException
Closed, ResolvedPublic

Description

E.g. https://en.wikibooks.org/wiki/a& -

2015-05-20 19:22:07 mw1049 enwikibooks exception INFO: [5224434d] /wiki/a&   InvalidArgumentException from line 240 of /srv/mediawiki/php-1.26wmf6/includes/Message.php: $key must be a string or an array
#0 /srv/mediawiki/php-1.26wmf6/includes/GlobalFunctions.php(1433): Message->__construct()
#1 /srv/mediawiki/php-1.26wmf6/includes/title/MalformedTitleException.php(44): wfMessage()
#2 /srv/mediawiki/php-1.26wmf6/includes/MediaWiki.php(117): MalformedTitleException->__construct()
#3 /srv/mediawiki/php-1.26wmf6/includes/MediaWiki.php(130): MediaWiki->parseTitle()
#4 /srv/mediawiki/php-1.26wmf6/includes/MediaWiki.php(518): MediaWiki->getTitle()
#5 /srv/mediawiki/php-1.26wmf6/includes/MediaWiki.php(431): MediaWiki->main()
#6 /srv/mediawiki/php-1.26wmf6/index.php(46): MediaWiki->run()
#7 /srv/mediawiki/w/index.php(3): include()
#8 {main} {"private":false}

Seems to only be on non-wikipedias, so wmf6 regression?

Event Timeline

Krenair created this task.May 20 2015, 7:23 PM
Krenair raised the priority of this task from to Needs Triage.
Krenair updated the task description. (Show Details)
Krenair added a subscriber: Krenair.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMay 20 2015, 7:23 PM
Krenair renamed this task from Some URLs just lead to InvalidArgumentException to Invalid titles just lead to InvalidArgumentException.May 20 2015, 7:23 PM
Krenair added a project: MediaWiki-General.
Krenair set Security to None.

Indirectly. MalformedTitleException::__construct() is documented to take a string as its first parameter, but MediaWiki::parseTitle() is passing null instead.

Change 212331 had a related patch set uploaded (by Anomie):
Pass a message key to MalformedTitleException constructor

https://gerrit.wikimedia.org/r/212331

just calling "new MalformedTitleException()" would also throw this error (Call style before 1.26), because the default value of $errorMessage is null

In my opinion the call Title::newFromTextThrow( $title ); before the changed line should already have a correct MalformedTitleException thrown, but that acutally is not happen.

just calling "new MalformedTitleException()" would also throw this error (Call style before 1.26), because the default value of $errorMessage is null

Before 1.26 the constructor was inherited from Exception, which takes an optional (but recommended) string message as its first parameter. Wikibase is doing this; I don't see any other uses of this class in extensions in Gerrit.

Change 212331 merged by jenkins-bot:
Pass a message key to MalformedTitleException constructor

https://gerrit.wikimedia.org/r/212331

In my opinion the call Title::newFromTextThrow( $title ); before the changed line should already have a correct MalformedTitleException thrown, but that acutally is not happen.

Title::newFromTextThrow decode the & and than it is a valid title, therefore that call does not throw a MalformedTitleException.

Earlier in the code path Title::newFromURL is used, which does not decode html entity and therefore gets an invalid title and returning null. This null than triggers the call to Title::newFromTextThrow, but than the title is decoded and no invalid title is detected, going further to the now changed line.

Change 212487 had a related patch set uploaded (by Ori.livneh):
Pass a message key to MalformedTitleException constructor

https://gerrit.wikimedia.org/r/212487

Change 212490 had a related patch set uploaded (by Ori.livneh):
Pass a message key to MalformedTitleException constructor

https://gerrit.wikimedia.org/r/212490

Change 212487 merged by Ori.livneh:
Pass a message key to MalformedTitleException constructor

https://gerrit.wikimedia.org/r/212487

Change 212490 merged by Ori.livneh:
Pass a message key to MalformedTitleException constructor

https://gerrit.wikimedia.org/r/212490

ori closed this task as Resolved.May 21 2015, 12:40 AM
ori claimed this task.
demon triaged this task as Normal priority.Jul 9 2015, 4:40 PM

Change 360399 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/core@master] Make MalformedTitleException errorMessage non-null

https://gerrit.wikimedia.org/r/360399

Change 360399 merged by jenkins-bot:
[mediawiki/core@master] Make MalformedTitleException errorMessage non-null

https://gerrit.wikimedia.org/r/360399