Page MenuHomePhabricator

Unable to open user sub pages with trailing space (Blank page fatal: "invalid DB key")
Closed, ResolvedPublic

Description

After moving the page Քննարկում:Գոհար_Նալբանդյան_/_Չեռնոբիլ_(մինի_սերիալ) to Մասնակից:Գոհար_Նալբանդյան_/_Չեռնոբիլ_(մինի_սերիալ) in hywiki, we get the following error:

MediaWiki internal error.

Original exception: [XQBxUwpAME0AAIK-kqkAAACH] 2019-06-12 03:28:19: Fatal exception of type "Wikimedia\Assert\ParameterAssertionException"

Exception caught inside exception handler.

Set $wgShowExceptionDetails = true; at the bottom of LocalSettings.php to show detailed debugging information.

And there is no way to revert that edit and recover the content of the article :(. Is there any way to solve this problem>

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 12 2019, 3:37 AM
Aklapper renamed this task from MediaWiki internal error to MediaWiki internal error after page move in hywiki.Jun 12 2019, 10:57 AM
Aklapper added a project: WikiLove.

Is there any way to solve this problem>

Yes: Find the incorrect code and provide a patch in Gerrit to make it correct code. :)

exception.message	       	Bad value for parameter $dbkey: invalid DB key 'Գոհար_Նալբանդյան_'
exception.trace
#0 /srv/mediawiki/php-1.34.0-wmf.8/includes/title/TitleValue.php(105): Wikimedia\Assert\Assert::parameter(boolean, string, string)
#1 /srv/mediawiki/php-1.34.0-wmf.8/includes/title/NamespaceInfo.php(162): TitleValue->__construct(integer, string)
#2 /srv/mediawiki/php-1.34.0-wmf.8/includes/Title.php(1523): NamespaceInfo->getTalkPage(Title)
#3 /srv/mediawiki/php-1.34.0-wmf.8/extensions/WikiLove/includes/WikiLoveHooks.php(166): Title->getTalkPage()
#4 /srv/mediawiki/php-1.34.0-wmf.8/extensions/WikiLove/includes/WikiLoveHooks.php(57): WikiLoveHooks::getUserTalkPage(Title, User)
#5 /srv/mediawiki/php-1.34.0-wmf.8/includes/Hooks.php(174): WikiLoveHooks::onBeforePageDisplay(OutputPage, SkinVector)
#6 /srv/mediawiki/php-1.34.0-wmf.8/includes/Hooks.php(234): Hooks::callHook(string, array, array, NULL, string)
#7 /srv/mediawiki/php-1.34.0-wmf.8/includes/OutputPage.php(2746): Hooks::runWithoutAbort(string, array)
#8 /srv/mediawiki/php-1.34.0-wmf.8/includes/MediaWiki.php(872): OutputPage->output(boolean)
#9 /srv/mediawiki/php-1.34.0-wmf.8/includes/MediaWiki.php(884): Closure$MediaWiki::main()
#10 /srv/mediawiki/php-1.34.0-wmf.8/includes/MediaWiki.php(515): MediaWiki->main()
#11 /srv/mediawiki/php-1.34.0-wmf.8/index.php(42): MediaWiki->run()
#12 /srv/mediawiki/w/index.php(3): include(string)
#13 {main}
Restricted Application added a project: Growth-Team. · View Herald TranscriptJun 12 2019, 10:58 AM
Aklapper renamed this task from MediaWiki internal error after page move in hywiki to MediaWiki internal error after page move in hywiki: invalid DB key.Jun 12 2019, 10:59 AM
Krinkle renamed this task from MediaWiki internal error after page move in hywiki: invalid DB key to Unable to open some user pages on hywiki (Blank page fatal: "invalid DB key").Jun 12 2019, 6:01 PM
Krinkle updated the task description. (Show Details)
Krinkle triaged this task as High priority.Jun 12 2019, 6:03 PM
Krinkle added a project: Core Platform Team.
Krinkle added subscribers: daniel, Krinkle.

Impact is that some user pages cannot be viewed. Following links to them results in a blank page like this:

Given the trace involves Title->getTalkPage and fatals in TitleValue->__construct, this is very likely not related to WikiLove but rather caused by the same commit that also caused some of these regressions: T224095, T224811, T222628, T222529. This might further indicate that a contract has been broken, although I'll leave it to @daniel / CPT to decide whether to fixup the caller in WikiLove somehow, or to generally support this use case in core the way it was previously.

Krinkle renamed this task from Unable to open some user pages on hywiki (Blank page fatal: "invalid DB key") to Unable to open user sub pages with trailing space (Blank page fatal: "invalid DB key").EditedJun 12 2019, 6:07 PM

I've reproduced this on en.wikipedia.org, and narrowed it down to a trailing space in the parent page title.

Note a space in before slash is entirely valid in MediaWiki. As demonstrated by this page on test2.wikipedia.org:

daniel added a comment.EditedJun 12 2019, 6:49 PM

Note a space in before slash is entirely valid in MediaWiki.

It is, but it causes confusion when trying to remove a subpage suffix.

The problem lies with Title::getBaseText() / getSubpageText() / getRootText() which would cut away the suffix, but not trim any leading or trailing whitespace or underscores. Then getBaseTitle() / getRootTite() construct a new (invlid!) Title object from that, which then triggers an error when getTalkPage is called on it, because NamespaceInfo->getTalkPage(Title) tries to construct a TitleValue.

The expectation that has been broken is "it is possible to get the talk page of an invalid title".

My suggestion for fixing this would be to:

  • introduce a trimTitle method in TitleParser
  • use that to trim the return values of getBaseText and friends.
  • maybe also use it in makeTitle; or let makeTitle fail when called on an invalid title - after all, it'S contract says "It's assumed that $ns and $title are safe", which is violated in this case.

A somewhat rougher approach would be to simply replace makeTitle with makeTitleSafe in getBaseTitle and getRootTitle.

Change 517014 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] Title: ensure getBaseTitle and getRootTitle return valid Titles.

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

WDoranWMF added subscribers: BPirkle, WDoranWMF.

@BPirkle Could you review the patchset for this ticket?

Change 517014 merged by jenkins-bot:
[mediawiki/core@master] Title: ensure getBaseTitle and getRootTitle return valid Titles

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

daniel added a comment.Jul 3 2019, 8:43 AM

should be fixed now, waiting for this to go live to confirm

Change 521253 had a related patch set uploaded (by Urbanecm; owner: Daniel Kinzler):
[mediawiki/core@wmf/1.34.0-wmf.11] Title: ensure getBaseTitle and getRootTitle return valid Titles

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

Change 521253 merged by jenkins-bot:
[mediawiki/core@wmf/1.34.0-wmf.11] Title: ensure getBaseTitle and getRootTitle return valid Titles

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

Mentioned in SAL (#wikimedia-operations) [2019-07-08T11:44:33Z] <urbanecm@deploy1001> Synchronized php-1.34.0-wmf.11/includes/Title.php: SWAT: [[:gerrit:521253|Title: ensure getBaseTitle and getRootTitle return valid Titles]] (T225585) (duration: 00m 50s)

@daniel i've backported this into wmf.11 to speed up the fixing. Can you (or somebody else) verify it's indeed fixed now please?

@daniel i've backported this into wmf.11 to speed up the fixing. Can you (or somebody else) verify it's indeed fixed now please?

The only thing I can do to verify is to click the link in the description and note that it indeed no longer triggers an error. I consider that fixed :)

daniel closed this task as Resolved.Jul 8 2019, 11:52 AM