Page MenuHomePhabricator

Numeric page titles can cause query page reports to stop updating
Open, Needs TriagePublic

Description

Several query pages such as ListRedirects and Lonely pages return the value of page_title as the "value" field. This is passed through intval by QueryCache::recache before it ends up in the database.

If the wiki is using MySQL database server and the database is set to use SQL strict mode (either via database config and empty wgSQLMode configuration option, or via explicit wgSQLMode option), an user can create a page with a numeric title that is larger than the maximum allowed value of unsigned integer. As a result, subsequent updateSpecialPages.php runs will fail with a database error - this will cause the query page to either not be updated, or to go empty.

Steps to Reproduce
On an MW install with MySQL (like mediawiki-vagrant):

  1. Set $wgSQLMode = 'STRICT_TRANS_TABLES'; in LocalSettings.php
  2. Create a redirect page titled 99999999999999999999999999999999999999999999999999999999999999999999999 or such
  3. Run updateSpecialPages.php - it will display error when regenerating ListRedirects:
Function: QueryPage::recache
Error: 1264 Out of range value for column 'qc_value' at row 1 (127.0.0.1)

Event Timeline

TK-999 created this task.Nov 29 2017, 5:40 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 29 2017, 5:40 PM
TK-999 updated the task description. (Show Details)Nov 29 2017, 5:44 PM
Reedy added a subscriber: Reedy.Nov 29 2017, 5:48 PM
-- Some sort of stored value. Sizes, counts...
qc_value int unsigned NOT NULL default 0,

I wonder what it's trying to put in it...

-- Some sort of stored value. Sizes, counts...
qc_value int unsigned NOT NULL default 0,

I wonder what it's trying to put in it...

Query pages such as MostLinkedCategories put an aggregate count value there, but other pages such as Listredirects pass page_title there, which is then passed through intval by QueryPage::recache. Interpreting page_title as integer does not really make much sense IMHO

Change 419441 had a related patch set uploaded (by TK-999; owner: TK-999):
[mediawiki/core@master] Do not insert page titles into querycache.qc_value

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

Still an issue with 1.33

Change 419441 had a related patch set uploaded (by TK-999; owner: TK-999):
[mediawiki/core@master] Do not insert page titles into querycache.qc_value

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

I've rebased the existing patchset, sorry about the undue delay incurred.

Change 419441 merged by jenkins-bot:
[mediawiki/core@master] Do not insert page titles into querycache.qc_value

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

Reedy added a comment.Nov 1 2019, 2:40 PM

Patch seems a worthy backport candidate :)

TK-999 added a comment.Nov 4 2019, 1:33 PM

@Reedy Makes sense, who would be the person to ask for approval? :)

Change 548311 had a related patch set uploaded (by Reedy; owner: TK-999):
[mediawiki/core@REL1_34] Do not insert page titles into querycache.qc_value

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

Change 548321 had a related patch set uploaded (by Reedy; owner: TK-999):
[mediawiki/core@REL1_33] Do not insert page titles into querycache.qc_value

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

Change 548325 had a related patch set uploaded (by Reedy; owner: TK-999):
[mediawiki/core@REL1_32] Do not insert page titles into querycache.qc_value

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

Change 548328 had a related patch set uploaded (by Reedy; owner: TK-999):
[mediawiki/core@REL1_31] Do not insert page titles into querycache.qc_value

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

Change 548328 merged by jenkins-bot:
[mediawiki/core@REL1_31] Do not insert page titles into querycache.qc_value

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

Change 548325 merged by jenkins-bot:
[mediawiki/core@REL1_32] Do not insert page titles into querycache.qc_value

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

Change 548311 merged by jenkins-bot:
[mediawiki/core@REL1_34] Do not insert page titles into querycache.qc_value

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

Change 548321 merged by jenkins-bot:
[mediawiki/core@REL1_33] Do not insert page titles into querycache.qc_value

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