Page MenuHomePhabricator

Unable to open edit page, or view Special:Log, for certain pages ("MWException: Expected title, got null" from LogFormatter.php)
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error Details

For Special:Log
MWException: Expected title, got null 
from line 650 of /srv/mediawiki/php-1.32.0-wmf.13/includes/logging/LogFormatter.php

2018-07-28 00:26:35 [W1u4OwpAAEUAAIFd6UIAAAAI] mw1274 enwiki 1.32.0-wmf.13 exception ERROR: [W1u4OwpAAEUAAIFd6UIAAAAI] /w/index.php?title=Special:Log&offset=20070819174422&limit=1&type=move&user=Physchim62&page=&tagfilter=&subtype=   MWException from line 650 of /srv/mediawiki/php-1.32.0-wmf.13/includes/logging/LogFormatter.php: Expected title, got null {"exception_id":"W1u4OwpAAEUAAIFd6UIAAAAI","exception_url":"/w/index.php?title=Special:Log&offset=20070819174422&limit=1&type=move&user=Physchim62&page=&tagfilter=&subtype=","caught_by":"mwe_handler"} 
[Exception MWException] (/srv/mediawiki/php-1.32.0-wmf.13/includes/logging/LogFormatter.php:650) Expected title, got null
  #0 /srv/mediawiki/php-1.32.0-wmf.13/includes/logging/MoveLogFormatter.php(52): LogFormatter->makePageLink(NULL)
  #1 /srv/mediawiki/php-1.32.0-wmf.13/includes/logging/LogFormatter.php(467): MoveLogFormatter->getMessageParameters()
  #2 /srv/mediawiki/php-1.32.0-wmf.13/includes/logging/LogFormatter.php(442): LogFormatter->getActionMessage()
  #3 /srv/mediawiki/php-1.32.0-wmf.13/includes/logging/LogEventsList.php(394): LogFormatter->getActionText()
  #4 /srv/mediawiki/php-1.32.0-wmf.13/includes/logging/LogPager.php(384): LogEventsList->logLine(stdClass)
  #5 /srv/mediawiki/php-1.32.0-wmf.13/includes/pager/IndexPager.php(445): LogPager->formatRow(stdClass)
  #6 /srv/mediawiki/php-1.32.0-wmf.13/includes/specials/SpecialLog.php(258): IndexPager->getBody()
  #7 /srv/mediawiki/php-1.32.0-wmf.13/includes/specials/SpecialLog.php(147): SpecialLog->show(FormOptions, array)
  #8 /srv/mediawiki/php-1.32.0-wmf.13/includes/specialpage/SpecialPage.php(566): SpecialLog->execute(NULL)
For Edit page
2018-07-19 07:27:58 [W1A9fQpAICwAAJKjYHUAAABR] mw1323 enwiki 1.32.0-wmf.12 exception ERROR: [W1A9fQpAICwAAJKjYHUAAABR] /w/index.php?title=Talk:C_Real&action=edit&redlink=1   MWException from line 650 of /srv/mediawiki/php-1.32.0-wmf.12/includes/logging/LogFormatter.php: Expected title, got null {"exception_id":"W1A9fQpAICwAAJKjYHUAAABR","exception_url":"/w/index.php?title=Talk:C_Real&action=edit&redlink=1","caught_by":"mwe_handler"} 
[Exception MWException] (/srv/mediawiki/php-1.32.0-wmf.12/includes/logging/LogFormatter.php:650) Expected title, got null
  #0 /srv/mediawiki/php-1.32.0-wmf.12/includes/logging/MoveLogFormatter.php(52): LogFormatter->makePageLink(NULL)
  #1 /srv/mediawiki/php-1.32.0-wmf.12/includes/logging/LogFormatter.php(467): MoveLogFormatter->getMessageParameters()
  #2 /srv/mediawiki/php-1.32.0-wmf.12/includes/logging/LogFormatter.php(442): LogFormatter->getActionMessage()
  #3 /srv/mediawiki/php-1.32.0-wmf.12/includes/logging/LogEventsList.php(389): LogFormatter->getActionText()
  #4 /srv/mediawiki/php-1.32.0-wmf.12/includes/logging/LogPager.php(378): LogEventsList->logLine(stdClass)
  #5 /srv/mediawiki/php-1.32.0-wmf.12/includes/pager/IndexPager.php(445): LogPager->formatRow(stdClass)
  #6 /srv/mediawiki/php-1.32.0-wmf.12/includes/logging/LogEventsList.php(657): IndexPager->getBody()
  #7 /srv/mediawiki/php-1.32.0-wmf.12/includes/EditPage.php(2603): LogEventsList::showLogExtract(OutputPage, array, Title, string, array)
  #8 /srv/mediawiki/php-1.32.0-wmf.12/includes/EditPage.php(652): EditPage->showIntro()

