Page MenuHomePhabricator

PHP Notice: Trying to get property 'tagName' of non-object
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error

A burst of tens-of-thousands of these errors happened.

MediaWiki version: 1.36.0-wmf.37

message
PHP Notice: Trying to get property 'tagName' of non-object
message
PHP Notice: Trying to get property 'parentNode' of non-object
message
PHP Notice: Trying to get property 'nextSibling' of non-object
exception.trace
from /srv/mediawiki/php-1.36.0-wmf.37/extensions/DiscussionTools/includes/CommentModifier.php(208)
#0 /srv/mediawiki/php-1.36.0-wmf.37/extensions/DiscussionTools/includes/CommentModifier.php(208): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.36.0-wmf.37/extensions/DiscussionTools/includes/CommentModifier.php(507): MediaWiki\Extension\DiscussionTools\CommentModifier::addListItem(MediaWiki\Extension\DiscussionTools\CommentItem)
#2 /srv/mediawiki/php-1.36.0-wmf.37/extensions/DiscussionTools/includes/CommentModifier.php(538): MediaWiki\Extension\DiscussionTools\CommentModifier::addReply(MediaWiki\Extension\DiscussionTools\CommentItem, DOMElement)
#3 /srv/mediawiki/php-1.36.0-wmf.37/extensions/DiscussionTools/includes/ApiDiscussionToolsEdit.php(176): MediaWiki\Extension\DiscussionTools\CommentModifier::addWikitextReply(MediaWiki\Extension\DiscussionTools\CommentItem, string)
#4 /srv/mediawiki/php-1.36.0-wmf.37/includes/api/ApiMain.php(1647): MediaWiki\Extension\DiscussionTools\ApiDiscussionToolsEdit->execute()
#5 /srv/mediawiki/php-1.36.0-wmf.37/includes/api/ApiMain.php(617): ApiMain->executeAction()
#6 /srv/mediawiki/php-1.36.0-wmf.37/includes/api/ApiMain.php(588): ApiMain->executeActionWithErrorHandling()
#7 /srv/mediawiki/php-1.36.0-wmf.37/api.php(90): ApiMain->execute()
#8 /srv/mediawiki/php-1.36.0-wmf.37/api.php(45): wfApiMain()
#9 /srv/mediawiki/w/api.php(3): require(string)
#10 {main}

Details

Request ID
bb6b716c-1ed5-4d8b-b5ec-9582d805f7ab
Request URL
https://ar.wikipedia.org/w/api.php

Event Timeline

Krinkle edited Stack Trace. (Show Details)
Krinkle added a project: Editing-team.
Krinkle added subscribers: Esanders, matmarex.

It happened only in a single request to a single page on ar.wp. We should investigate but I don't think we need to do it right now.

I'm surprised phan doesn't detect this.

Minimal test case: https://en.wikipedia.beta.wmflabs.org/wiki/Talk:T279445

== test1 ==
a [[User:Matma Rex|Matma Rex]] ([[User talk:Matma Rex|talk]]) 10:25, 21 April 2021 (UTC)
:b [[User:Matma Rex|Matma Rex]] ([[User talk:Matma Rex|talk]]) 10:25, 21 April 2021 (UTC)
;d [[User:Matma Rex|Matma Rex]] ([[User talk:Matma Rex|talk]]) 10:25, 21 April 2021 (UTC)
:e [[User:Matma Rex|Matma Rex]] ([[User talk:Matma Rex|talk]]) 10:25, 21 April 2021 (UTC)

== test2 ==
a [[User:Matma Rex|Matma Rex]] ([[User talk:Matma Rex|talk]]) 10:25, 21 April 2021 (UTC)
:b [[User:Matma Rex|Matma Rex]] ([[User talk:Matma Rex|talk]]) 10:25, 21 April 2021 (UTC)
::c [[User:Matma Rex|Matma Rex]] ([[User talk:Matma Rex|talk]]) 10:25, 21 April 2021 (UTC)
;d [[User:Matma Rex|Matma Rex]] ([[User talk:Matma Rex|talk]]) 10:25, 21 April 2021 (UTC)
:e [[User:Matma Rex|Matma Rex]] ([[User talk:Matma Rex|talk]]) 10:25, 21 April 2021 (UTC)

To reproduce the bug, you need a comment with multiple replies, where a middle reply is incorrect indented with ; instead of :.

When replying to the last existing reply:

  • test1: You get a JavaScript error "Uncaught DOMException: Failed to execute 'insertBefore' on 'Node': Only one element on document allowed."
  • test2: The reply widget seems to work, but posting the reply times out, causing the numerous PHP notices (there's an infinite loop)

(Arguably, the PHP code should also throw a similar exception, but PHP is happy to have a document node with multiple children: https://3v4l.org/v84np)

The JS version works in test2 because it runs on old PHP Parser HTML, which is different than Parsoid HTML for this case!

Change 681686 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/DiscussionTools@master] modifier: Guard against infinite loop

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

Change 681687 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/DiscussionTools@master] Fix adding comments in lists containing <dt> tags

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

Change 681686 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@master] modifier: Guard against infinite loop

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

Change 681687 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@master] Fix adding comments in lists containing <dt> tags

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

matmarex added a project: Editing QA.

For test instructions, see an earlier comment: T279445#7023793