Page MenuHomePhabricator

Special:ReplaceText throws DB error on Postgres
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • Have a MediaWiki 1.35.2 instance using Postgres as the database backend.
  • Make sure ReplaceText is enabled in your LocalSettings.php. This can be reproduced using version 1.4.1 that comes bundled with MediaWiki.
  • Go to Special:ReplaceText and put in any two strings, like "test" and "test2", then press submit.
  • Get DB error.

What happens?:

A database query error has occurred. This may indicate a bug in the software.

[cf4a423979752d0896b9a57e] /w/Special:ReplaceText Wikimedia\Rdbms\DBQueryError from line 1699 of /srv/mediawiki/live/includes/libs/rdbms/database/Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?

Error 42704: ERROR: type "signed" does not exist
LINE 1: ...nt_id) AND (CAST(SUBSTRING(content_address, 4) AS SIGNED) = ...
^

Function: ReplaceTextSearch::doSearchQuery
Query: SELECT page_id,page_namespace,page_title,old_text FROM "page","revision","pagecontent","slots","content" WHERE (old_text LIKE '%test%' ESCAPE '`' ) AND page_namespace = 0 AND (rev_id = page_latest) AND (rev_id = slot_revision_id) AND (slot_content_id = content_id) AND (CAST(SUBSTRING(content_address, 4) AS SIGNED) = old_id) ORDER BY page_namespace, page_title LIMIT 250

Backtrace:

#0 /srv/mediawiki/live/includes/libs/rdbms/database/Database.php(1683): Wikimedia\Rdbms\Database->getQueryException()
#1 /srv/mediawiki/live/includes/libs/rdbms/database/Database.php(1658): Wikimedia\Rdbms\Database->getQueryExceptionAndLog()
#2 /srv/mediawiki/live/includes/libs/rdbms/database/Database.php(1227): Wikimedia\Rdbms\Database->reportQueryError()
#3 /srv/mediawiki/live/includes/libs/rdbms/database/Database.php(1907): Wikimedia\Rdbms\Database->query()
#4 /srv/mediawiki/live/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->select()
#5 /srv/mediawiki/live/includes/libs/rdbms/database/DBConnRef.php(313): Wikimedia\Rdbms\DBConnRef->__call()
#6 /srv/mediawiki/live/extensions/ReplaceText/src/ReplaceTextSearch.php(70): Wikimedia\Rdbms\DBConnRef->select()
#7 /srv/mediawiki/live/extensions/ReplaceText/src/SpecialReplaceText.php(303): ReplaceTextSearch::doSearchQuery()
#8 /srv/mediawiki/live/extensions/ReplaceText/src/SpecialReplaceText.php(172): SpecialReplaceText->getTitlesForEditingWithContext()
#9 /srv/mediawiki/live/extensions/ReplaceText/src/SpecialReplaceText.php(73): SpecialReplaceText->doSpecialReplaceText()
#10 /srv/mediawiki/live/includes/specialpage/SpecialPage.php(600): SpecialReplaceText->execute()
#11 /srv/mediawiki/live/includes/specialpage/SpecialPageFactory.php(635): SpecialPage->run()
#12 /srv/mediawiki/live/includes/MediaWiki.php(307): MediaWiki\SpecialPage\SpecialPageFactory->executePath()
#13 /srv/mediawiki/live/includes/MediaWiki.php(940): MediaWiki->performRequest()
#14 /srv/mediawiki/live/includes/MediaWiki.php(543): MediaWiki->main()
#15 /srv/mediawiki/live/index.php(53): MediaWiki->run()
#16 /srv/mediawiki/live/index.php(46): wfIndexMain()
#17 {main}

What should have happened instead?:

Text replace should work without throwing a DB error.

It appears that this was caused by the fix for T264433, which changed this from INTEGER to SIGNED to workaround a MySQL bug.

I am able to workaround this error by locally patching the code to use INTEGER instead of SIGNED, effectively reverting the fix for the MySQL bug.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc:

MediaWiki 1.35.2
PHP 7.4.16 (fpm-fcgi)
PostgreSQL 13.2
ICU 68.2
Lua 5.1.5

ReplaceText 1.4.1

ReplaceText worked for me in 1.35.1, as far as I know this is a new regression in 1.35.2.

Event Timeline

Tiffany352 renamed this task from Special:ReplaceText broken on Postgres to Special:ReplaceText throws DB error on Postgres.Apr 14 2021, 2:39 AM
Tiffany352 updated the task description. (Show Details)

Change 692025 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/extensions/ReplaceText@master] Fix mysql specifc cast on signed with Database::buildIntegerCast

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

There is Database::buildIntegerCast to differ between as integer/as signed

Change 692025 merged by jenkins-bot:

[mediawiki/extensions/ReplaceText@master] Fix mysql specifc cast on signed with Database::buildIntegerCast

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

Change 692076 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/extensions/ReplaceText@REL1_36] Fix mysql specifc cast on signed with Database::buildIntegerCast

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

Change 692077 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/extensions/ReplaceText@REL1_35] Fix mysql specifc cast on signed with Database::buildIntegerCast

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

Change 692076 merged by jenkins-bot:

[mediawiki/extensions/ReplaceText@REL1_36] Fix mysql specifc cast on signed with Database::buildIntegerCast

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

Change 692077 merged by jenkins-bot:

[mediawiki/extensions/ReplaceText@REL1_35] Fix mysql specifc cast on signed with Database::buildIntegerCast

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

Umherirrender claimed this task.

Fixed and backported to 1.35