Example

These URLs are known to trigger it:

Original report
  1. Copy paste below link to browser address bar and click enter: https://ml.wikipedia.org/w/index.php?title=%E0%B4%AA%E0%B5%8D%E0%B4%B0%E0%B4%A4%E0%B5%8D%E0%B4%AF%E0%B5%87%E0%B4%95%E0%B4%82:%E0%B4%B0%E0%B5%87%E0%B4%96/Viswaprabha&offset=20160327215049&limit=250&type=&user=Viswaprabha
  2. Result here:
    image.png (189×1 px, 10 KB)
    The headline translates to "Internal Error". The body translates to "[Wl6GEQpAMCUAAEP5sSMAAAAR] 2018-01-16 23:09:06: "MWException" type critical exception"
exception.message	       	Expected title, got null
exception.trace
#0 /srv/mediawiki/php-1.31.0-wmf.16/includes/logging/MoveLogFormatter.php(52): LogFormatter->makePageLink(NULL)
#1 /srv/mediawiki/php-1.31.0-wmf.16/includes/logging/LogFormatter.php(461): MoveLogFormatter->getMessageParameters()
#2 /srv/mediawiki/php-1.31.0-wmf.16/includes/logging/LogFormatter.php(436): LogFormatter->getActionMessage()
#3 /srv/mediawiki/php-1.31.0-wmf.16/includes/logging/LogEventsList.php(388): LogFormatter->getActionText()
#4 /srv/mediawiki/php-1.31.0-wmf.16/includes/logging/LogPager.php(366): LogEventsList->logLine(stdClass)
#5 /srv/mediawiki/php-1.31.0-wmf.16/includes/pager/IndexPager.php(445): LogPager->formatRow(stdClass)
#6 /srv/mediawiki/php-1.31.0-wmf.16/includes/specials/SpecialLog.php(207): IndexPager->getBody()
#7 /srv/mediawiki/php-1.31.0-wmf.16/includes/specials/SpecialLog.php(109): SpecialLog->show(FormOptions, array)
#8 /srv/mediawiki/php-1.31.0-wmf.16/includes/specialpage/SpecialPage.php(522): SpecialLog->execute(string)
#9 /srv/mediawiki/php-1.31.0-wmf.16/includes/specialpage/SpecialPageFactory.php(578): SpecialPage->run(string)
#10 /srv/mediawiki/php-1.31.0-wmf.16/includes/MediaWiki.php(288): SpecialPageFactory::executePath(Title, RequestContext)
#11 /srv/mediawiki/php-1.31.0-wmf.16/includes/MediaWiki.php(854): MediaWiki->performRequest()
#12 /srv/mediawiki/php-1.31.0-wmf.16/includes/MediaWiki.php(524): MediaWiki->main()
#13 /srv/mediawiki/php-1.31.0-wmf.16/index.php(42): MediaWiki->run()
#14 /srv/mediawiki/w/index.php(3): include(string)
#15 {main}
exception_url	       	/w/index.php?title=%E0%B4%AA%E0%B5%8D%E0%B4%B0%E0%B4%A4%E0%B5%8D%E0%B4%AF%E0%B5%87%E0%B4%95%E0%B4%82:%E0%B4%B0%E0%B5%87%E0%B4%96/Viswaprabha&offset=20160327215049&limit=250&type=&user=Viswaprabha

