Page MenuHomePhabricator

PhpTagsWiki parser tests broken because !!article sections do not save categorylinks / page count anymore
Closed, ResolvedPublic

Description

When running PhpTagsWiki parser tests, the two that rely on counting files and sub categories of a category are failing.

1) ParserIntegrationTest::testParse with data set "PhpTagsWikiTests.txt: WCategory->pageCount Test pages" ('[details omitted]')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<p>4
+'<p>0
 </p>'

2) ParserIntegrationTest::testParse with data set "PhpTagsWikiTests.txt: WCategory->subcatCount" ('[details omitted]')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<p>1
+'<p>0
 </p>'

They fail because Category:refreshCounts() ends up inserting a count of zero regardless of content in categorylinks.

The parser test file creates a few articles with [[Category:Test pages]] and then assert that the category has 4 pages. Example:

!! article
Other page
!! text
[[Category:Test pages]]
!! endarticle

!! test
WCategory->pageCount Test pages
!! input
<phptag>
$c = new WCategory( 'Test pages' );
echo $c->pageCount;
</phptag>
!! result
<p>4
</p>
!! end

I did a git bisect against mediawiki/core with:

composer install ; php tests/phpunit/phpunit.php --testsuite extensions --filter ParserIntegrationTest::testParse.*ount --debug-tests

That yields 65b732f295687f0d2f2f37361494c3136c70481d as the culprit.

commit 65b732f295687f0d2f2f37361494c3136c70481d
Author: Tim Starling <tstarling@wikimedia.org>
Date:   Thu Oct 6 16:41:15 2016 +1100

    parserTests: Use a mock parser during article insertion
    
    This makes debugging simpler by avoiding log noise, hitting breakpoints
    unexpectedly, etc. This means that {{subst:}} is no longer supported in
    !!article sections, but I could only find one test which relied on that.
    
    Change-Id: I6400defa389389e5d9632fb01d4a534c0d88d442

Seems that commit is something we want to keep. Note it also broke Disambiguator parser tests T159014

Event Timeline

hashar created this task.Apr 24 2017, 7:42 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 24 2017, 7:42 PM

Change 350015 had a related patch set uploaded (by Hashar):
[mediawiki/extensions/PhpTagsWiki@master] Disable parser tests for categories count

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

Change 350015 merged by jenkins-bot:
[mediawiki/extensions/PhpTagsWiki@master] Disable parser tests for categories count

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

hashar triaged this task as Medium priority.Jun 16 2017, 11:08 AM

Change 448408 had a related patch set uploaded (by Hashar; owner: Hashar):
[mediawiki/extensions/PhpTagsWiki@master] Revert "Disable parser tests for categories count"

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

hashar closed this task as Resolved.Jul 27 2018, 8:16 AM
hashar assigned this task to tstarling.

Fixed by @tstarling in MediaWiki by:

Change 447013 had a related patch set uploaded (by Tim Starling; owner: Tim Starling):
[mediawiki/core@master] parserTests: re-enable save parse and fix MCR errors

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

Change 448408 merged by Hashar:
[mediawiki/extensions/PhpTagsWiki@master] Revert "Disable parser tests for categories count"

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