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.31.6~17 X-Git-Url: http://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=4d8248ff97278627902974bd1726c6a3c0a70f50 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 --- diff --git a/includes/specials/SpecialBrokenRedirects.php b/includes/specials/SpecialBrokenRedirects.php index 3e1909b836..25571ccd5f 100644 --- a/includes/specials/SpecialBrokenRedirects.php +++ b/includes/specials/SpecialBrokenRedirects.php @@ -63,7 +63,6 @@ class BrokenRedirectsPage 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 77c59f0387..8bfc4a9d1d 100644 --- a/includes/specials/SpecialDoubleRedirects.php +++ b/includes/specials/SpecialDoubleRedirects.php @@ -64,7 +64,6 @@ class DoubleRedirectsPage 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 48f364027e..d58097cc99 100644 --- a/includes/specials/SpecialListredirects.php +++ b/includes/specials/SpecialListredirects.php @@ -53,7 +53,6 @@ class ListredirectsPage 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 ff76a4b47d..a38752474d 100644 --- a/includes/specials/SpecialLonelypages.php +++ b/includes/specials/SpecialLonelypages.php @@ -79,7 +79,6 @@ class LonelyPagesPage 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 1cb27a3fc6..7e8938975a 100644 --- a/includes/specials/SpecialUncategorizedimages.php +++ b/includes/specials/SpecialUncategorizedimages.php @@ -45,17 +45,28 @@ class UncategorizedImagesPage 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 30b33cc697..d616f70964 100644 --- a/includes/specials/SpecialUncategorizedpages.php +++ b/includes/specials/SpecialUncategorizedpages.php @@ -52,7 +52,6 @@ class UncategorizedPagesPage 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 1469742a4b..429a3b03bb 100644 --- a/includes/specials/SpecialUnusedcategories.php +++ b/includes/specials/SpecialUnusedcategories.php @@ -37,13 +37,16 @@ class UnusedCategoriesPage extends QueryPage { return $this->msg( 'unusedcategoriestext' )->parseAsBlock(); } + function getOrderFields() { + return [ 'title' ]; + } + public function getQueryInfo() { return [ 'tables' => [ 'page', 'categorylinks' ], '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 f73be43839..1ac5e7f4d2 100644 --- a/includes/specials/SpecialUnusedtemplates.php +++ b/includes/specials/SpecialUnusedtemplates.php @@ -46,13 +46,16 @@ class UnusedtemplatesPage 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 a1e5156397..45dd5f5b37 100644 --- a/includes/specials/SpecialWithoutinterwiki.php +++ b/includes/specials/SpecialWithoutinterwiki.php @@ -87,7 +87,6 @@ class WithoutInterwikiPage 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 80bd365f35..fb49e851ee 100644 --- a/tests/phpunit/includes/specials/SpecialUncategorizedcategoriesTest.php +++ b/tests/phpunit/includes/specials/SpecialUncategorizedcategoriesTest.php @@ -21,7 +21,6 @@ class UncategorizedCategoriesPageTest extends MediaWikiTestCase { 'fields' => [ 'namespace' => 'page_namespace', 'title' => 'page_title', - 'value' => 'page_title', ], 'conds' => [ 0 => 'cl_from IS NULL',