Event Timeline

Jacob.jose triaged this task as Medium priority.Jan 17 2018, 7:40 AM
Jacob.jose added a project: Malayalam-Sites.
Aklapper renamed this task from Internal error when checking user log to Error when checking user log: "LogFormatter.php: Expected title, got null".Jan 17 2018, 11:57 AM
Aklapper updated the task description. (Show Details)
Krinkle triaged this task as High priority.Jul 19 2018, 7:34 AM
Krinkle subscribed.

This is about Special:Log, a similar error seems to also happen when viewing red links per T190477, which might be related.

Krinkle renamed this task from Error when checking user log: "LogFormatter.php: Expected title, got null" to Fatal error on Special:Log "MWException: Expected title, got null" from LogFormatter.php.Jul 24 2018, 2:43 PM

Probably related; the log entry (https://ml.wikipedia.org/w/api.php?action=query&list=logevents&leuser=Viswaprabha&lestart=20060110235733&lelimit=1) is for a move to a title that translates to "Special:Badtitle/Talk:" followed by another prefix.

Krinkle renamed this task from Fatal error on Special:Log "MWException: Expected title, got null" from LogFormatter.php to Unable to open edit page, or view Special:Log, for certain pages ("MWException: Expected title, got null" from LogFormatter.php).Jul 28 2018, 8:30 PM
Krinkle raised the priority of this task from High to Unbreak Now!.
Krinkle updated the task description. (Show Details)

I investigated one of the cases: https://en.wikipedia.org/w/index.php?title=Special:Log&offset=20070819174422&limit=1&type=move&user=Physchim62&page=&tagfilter=&subtype=

I looked up the problematic log entry in the Analytics DB replica (log_id=10430786). It concerns a move of a page titled "Talk:Talk:Social situation in the French suburbs/Archive 01" to "Talk:Social situation in the French suburbs/Archive 01" (removing the duplicated 'Talk' namespace). This title would become invalid around two years later, in rSVN45780.

Unfortunately that page was moved from an invalid title and there's nothing we can do about it, so we have to have a way to display this log entry.

I copied the log entry to the database of my local testing wiki. I get the same error with latest MediaWiki, but when I checkout out an older version (d14faa6bedf8cb5e400f910860e05a6f98709d01), it was able to display the log entry, happily linking to the invalid page. So it must have been broken in some commit since then.

Please ignore my previous comment, everything after the first sentence was incorrect. I looked at the wrong log entry and it went downhill from there.

The problematic log entry is a different one (log_id=10430773). It concerns a move of a page titled "Talk:Allegations of French apartheid/Archive 01" to "Talk:Talk:Social situation in the French suburbs/Archive 01" (with duplicated 'Talk' namespace). This title would become invalid around two years later, in rSVN45780. (The page was later moved to a fixed title without duplicated namespace, and that was the entry I mistakenly looked at first, log_id=10430786.)

Unfortunately that page was moved to an invalid title and there's nothing we can do about it, so we have to have a way to display this log entry.

I copied this log entry as well to the database of my local testing wiki. I get the same error with latest MediaWiki, but when I checkout an older version (d14faa6bedf8cb5e400f910860e05a6f98709d01), it doesn't fail; but instead of the new invalid title, it displays nothing (except <!-- ERROR --> in the HTML source).

Using git bisect, I found that the exception was introduced in rMWd0fa4e8d15ed: Use LogFormatter::getLinkRenderer in LogFormatter extensions. If you need to stop the exceptions, that commit can be reverted, which fixes the exception (and instead successfully produces incorrect output).

Nice find!

We handle a similar case in recent changes. The underlying similarity being with links such as "history" on Special:RecentChanges that link to the current version of pages, but still work if the page was renamed (showing the history of the modified page, not the unrelated new page created later under the old name). We solved that by using curid in the links, which takes precedence over titles. Eg. https://en.wikipedia.beta.wmflabs.org/w/index.php?title=Sandbox/A&curid=192360&action=history, showing history for Sandbox/B (as it should).

Perhaps we can do something similar for Special:Log? Alternatively, if that's infeasible or the page was deleted, perhaps we can render the log entry without hyperlinks, but afaik the format requires a link. I'm curious what the new LinkRenderer does differently that it refuses to link to an invalid title. Can this be bypassed? Seems like it should be possible to link to e.g. /wiki/Talk:Talk:Example plainly (with curid maybe). If the page was deleted and the title is now invalid, it'll point to Special:BadTitle, bu that seems unavoidable and better than a fatal?

In this case, the old log entries don't have a revision or page id, that was before we added the log_page field :)

LinkRenderer enforces the type of the $target parameter (and so PHP throws an exception if it is null). Linker checked for it and returned <!-- ERROR --> if it was null, without throwing an exception. (In this case, the exception is thrown from LogFormatter::makePageLink(), before it reaches LinkRenderer, anyway.)

In LogFormatter::makePageLink() we're several function calls away from the database query which returned that data, all we have is is a null $title. As a quick fix, I think we can just return "Invalid title" instead of a link. There is apparently some precedent for that in query special pages (search for code calling Linker::getInvalidTitleDescription()). If someone fancies to do some refactoring to pass in the text of the bad title, or some funny hacks (technically, a Title object can hold an invalid title…), that can be done later.

Change 449640 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/core@master] LogFormatter: Fail softer when trying to link an invalid titles

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

