Page MenuHomePhabricator

InvalidArgumentException: WikiPage constructed on a Title that cannot exist as a page: Special:NewEntitySchema (NewEntitySchemaTest::testNewSchemaIsNotCreatedWhenBlocked test failure)
Closed, ResolvedPublicPRODUCTION ERROR

Description

Special:NewEntitySchema crashes when loaded by a blocked user. This breaks CI (EntitySchema, ApiFeatureUsage), and has also happened in production once:

Error
normalized_message
[{reqId}] {exception_url}   InvalidArgumentException: WikiPage constructed on a Title that cannot exist as a page: Special:NewEntitySchema
exception.trace
from /srv/mediawiki/php-1.39.0-wmf.3/includes/page/WikiPage.php(178)
#0 /srv/mediawiki/php-1.39.0-wmf.3/includes/page/Article.php(144): WikiPage->__construct(Title)
#1 /srv/mediawiki/php-1.39.0-wmf.3/includes/page/Article.php(130): Article->newPage(Title)
#2 /srv/mediawiki/php-1.39.0-wmf.3/includes/page/Article.php(182): Article->__construct(Title)
#3 /srv/mediawiki/php-1.39.0-wmf.3/includes/Permissions/PermissionManager.php(802): Article::newFromTitle(Title, RequestContext)
#4 /srv/mediawiki/php-1.39.0-wmf.3/includes/Permissions/PermissionManager.php(465): MediaWiki\Permissions\PermissionManager->checkUserBlock(string, User, array, string, boolean, Title)
#5 /srv/mediawiki/php-1.39.0-wmf.3/includes/Permissions/PermissionManager.php(310): MediaWiki\Permissions\PermissionManager->getPermissionErrorsInternal(string, User, Title, string)
#6 /srv/mediawiki/php-1.39.0-wmf.3/extensions/EntitySchema/src/MediaWiki/Specials/NewEntitySchema.php(241): MediaWiki\Permissions\PermissionManager->getPermissionErrors(string, User, Title, string, array)
#7 /srv/mediawiki/php-1.39.0-wmf.3/extensions/EntitySchema/src/MediaWiki/Specials/NewEntitySchema.php(47): EntitySchema\MediaWiki\Specials\NewEntitySchema->checkPermissionsWithSubpage(NULL)
#8 /srv/mediawiki/php-1.39.0-wmf.3/includes/specialpage/SpecialPage.php(671): EntitySchema\MediaWiki\Specials\NewEntitySchema->execute(NULL)
#9 /srv/mediawiki/php-1.39.0-wmf.3/includes/specialpage/SpecialPageFactory.php(1378): SpecialPage->run(NULL)
#10 /srv/mediawiki/php-1.39.0-wmf.3/includes/MediaWiki.php(315): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#11 /srv/mediawiki/php-1.39.0-wmf.3/includes/MediaWiki.php(911): MediaWiki->performRequest()
#12 /srv/mediawiki/php-1.39.0-wmf.3/includes/MediaWiki.php(565): MediaWiki->main()
#13 /srv/mediawiki/php-1.39.0-wmf.3/index.php(53): MediaWiki->run()
#14 /srv/mediawiki/php-1.39.0-wmf.3/index.php(46): wfIndexMain()
#15 /srv/mediawiki/w/index.php(3): require(string)
#16 {main}
Impact

Slight logspam, ugly error message for users who would ultimately not be allowed to use the special page anyways.

Notes
CI output

https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-php72-noselenium-docker/147085/console

