From: James D. Forrester Date: Wed, 28 Feb 2018 01:45:27 +0000 (-0800) Subject: Drop 'comma' value for wgArticleCountMethod X-Git-Tag: 1.31.0-rc.0~455^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=326d655fc9309f55112538b387ed8c201158a27d Drop 'comma' value for wgArticleCountMethod We have three methods for page counting currently supported for wikitext non-redirect pages; 'any' counts any page that exists, 'link' counts any page that has any outbound links, and 'comma' which searches for any ',' in the text having loaded it. This last option is much slower than these other two, and is only used on a very small number of installations. Now by dropping support for this method we can simplify this code and so run it more often. Note that non-wikitext pages already did not support this count method. Installations with this setting set to 'comma', or any other string will now work as if it was configured with 'any'. Bug: T188472 Change-Id: I965927edcd2485ec4b49b2d80fdf216dbf19520b --- diff --git a/RELEASE-NOTES-1.31 b/RELEASE-NOTES-1.31 index 8113314a2a..336fa59f5e 100644 --- a/RELEASE-NOTES-1.31 +++ b/RELEASE-NOTES-1.31 @@ -28,6 +28,9 @@ production. as upstream is inactive and has no plans to move to PHP 7. * The old CategorizedRecentChanges feature, including its related configuration option $wgAllowCategorizedRecentChanges, has been removed. +* (T188472) The 'comma' value for $wgArticleCountMethod is no longer supported for + performance reasons, and installations with this setting will now work as if it + was configured with 'any'. === New features in 1.31 === * Wikimedia\Rdbms\IDatabase->select() and similar methods now support diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 33418d839c..e4da637dcb 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4438,7 +4438,6 @@ $wgEnableMagicLinks = [ * * This variable can have the following values: * - 'any': all pages as considered as valid articles - * - 'comma': the page must contain a comma to be considered valid * - 'link': the page must contain a [[wiki link]] to be considered valid * * See also See https://www.mediawiki.org/wiki/Manual:Article_count diff --git a/includes/SiteStatsInit.php b/includes/SiteStatsInit.php index f527cb226b..8adb2181ea 100644 --- a/includes/SiteStatsInit.php +++ b/includes/SiteStatsInit.php @@ -79,13 +79,6 @@ class SiteStatsInit { if ( $config->get( 'ArticleCountMethod' ) == 'link' ) { $tables[] = 'pagelinks'; $conds[] = 'pl_from=page_id'; - } elseif ( $config->get( 'ArticleCountMethod' ) == 'comma' ) { - // To make a correct check for this, we would need, for each page, - // to load the text, maybe uncompress it, maybe decode it and then - // check if there's one comma. - // But one thing we are sure is that if the page is empty, it can't - // contain a comma :) - $conds[] = 'page_len > 0'; } $this->articles = $this->dbr->selectField( diff --git a/includes/content/WikitextContent.php b/includes/content/WikitextContent.php index bc20aa0020..5beef31b8c 100644 --- a/includes/content/WikitextContent.php +++ b/includes/content/WikitextContent.php @@ -270,28 +270,22 @@ class WikitextContent extends TextContent { return false; } - switch ( $wgArticleCountMethod ) { - case 'any': - return true; - case 'comma': - $text = $this->getNativeData(); - return strpos( $text, ',' ) !== false; - case 'link': - if ( $hasLinks === null ) { # not known, find out - if ( !$title ) { - $context = RequestContext::getMain(); - $title = $context->getTitle(); - } - - $po = $this->getParserOutput( $title, null, null, false ); - $links = $po->getLinks(); - $hasLinks = !empty( $links ); + if ( $wgArticleCountMethod === 'link' ) { + if ( $hasLinks === null ) { # not known, find out + if ( !$title ) { + $context = RequestContext::getMain(); + $title = $context->getTitle(); } - return $hasLinks; + $po = $this->getParserOutput( $title, null, null, false ); + $links = $po->getLinks(); + $hasLinks = !empty( $links ); + } + + return $hasLinks; } - return false; + return true; } /** diff --git a/tests/phpunit/includes/content/JavaScriptContentTest.php b/tests/phpunit/includes/content/JavaScriptContentTest.php index 6656fa4d76..823be6f795 100644 --- a/tests/phpunit/includes/content/JavaScriptContentTest.php +++ b/tests/phpunit/includes/content/JavaScriptContentTest.php @@ -153,16 +153,6 @@ class JavaScriptContentTest extends TextContentTest { 'any', true ], - [ 'Foo', - null, - 'comma', - false - ], - [ 'Foo, bar', - null, - 'comma', - false - ], [ 'Foo', null, 'link', @@ -188,11 +178,6 @@ class JavaScriptContentTest extends TextContentTest { 'any', true ], - [ '#REDIRECT [[bar]]', - true, - 'comma', - false - ], [ '#REDIRECT [[bar]]', true, 'link', diff --git a/tests/phpunit/includes/content/TextContentTest.php b/tests/phpunit/includes/content/TextContentTest.php index b5480911df..406bc96b95 100644 --- a/tests/phpunit/includes/content/TextContentTest.php +++ b/tests/phpunit/includes/content/TextContentTest.php @@ -197,16 +197,6 @@ class TextContentTest extends MediaWikiLangTestCase { 'any', true ], - [ 'Foo', - null, - 'comma', - false - ], - [ 'Foo, bar', - null, - 'comma', - false - ], ]; } diff --git a/tests/phpunit/includes/content/WikitextContentTest.php b/tests/phpunit/includes/content/WikitextContentTest.php index e04f562429..1db6aab618 100644 --- a/tests/phpunit/includes/content/WikitextContentTest.php +++ b/tests/phpunit/includes/content/WikitextContentTest.php @@ -266,16 +266,6 @@ just a test" 'any', true ], - [ 'Foo', - null, - 'comma', - false - ], - [ 'Foo, bar', - null, - 'comma', - true - ], [ 'Foo', null, 'link', @@ -301,11 +291,6 @@ just a test" 'any', false ], - [ '#REDIRECT [[bar]]', - true, - 'comma', - false - ], [ '#REDIRECT [[bar]]', true, 'link', diff --git a/tests/phpunit/includes/page/WikiPageDbTestBase.php b/tests/phpunit/includes/page/WikiPageDbTestBase.php index 7adc43b739..6367a0f8ef 100644 --- a/tests/phpunit/includes/page/WikiPageDbTestBase.php +++ b/tests/phpunit/includes/page/WikiPageDbTestBase.php @@ -374,20 +374,6 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase { true ], - // comma - [ 'WikiPageTest_testIsCountable', - CONTENT_MODEL_WIKITEXT, - 'Foo', - 'comma', - false - ], - [ 'WikiPageTest_testIsCountable', - CONTENT_MODEL_WIKITEXT, - 'Foo, bar', - 'comma', - true - ], - // link [ 'WikiPageTest_testIsCountable', CONTENT_MODEL_WIKITEXT, @@ -409,12 +395,6 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase { 'any', false ], - [ 'WikiPageTest_testIsCountable', - CONTENT_MODEL_WIKITEXT, - '#REDIRECT [[bar]]', - 'comma', - false - ], [ 'WikiPageTest_testIsCountable', CONTENT_MODEL_WIKITEXT, '#REDIRECT [[bar]]', @@ -429,12 +409,6 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase { 'any', false ], - [ 'Talk:WikiPageTest_testIsCountable', - CONTENT_MODEL_WIKITEXT, - 'Foo, bar', - 'comma', - false - ], [ 'Talk:WikiPageTest_testIsCountable', CONTENT_MODEL_WIKITEXT, 'Foo [[bar]]', @@ -449,12 +423,6 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase { 'any', false ], - [ 'MediaWiki:WikiPageTest_testIsCountable.js', - null, - 'Foo, bar', - 'comma', - false - ], [ 'MediaWiki:WikiPageTest_testIsCountable.js', null, 'Foo [[bar]]', diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js index 1db8c61d49..23ef26f6f6 100644 --- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js @@ -130,7 +130,7 @@ [ '$ 1.50' ], [ '$ 3.00' ], [ '$3.50' ], - // Comma's sort after dots + // Commas sort after dots // Not intentional but test to detect changes [ '€ 2,99' ] ],