Change 449640 merged by jenkins-bot:
[mediawiki/core@master] LogFormatter: Fail softer when trying to link an invalid titles

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

Change 451367 had a related patch set uploaded (by Jforrester; owner: Bartosz Dziewoński):
[mediawiki/core@wmf/1.32.0-wmf.16] LogFormatter: Fail softer when trying to link an invalid titles

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

Change 451368 had a related patch set uploaded (by Jforrester; owner: Bartosz Dziewoński):
[mediawiki/core@wmf/1.32.0-wmf.15] LogFormatter: Fail softer when trying to link an invalid titles

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

Change 451368 merged by Jforrester:
[mediawiki/core@wmf/1.32.0-wmf.15] LogFormatter: Fail softer when trying to link an invalid titles

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

Change 451367 merged by Jforrester:
[mediawiki/core@wmf/1.32.0-wmf.16] LogFormatter: Fail softer when trying to link an invalid titles

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

Mentioned in SAL (#wikimedia-operations) [2018-08-08T17:00:23Z] <jforrester@deploy1001> Synchronized php-1.32.0-wmf.15/includes/logging/LogFormatter.php: SWAT T185049 Unbreak views of invalid title log entries, wmf.15 (duration: 01m 01s)

Mentioned in SAL (#wikimedia-operations) [2018-08-08T17:01:56Z] <jforrester@deploy1001> Synchronized php-1.32.0-wmf.16/includes/logging/LogFormatter.php: SWAT T185049 Unbreak views of invalid title log entries, wmf.16 (duration: 00m 58s)

Jdforrester-WMF assigned this task to matmarex.
Jdforrester-WMF removed a project: Patch-For-Review.
Jdforrester-WMF subscribed.

OK, I've hot-deployed this patch (without the i18n) to both production branches. All three URLs given above now load correct, but it will say ⧼invalidtitle⧽ instead of the proper i18n until it's synchronised by the regular scap process in a little bit. Declaring this Resolved.

Hi, we're getting this error in 1.31 as well, originating from the move_prot branch of ProtectLogFormatter::getMessageParameters where a log entry from 2009 has no data in the log_params column. Can this patch be cherry-picked into 1.31 as well?

I can submit a backport, sure. I have no idea what the release schedule is though.

Change 474970 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/core@REL1_31] LogFormatter: Fail softer when trying to link an invalid titles

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

Change 474970 merged by jenkins-bot:
[mediawiki/core@REL1_31] LogFormatter: Fail softer when trying to link an invalid titles

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

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:09 PM