Do not insert page titles into querycache.qc_value

querycache.qc_value column is used to store a numeric value related
to the query results, generally a COUNT(*) aggregation or timestamp,
but some query pages insert the page title here after passing it through
PHP's intval() function to parse it into a number.
While this will cause 0 to be inserted for pages whose title is not numeric
(i.e. most titles), a DB error may occur for numeric page titles that exceed
the maximum value for unsigned integers, depending on relevant DB settings,
such as MySQL's strict mode.[1]

This patch changes query pages not to insert page titles into the qc_value
column. Also, it adds the getOrderFields() method to query pages that were
missing them, to ensure that the result set inserted into the querycache
table is correctly ordered by title.

---
[1] https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sql-mode-strict

Bug: T181658
Change-Id: I1ef297257c6f419826ba4ffc6e875389ccec46db
This commit is contained in:
mszabo-wikia 2018-03-14 15:38:14 +01:00 committed by Máté Szabó
parent fbc745a1bf
commit 335fabf5fb
10 changed files with 25 additions and 15 deletions

View file

@ -64,7 +64,6 @@ class SpecialBrokenRedirects extends QueryPage {
'fields' => [
'namespace' => 'p1.page_namespace',
'title' => 'p1.page_title',
'value' => 'p1.page_title',
'rd_namespace',
'rd_title',
'rd_fragment',

View file

@ -65,7 +65,6 @@ class SpecialDoubleRedirects extends QueryPage {
'fields' => [
'namespace' => 'pa.page_namespace',
'title' => 'pa.page_title',
'value' => 'pa.page_title',
'b_namespace' => 'pb.page_namespace',
'b_title' => 'pb.page_title',

View file

@ -53,7 +53,6 @@ class SpecialListRedirects extends QueryPage {
'tables' => [ 'p1' => 'page', 'redirect', 'p2' => 'page' ],
'fields' => [ 'namespace' => 'p1.page_namespace',
'title' => 'p1.page_title',
'value' => 'p1.page_title',
'rd_namespace',
'rd_title',
'rd_fragment',

View file

@ -82,7 +82,6 @@ class SpecialLonelyPages extends PageQueryPage {
'fields' => [
'namespace' => 'page_namespace',
'title' => 'page_title',
'value' => 'page_title'
],
'conds' => $conds,
'join_conds' => $joinConds

View file

@ -46,17 +46,28 @@ class SpecialUncategorizedImages extends ImageQueryPage {
return false;
}
function getOrderFields() {
return [ 'title' ];
}
function getQueryInfo() {
return [
'tables' => [ 'page', 'categorylinks' ],
'fields' => [ 'namespace' => 'page_namespace',
'fields' => [
'namespace' => 'page_namespace',
'title' => 'page_title',
'value' => 'page_title' ],
'conds' => [ 'cl_from IS NULL',
],
'conds' => [
'cl_from IS NULL',
'page_namespace' => NS_FILE,
'page_is_redirect' => 0 ],
'join_conds' => [ 'categorylinks' => [
'LEFT JOIN', 'cl_from=page_id' ] ]
'page_is_redirect' => 0,
],
'join_conds' => [
'categorylinks' => [
'LEFT JOIN',
'cl_from=page_id',
],
],
];
}

View file

@ -56,7 +56,6 @@ class SpecialUncategorizedPages extends PageQueryPage {
'fields' => [
'namespace' => 'page_namespace',
'title' => 'page_title',
'value' => 'page_title'
],
// default for page_namespace is all content namespaces (if requestedNamespace is false)
// otherwise, page_namespace is requestedNamespace

View file

@ -37,13 +37,16 @@ class SpecialUnusedCategories extends QueryPage {
return $this->msg( 'unusedcategoriestext' )->parseAsBlock();
}
function getOrderFields() {
return [ 'title' ];
}
public function getQueryInfo() {
return [
'tables' => [ 'page', 'categorylinks', 'page_props' ],
'fields' => [
'namespace' => 'page_namespace',
'title' => 'page_title',
'value' => 'page_title'
],
'conds' => [
'cl_from IS NULL',

View file

@ -46,13 +46,16 @@ class SpecialUnusedTemplates extends QueryPage {
return false;
}
function getOrderFields() {
return [ 'title' ];
}
public function getQueryInfo() {
return [
'tables' => [ 'page', 'templatelinks' ],
'fields' => [
'namespace' => 'page_namespace',
'title' => 'page_title',
'value' => 'page_title'
],
'conds' => [
'page_namespace' => NS_TEMPLATE,

View file

@ -89,7 +89,6 @@ class SpecialWithoutInterwiki extends PageQueryPage {
'fields' => [
'namespace' => 'page_namespace',
'title' => 'page_title',
'value' => 'page_title'
],
'conds' => [
'll_title IS NULL',

View file

@ -21,7 +21,6 @@ class SpecialUncategorizedCategoriesTest extends MediaWikiTestCase {
'fields' => [
'namespace' => 'page_namespace',
'title' => 'page_title',
'value' => 'page_title',
],
'conds' => [
0 => 'cl_from IS NULL',