Page MenuHomePhabricator

Error: Call to a member function getModel() on null
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   Error: Call to a member function getModel() on null
exception.trace
from /srv/mediawiki/php-1.37.0-wmf.21/includes/api/ApiEditPage.php(480)
#0 /srv/mediawiki/php-1.37.0-wmf.21/includes/api/ApiMain.php(1845): ApiEditPage->execute()
#1 /srv/mediawiki/php-1.37.0-wmf.21/includes/api/ApiMain.php(824): ApiMain->executeAction()
#2 /srv/mediawiki/php-1.37.0-wmf.21/includes/api/ApiMain.php(795): ApiMain->executeActionWithErrorHandling()
#3 /srv/mediawiki/php-1.37.0-wmf.21/api.php(90): ApiMain->execute()
#4 /srv/mediawiki/php-1.37.0-wmf.21/api.php(45): wfApiMain()
#5 /srv/mediawiki/w/api.php(3): require(string)
#6 {main}
Impact

Seen half a dozen time in the past few weeks.

Notes

Event Timeline

ApiEditPage.php
		// T255700: Ensure content models of the base content
		// and fetched revision remain the same before attempting to save.
		$editRevId = $requestArray['editRevId'] ?? false;
		$baseRev = $this->revisionLookup->getRevisionByTitle( $titleObj, $editRevId );
		$baseContentModel = $baseRev
			? $baseRev->getContent( SlotRecord::MAIN )->getModel()
			: $pageObj->getContentModel();

getContent( SlotRecord::MAIN ) is documented to return null, if the content is not visible for the current user.

When setting baserevid of action=edit to a revision id with revision deleted content (it could only non-current ones), it fails.
The audience of the getContent calll is public, which means for sysop it is not possible to use the revision deleted content as base rev, while index.php allows

Change 725437 had a related patch set uploaded (by Ammarpad; author: Ammarpad):

[mediawiki/core@master] ApiEditPage: Harden content model mismatch checks

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

Change 725437 merged by jenkins-bot:

[mediawiki/core@master] ApiEditPage: Harden content model mismatch checks

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