Page MenuHomePhabricator

EditHandler: Call to a member function getContent() on null
Open, HighPublicPRODUCTION ERROR

Description

Error

MediaWiki version: 1.36.0-wmf.34

message
Call to a member function getContent() on null
exception.trace
from /srv/mediawiki/php-1.36.0-wmf.34/includes/Rest/Handler/EditHandler.php(101)
#0 /srv/mediawiki/php-1.36.0-wmf.34/includes/Rest/Handler/ActionModuleBasedHandler.php(152): MediaWiki\Rest\Handler\EditHandler->mapActionModuleResult(array)
#1 /srv/mediawiki/php-1.36.0-wmf.34/includes/Rest/Router.php(395): MediaWiki\Rest\Handler\ActionModuleBasedHandler->execute()
#2 /srv/mediawiki/php-1.36.0-wmf.34/includes/Rest/Router.php(322): MediaWiki\Rest\Router->executeHandler(MediaWiki\Rest\Handler\UpdateHandler)
#3 /srv/mediawiki/php-1.36.0-wmf.34/includes/Rest/EntryPoint.php(165): MediaWiki\Rest\Router->execute(MediaWiki\Rest\RequestFromGlobals)
#4 /srv/mediawiki/php-1.36.0-wmf.34/includes/Rest/EntryPoint.php(130): MediaWiki\Rest\EntryPoint->execute()
#5 /srv/mediawiki/php-1.36.0-wmf.34/rest.php(31): MediaWiki\Rest\EntryPoint::main()
#6 /srv/mediawiki/w/rest.php(3): require(string)
#7 {main}

and in the same requests, prior to reaching the above fatal error:

message2
PHP Notice: Undefined index: newrevid
trace
from /srv/mediawiki/php-1.36.0-wmf.34/includes/Rest/Handler/EditHandler.php(100)
#0 /srv/mediawiki/php-1.36.0-wmf.34/includes/Rest/Handler/EditHandler.php(100): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.36.0-wmf.34/includes/Rest/Handler/ActionModuleBasedHandler.php(152): MediaWiki\Rest\Handler\EditHandler->mapActionModuleResult(array)
#2 /srv/mediawiki/php-1.36.0-wmf.34/includes/Rest/Router.php(395): MediaWiki\Rest\Handler\ActionModuleBasedHandler->execute()
#3 /srv/mediawiki/php-1.36.0-wmf.34/includes/Rest/Router.php(322): MediaWiki\Rest\Router->executeHandler(MediaWiki\Rest\Handler\UpdateHandler)
#4 /srv/mediawiki/php-1.36.0-wmf.34/includes/Rest/EntryPoint.php(165): MediaWiki\Rest\Router->execute(MediaWiki\Rest\RequestFromGlobals)
#5 /srv/mediawiki/php-1.36.0-wmf.34/includes/Rest/EntryPoint.php(130): MediaWiki\Rest\EntryPoint->execute()
#6 /srv/mediawiki/php-1.36.0-wmf.34/rest.php(31): MediaWiki\Rest\EntryPoint::main()
#7 /srv/mediawiki/w/rest.php(3): require(string)
#8 {main}

Impact

Notes

Details

Request URL
https://sq.wikipedia.org/w/rest.php/v1/page/[page]

Event Timeline

brennen renamed this task from Call to a member function getContent() on null to EditHandler: Call to a member function getContent() on null.Mar 19 2021, 12:03 AM
brennen changed Request URL from https://sq.wikipedia.org/w/rest.php/v1/page/P%C3%ABrdoruesi:Smallem%2FLivadhi%20personal%2FLangCodes to https://sq.wikipedia.org/w/rest.php/v1/page/[page].
brennen moved this task from Backlog to Logs/Train on the User-brennen board.
Krinkle edited Stack Trace. (Show Details)
Krinkle updated the task description. (Show Details)

At a glance, I suspect this will happen for null-edits: no new revision is created, so newrevid isn't set, so trying to load the revision returns null, so calling getContent() throws.

EDIT: confirmed. Fixing.

Change 673479 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] REST edit: handle null edits correctly

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

Change 673479 merged by jenkins-bot:
[mediawiki/core@master] REST edit: handle null edits correctly

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

The fix for this (b38e0e8) may send a db query looking for revision with rev_id 0 which does not make sense.

SELECT ... FROM `revision` ... WHERE rev_id = 0

The fix for this (b38e0e8) may send a db query looking for revision with rev_id 0 which does not make sense.

SELECT ... FROM `revision` ... WHERE rev_id = 0

While generally this would be pointless but harmless, this actually led me to realize a flaw in my patch: the response representing the state after a null-edit should reflect information from the page's current revision, not the edit's base revision. I'll make another patch to improve this.

Change 674627 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] UpdateHandler: fix response for null edits

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

The fix for this (b38e0e8) may send a db query looking for revision with rev_id 0 which does not make sense.

SELECT ... FROM `revision` ... WHERE rev_id = 0

While generally this would be pointless but harmless, this actually led me to realize a flaw in my patch: the response representing the state after a null-edit should reflect information from the page's current revision, not the edit's base revision. I'll make another patch to improve this.

Pointless is the same as "doesn't make sense" No one says it's harmful.

Change 674627 merged by jenkins-bot:
[mediawiki/core@master] UpdateHandler: fix response for null edits

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