Page MenuHomePhabricator

Warning: SQLPlatform::isWriteQuery fallback to regex (SpecialShortPages)
Closed, ResolvedPublic

Description

#2 /srv/mediawiki/php-1.41.0-wmf.5/includes/libs/rdbms/database/DBConnRef.php(119): Wikimedia\Rdbms\Database->query(string, string, integer)
#3 /srv/mediawiki/php-1.41.0-wmf.5/includes/libs/rdbms/database/DBConnRef.php(302): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#4 /srv/mediawiki/php-1.41.0-wmf.5/includes/specials/SpecialShortPages.php(139): Wikimedia\Rdbms\DBConnRef->query(string, string)
#5 /srv/mediawiki/php-1.41.0-wmf.5/includes/specialpage/QueryPage.php(732): SpecialShortPages->reallyDoQuery(integer, integer)

This call to ->query() is very special:

$sql = $dbr->unionConditionPermutations(
	$tables,
	$fields,
	[ 'page_namespace' => $namespaces ],
	$conds,
	$fname,
	$options,
	$join_conds
);
// phpcs:ignore MediaWiki.Usage.DbrQueryUsage.DbrQueryFound
$res = $dbr->query( $sql, $fname );

According to codesearch, Special:ShortPages is the only caller of unionConditionPermutations(). Ideally, we would probably transform this method into one that does the query and returns results, instead of returning SQL; but perhaps it’s easier to just add the right ISQLPlatform::QUERY_CHANGE_* constant to the ->query() call for now, to silence the deprecation warning.

Event Timeline

Change 910437 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/core@master] SpecialShortPages: Mark query as read-only

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

unionConditionPermutations() was added in 2017 for T149077 and T168010; before anyone embarks on a wider refactoring of that method, it’s probably worth checking if the problems it works around even still exist in current MariaDB versions. (But I don’t plan to do that myself – I think adding ISQLPlatform::QUERY_CHANGE_NONE is good enough for now.)

Change 910437 merged by jenkins-bot:

[mediawiki/core@master] SpecialShortPages: Mark query as read-only

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

Alright, then let’s close this already and leave the broader improvement for that task.