05:52:36 1) EntitySchema\Tests\Integration\MediaWiki\Specials\NewEntitySchemaTest::testNewSchemaIsNotCreatedWhenBlocked
05:52:36 InvalidArgumentException: WikiPage constructed on a Title that cannot exist as a page: Special:NewEntitySchema
05:52:36 
05:52:36 /workspace/src/includes/page/WikiPage.php:177
05:52:36 /workspace/src/includes/page/Article.php:141
05:52:36 /workspace/src/includes/page/Article.php:127
05:52:36 /workspace/src/includes/page/Article.php:179
05:52:36 /workspace/src/includes/Permissions/PermissionManager.php:815
05:52:36 /workspace/src/includes/Permissions/PermissionManager.php:478
05:52:36 /workspace/src/includes/Permissions/PermissionManager.php:323
05:52:36 /workspace/src/extensions/EntitySchema/src/MediaWiki/Specials/NewEntitySchema.php:241
05:52:36 /workspace/src/extensions/EntitySchema/src/MediaWiki/Specials/NewEntitySchema.php:47
05:52:36 /workspace/src/tests/phpunit/includes/specials/SpecialPageExecutor.php:115
05:52:36 /workspace/src/tests/phpunit/includes/specials/SpecialPageExecutor.php:44
05:52:36 /workspace/src/tests/phpunit/includes/specials/SpecialPageTestBase.php:78
05:52:36 /workspace/src/extensions/EntitySchema/tests/phpunit/integration/MediaWiki/Specials/NewEntitySchemaTest.php:87
05:52:36 /workspace/src/tests/phpunit/MediaWikiIntegrationTestCase.php:467

Event Timeline

Can be reproduced locally , visiting Special:NewEntitySchema as a blocked user crashes. To me this seems like a regression in core, I don’t think it’s wrong for the special page to pass its own title into PermissionManager::getPermissionErrors(). (The relevant parameter is also typed as a LinkTarget (which includes special pages), not as a PageIdentity (which conceptually excludes them, though Title currently still implements it).)

git bisect says the first bad MediaWiki core commit is rMW1ae3b0ca8672: Allow ContentHandler to "override" non-existent actions (I67c1ae9534, T303237), which seems to have removed a condition around the Article::newFromTitle( $title, $context ) call that’s crashing here.

Lucas_Werkmeister_WMDE changed the subtype of this task from "Task" to "Production Error".Apr 27 2022, 5:19 PM

Also seen in production (though only once), I’ll fill in the details.

Lucas_Werkmeister_WMDE renamed this task from NewEntitySchemaTest::testNewSchemaIsNotCreatedWhenBlocked test failure to InvalidArgumentException: WikiPage constructed on a Title that cannot exist as a page: Special:NewEntitySchema (NewEntitySchemaTest::testNewSchemaIsNotCreatedWhenBlocked test failure).Apr 27 2022, 5:22 PM
Lucas_Werkmeister_WMDE set Request URL to https://www.wikidata.org/wiki/Special:NewEntitySchema.
Lucas_Werkmeister_WMDE updated the task description. (Show Details)
Lucas_Werkmeister_WMDE set Release Version to 1.39.0-wmf.3.

Change 787427 had a related patch set uploaded (by Jakob; author: Jakob):

[mediawiki/extensions/EntitySchema@master] Add quick fix for special page permission check

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

Change 787427 merged by jenkins-bot:

[mediawiki/extensions/EntitySchema@master] Add quick fix for special page permission check

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

This is fixed for now, and can roll out with next week’s train. But I think we should leave the issue open, to me it’s still a regression that PermissionManager can no longer be called with a special page title despite its $page argument being a LinkTarget.

Change 787571 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/core@master] Don't consult ActionFactory for pages that can't exist

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

git bisect says the first bad MediaWiki core commit is rMW1ae3b0ca8672: Allow ContentHandler to "override" non-existent actions (I67c1ae9534, T303237), which seems to have removed a condition around the Article::newFromTitle( $title, $context ) call that’s crashing here.

I didn't mention that commit in my fix because I believe the bug existed before that change, for actions that exist.

Change 787571 merged by jenkins-bot:

[mediawiki/core@master] Don't consult ActionFactory for pages that can't exist

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

Change 787746 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/EntitySchema@master] Revert "Add quick fix for special page permission check"

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

Change 787746 merged by jenkins-bot:

[mediawiki/extensions/EntitySchema@master] Revert "Add quick fix for special page permission check"

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