From: mszabo-wikia Date: Wed, 14 Mar 2018 14:38:14 +0000 (+0100) Subject: Do not insert page titles into querycache.qc_value X-Git-Tag: 1.34.0-rc.1~4 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=9c7f6734c397a954b8eaa5ec73876f2b4bf92afb;ds=inline 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 (cherry picked from commit 335fabf5fba49fa43c0e876996baa165a7ff4350) --- diff --git a/includes/specials/SpecialBrokenRedirects.php b/includes/specials/SpecialBrokenRedirects.php index 392b4e970d..9382b5f617 100644 --- a/includes/specials/SpecialBrokenRedirects.php +++ b/includes/specials/SpecialBrokenRedirects.php @@ -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', diff --git a/includes/specials/SpecialDoubleRedirects.php b/includes/specials/SpecialDoubleRedirects.php index 540ac5aaef..d0d832246e 100644 --- a/includes/specials/SpecialDoubleRedirects.php +++ b/includes/specials/SpecialDoubleRedirects.php @@ -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', diff --git a/includes/specials/SpecialListRedirects.php b/includes/specials/SpecialListRedirects.php index e6862733f1..e73c87176f 100644 --- a/includes/specials/SpecialListRedirects.php +++ b/includes/specials/SpecialListRedirects.php @@ -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', diff --git a/includes/specials/SpecialLonelyPages.php b/includes/specials/SpecialLonelyPages.php index 14f9435f3a..d1c83af38e 100644 --- a/includes/specials/SpecialLonelyPages.php +++ b/includes/specials/SpecialLonelyPages.php @@ -82,7 +82,6 @@ class SpecialLonelyPages extends PageQueryPage { 'fields' => [ 'namespace' => 'page_namespace', 'title' => 'page_title', - 'value' => 'page_title' ], 'conds' => $conds, 'join_conds' => $joinConds diff --git a/includes/specials/SpecialUncategorizedImages.php b/includes/specials/SpecialUncategorizedImages.php index 9dcd1bdd35..67a2edb4ab 100644 --- a/includes/specials/SpecialUncategorizedImages.php +++ b/includes/specials/SpecialUncategorizedImages.php @@ -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', + ], + ], ]; } diff --git a/includes/specials/SpecialUncategorizedPages.php b/includes/specials/SpecialUncategorizedPages.php index 3610c011e7..2ec020afd9 100644 --- a/includes/specials/SpecialUncategorizedPages.php +++ b/includes/specials/SpecialUncategorizedPages.php @@ -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 diff --git a/includes/specials/SpecialUnusedCategories.php b/includes/specials/SpecialUnusedCategories.php index 36367d2f27..f8c9360acf 100644 --- a/includes/specials/SpecialUnusedCategories.php +++ b/includes/specials/SpecialUnusedCategories.php @@ -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', diff --git a/includes/specials/SpecialUnusedTemplates.php b/includes/specials/SpecialUnusedTemplates.php index 119ef875a9..89468d296c 100644 --- a/includes/specials/SpecialUnusedTemplates.php +++ b/includes/specials/SpecialUnusedTemplates.php @@ -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, diff --git a/includes/specials/SpecialWithoutInterwiki.php b/includes/specials/SpecialWithoutInterwiki.php index 36aea75b96..3ab0ef97f1 100644 --- a/includes/specials/SpecialWithoutInterwiki.php +++ b/includes/specials/SpecialWithoutInterwiki.php @@ -89,7 +89,6 @@ class SpecialWithoutInterwiki extends PageQueryPage { 'fields' => [ 'namespace' => 'page_namespace', 'title' => 'page_title', - 'value' => 'page_title' ], 'conds' => [ 'll_title IS NULL', diff --git a/tests/phpunit/includes/specials/SpecialUncategorizedCategoriesTest.php b/tests/phpunit/includes/specials/SpecialUncategorizedCategoriesTest.php index daccd274a9..d151f596f0 100644 --- a/tests/phpunit/includes/specials/SpecialUncategorizedCategoriesTest.php +++ b/tests/phpunit/includes/specials/SpecialUncategorizedCategoriesTest.php @@ -21,7 +21,6 @@ class SpecialUncategorizedCategoriesTest extends MediaWikiTestCase { 'fields' => [ 'namespace' => 'page_namespace', 'title' => 'page_title', - 'value' => 'page_title', ], 'conds' => [ 0 => 'cl_from IS NULL',