Page MenuHomePhabricator

Numeric page titles can cause query page reports to stop updating
Closed, ResolvedPublic

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

-- 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

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

Patch seems a worthy backport candidate :)

@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

Change 675120 had a related patch set uploaded (by TK-999; author: TK-999):
[mediawiki/core@master] Follow-up I1ef297: Don't misuse qc_value in DeadendPages

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

Change 675120 merged by jenkins-bot:

[mediawiki/core@master] Follow-up 335fabf5f: Don't misuse qc_value in DeadendPages

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