Page MenuHomePhabricator

Special:AllComments is incompatible with MediaWiki 1.42
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Install CommentStreams on MediaWiki 1.42
  • Go to Special:AllComments

What happens?

Table name component contains unexpected quote or dot character

from /srv/mediawiki/1.42/includes/libs/rdbms/platform/SQLPlatform.php(1051)
#0 /srv/mediawiki/1.42/includes/libs/rdbms/platform/SQLPlatform.php(991): Wikimedia\Rdbms\Platform\SQLPlatform->extractTableNameComponents(string)
#1 /srv/mediawiki/1.42/includes/libs/rdbms/platform/SQLPlatform.php(957): Wikimedia\Rdbms\Platform\SQLPlatform->qualifiedTableComponents(string)
#2 /srv/mediawiki/1.42/includes/libs/rdbms/platform/SQLPlatform.php(936): Wikimedia\Rdbms\Platform\SQLPlatform->tableName(string)
#3 /srv/mediawiki/1.42/includes/libs/rdbms/platform/SQLPlatform.php(837): Wikimedia\Rdbms\Platform\SQLPlatform->tableNameWithAlias(string, string)
#4 /srv/mediawiki/1.42/includes/libs/rdbms/platform/SQLPlatform.php(665): Wikimedia\Rdbms\Platform\SQLPlatform->tableNamesWithIndexClauseOrJOIN(array, array, array, array)
#5 /srv/mediawiki/1.42/includes/libs/rdbms/database/Database.php(3334): Wikimedia\Rdbms\Platform\SQLPlatform->selectSQLText(array, array, array, string, array, array)
#6 /srv/mediawiki/1.42/includes/libs/rdbms/database/DatabaseMySQL.php(730): Wikimedia\Rdbms\Database->selectSQLText(array, array, array, string, array, array)
#7 /srv/mediawiki/1.42/includes/libs/rdbms/database/Database.php(1342): Wikimedia\Rdbms\DatabaseMySQL->selectSQLText(array, array, array, string, array, array)
#8 /srv/mediawiki/1.42/includes/libs/rdbms/database/DBConnRef.php(119): Wikimedia\Rdbms\Database->select(array, array, array, string, array, array)
#9 /srv/mediawiki/1.42/includes/libs/rdbms/database/DBConnRef.php(351): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#10 /srv/mediawiki/1.42/includes/libs/rdbms/querybuilder/SelectQueryBuilder.php(729): Wikimedia\Rdbms\DBConnRef->select(array, array, array, string, array, array)
#11 /srv/mediawiki/1.42/extensions/CommentStreams/includes/CommentStreamsStore.php(246): Wikimedia\Rdbms\SelectQueryBuilder->fetchResultSet()
#12 /srv/mediawiki/1.42/extensions/CommentStreams/includes/CommentStreamsAllComments.php(85): MediaWiki\Extension\CommentStreams\CommentStreamsStore->getCommentPages(integer, integer)
#13 /srv/mediawiki/1.42/includes/specialpage/SpecialPage.php(719): MediaWiki\Extension\CommentStreams\CommentStreamsAllComments->execute(NULL)
#14 /srv/mediawiki/1.42/includes/specialpage/SpecialPageFactory.php(1669): MediaWiki\SpecialPage\SpecialPage->run(NULL)
#15 /srv/mediawiki/1.42/includes/actions/ActionEntryPoint.php(504): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, MediaWiki\Context\RequestContext)
#16 /srv/mediawiki/1.42/includes/actions/ActionEntryPoint.php(145): MediaWiki\Actions\ActionEntryPoint->performRequest()
#17 /srv/mediawiki/1.42/includes/MediaWikiEntryPoint.php(199): MediaWiki\Actions\ActionEntryPoint->execute()
#18 /srv/mediawiki/config/initialise/entrypoints/index.php(98): MediaWiki\MediaWikiEntryPoint->run()
#19 {main}

What should have happened instead?
All the comments are shown as normal

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

  • MediaWiki: 1.42.1 (61e9a5b) 21:29, 12 July 2024
  • PHP: 8.2.20 (fpm-fcgi)
  • MariaDB: 10.11.6-MariaDB-1:10.11.6+maria~deb12-log
  • CommentStreams: 8.0.2 (4fac5fd) 17:23, 16 June 2024

Other information (browser name/version, screenshots, etc.):
This appears to be caused by T318845.

Miraheze issue tracker task: https://issue-tracker.miraheze.org/T12512

Event Timeline

Restricted Application added subscribers: Reception123, Aklapper. · View Herald Transcript
BlankEclair renamed this task from CommentStreams is incompatible with MediaWiki 1.42 to Special:AllComments is incompatible with MediaWiki 1.42.Aug 28 2024, 10:07 AM

Hi, What is the action plan to get Special:AllComments up and running again?

@Paladium: Same as with any other issue: You or someone else needs to volunteer to investigate and contribute a software patch which fixes the problem

Personally, I tried to take a stab at it when I first filed it, but it was too complex for me to figure out.

Looks like this is the offending table name.

((SELECT cst_c_comment_page_id AS `union_page_id` FROM `cs_comments` ) UNION (SELECT cst_r_reply_page_id AS `union_page_id` FROM `cs_replies` )) AS union_table

As far as I can tell, extractTableNameComponents checks whether there is a quotation mark in the string. If there is, it'll panic an throw the exception seen here. The backticks (`) are the culprit.

This SQL query is malformed possibly because the table name is constructed from another query. In CommentStreamsStore.php, this line ->from( '(' . $union->getSQL() . ') AS union_table' ) makes the software think the ((SELECT cst_c_comment_page_id... SQL statement is the name of a table. Even if the backticks don't exist, the query will fail because the entire SQL statement will still be treated as a table name.

SelectQueryBuilder probably supports nested subqueries somewhere. Using that feature instead of the hack currently employed by CommentStreams should be able to fix it.

Change #1110742 had a related patch set uploaded (by Umherirrender; author: ItSpiderman):

[mediawiki/extensions/CommentStreams@REL1_43] Fix fatal when selecting from a subquery

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

Change #1112376 had a related patch set uploaded (by Umherirrender; author: ItSpiderman):

[mediawiki/extensions/CommentStreams@master] Fix fatal when selecting from a subquery

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

Change #1112376 merged by Umherirrender:

[mediawiki/extensions/CommentStreams@master] Fix fatal when selecting from a subquery

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

Change #1112378 had a related patch set uploaded (by Umherirrender; author: ItSpiderman):

[mediawiki/extensions/CommentStreams@REL1_42] Fix fatal when selecting from a subquery

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

Umherirrender assigned this task to Dsavuljesku.
Umherirrender subscribed.

The validation causing the exception was added in f3607d6512cdc337bd9cbbd3cc94d71e06c78cb6

Reviewed the patch set from the duplicate task.

Change #1110742 merged by jenkins-bot:

[mediawiki/extensions/CommentStreams@REL1_43] Fix fatal when selecting from a subquery

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

Change #1112378 merged by jenkins-bot:

[mediawiki/extensions/CommentStreams@REL1_42] Fix fatal when selecting from a subquery

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