Page MenuHomePhabricator

Fatal Error when trying to read notifications: Call to a member function getComment() on null
Closed, ResolvedPublic

Description

I get error "[XJjRqgpAAEAAABehZz8AAACS] 2019-03-25 13:03:38: Fatal exception of type "Error"" when trying to read my notifications.

Event Timeline

kolbert created this task.Mar 25 2019, 1:15 PM
Restricted Application added a project: Growth-Team. · View Herald TranscriptMar 25 2019, 1:15 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Daimona added a subscriber: Daimona.
message
Call to a member function getComment() on null
Trace
#0 /srv/mediawiki/php-1.33.0-wmf.22/extensions/Echo/includes/formatters/SpecialNotificationsFormatter.php(48): EchoMentionInSummaryPresentationModel->getBodyMessage()
#1 /srv/mediawiki/php-1.33.0-wmf.22/extensions/Echo/includes/formatters/EchoEventFormatter.php(72): SpecialNotificationsFormatter->formatModel(EchoMentionInSummaryPresentationModel)
#2 /srv/mediawiki/php-1.33.0-wmf.22/extensions/Echo/includes/DataOutputFormatter.php(187): EchoEventFormatter->format(EchoEvent)
#3 /srv/mediawiki/php-1.33.0-wmf.22/extensions/Echo/includes/DataOutputFormatter.php(147): EchoDataOutputFormatter::formatNotification(EchoEvent, User, string, LanguageEn)
#4 /srv/mediawiki/php-1.33.0-wmf.22/extensions/Echo/includes/special/SpecialNotifications.php(63): EchoDataOutputFormatter::formatOutput(EchoNotification, string, User, LanguageEn)
#5 /srv/mediawiki/php-1.33.0-wmf.22/includes/specialpage/SpecialPage.php(569): SpecialNotifications->execute(NULL)
#6 /srv/mediawiki/php-1.33.0-wmf.22/includes/specialpage/SpecialPageFactory.php(558): SpecialPage->run(NULL)
#7 /srv/mediawiki/php-1.33.0-wmf.22/includes/MediaWiki.php(288): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#8 /srv/mediawiki/php-1.33.0-wmf.22/includes/MediaWiki.php(867): MediaWiki->performRequest()
#9 /srv/mediawiki/php-1.33.0-wmf.22/includes/MediaWiki.php(517): MediaWiki->main()
#10 /srv/mediawiki/php-1.33.0-wmf.22/index.php(42): MediaWiki->run()
#11 /srv/mediawiki/w/index.php(3): require(string)
#12 {main}
Aklapper renamed this task from Fatal Error when trying to read notifications to Fatal Error when trying to read notifications: Call to a member function getComment() on null.Mar 25 2019, 1:49 PM

Change 499558 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/extensions/Echo@master] Do not fail on unknown revids in mention-summary events

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

Umherirrender added subscribers: MaxSem, Umherirrender.
	public function getBodyMessage() {
		if ( $this->userCan( Revision::DELETED_COMMENT ) ) {
			$revision = $this->event->getRevision();
			$summary = $revision->getComment();
			$summary = Linker::formatComment( $summary );
			$summary = Sanitizer::stripAllTags( $summary );

			$msg = $this->msg( 'notification-body-mention' )
				->plaintextParams( $summary );
			return $msg;
		} else {
			return false;
		}
	}

EchoEvent::getRevision is documented to return null and the $revision->getComment() fails

it seems there is a mention-summary event without a (existing) 'revid'.

I would say this can only happen when Revision::newFromId does not find the provided revid due to deletion

The code above will render a notification with an empty body. If you want the notification to not be present at all in this case you can add your condition to the canRender() function of the presentation model.

Note that T204795 was similar in that it also involved creating notifications for an events where the rev-id data seemingly could not be resolved. I don't know if there is a common or central piece of code between the two that could prevent this, but just mentioning it :)

The code above will render a notification with an empty body. If you want the notification to not be present at all in this case you can add your condition to the canRender() function of the presentation model.

Yes, the event has a empty body, but the header described what was happen. It also linked to an invalid diff, because one revision is gone.
I want to fix the fatal first. I have no idea what the maintenancer of the extension would expect when a revision is missing.

When a page is deleted, the event is not showing, when undelete the event is shown, because it is associated with the pageid, but when on undelete a revision is missing, than this error is happen. One solution is to remove the event from the list. But what is with the count of unread events when it is not rendered? Maybe the mention is enough to look at the page what was happen to guess why mention and soit could stay. I have not looked how other events handled missing pages or revisions or users.

When it is expected to not render the event, feel free to upload a patch set.

I have no idea what the maintenancer of the extension would expect when a revision is missing.

I think what you have in the patch is in-line with the original intent of the code.

Change 499558 merged by jenkins-bot:
[mediawiki/extensions/Echo@master] Do not fail on unknown revids in mention-summary events

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

Umherirrender closed this task as Resolved.Apr 11 2019, 4:20 PM
Umherirrender triaged this task as Normal priority.