Last modified: 2014-10-19 17:47:08 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T70231, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 68231 - wfWikiID() returns different values from test and data provider
wfWikiID() returns different values from test and data provider
Status: NEW
Product: MediaWiki
Classification: Unclassified
Unit tests (Other open bugs)
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: 68650 (view as bug list)
Depends on:
Blocks: 67216
  Show dependency treegraph
Reported: 2014-07-18 19:25 UTC by Bryan Davis
Modified: 2014-10-19 17:47 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description Bryan Davis 2014-07-18 19:25:44 UTC
This fails when running a test that extends CentralAuthTestCaseUsingDatabase:

     * @dataProvider provideWfWikiID
    public function testWfWikiID($expect) {
        $this->assertSame( $expect, wfWikiID() );

    public function provideWfWikiID() {
        return array(
            array( wfWikiID() ),

    CentralAuthPluginUsingDatabaseTest::testWfWikiID with data set #0 ('wiki')
    Failed asserting that two strings are identical.
    --- Expected
    +++ Actual
    @@ @@

I tried to use $this->dbPrefix() inside the provider to kludge the right value and got a failure with this stacktrace which might help figure out where we could initialize $wgDBprefix to get consistent behavior:

Fatal error: Call to a member function getType() on a non-object in /vagrant/mediawiki/tests/phpunit/MediaWikiTestCase.php on line 400

Call Stack:
    0.0008     253704   1. {main}() /vagrant/mediawiki/tests/phpunit/phpunit.php:0
    0.2053    8666952   2. MediaWikiPHPUnitCommand::main() /vagrant/mediawiki/tests/phpunit/phpunit.php:160
    0.2053    8680808   3. PHPUnit_TextUI_Command->run() /vagrant/mediawiki/tests/phpunit/MediaWikiPHPUnitCommand.php:42
    0.2263    9419016   4. PHPUnit_Runner_BaseTestRunner->getTest() /vagrant/mediawiki/vendor/phpunit/phpunit/src/TextUI/Command.php:153
    0.2502   11030928   5. PHPUnit_Framework_TestSuite->__construct() /vagrant/mediawiki/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php:138
    0.2587   11389784   6. PHPUnit_Framework_TestSuite->addTestMethod() /vagrant/mediawiki/vendor/phpunit/phpunit/src/Framework/TestSuite.php:219
    0.2588   11390232   7. PHPUnit_Framework_TestSuite::createTest() /vagrant/mediawiki/vendor/phpunit/phpunit/src/Framework/TestSuite.php:800
    0.2590   11394056   8. PHPUnit_Util_Test::getProvidedData() /vagrant/mediawiki/vendor/phpunit/phpunit/src/Framework/TestSuite.php:472
    0.2591   11398136   9. ReflectionMethod->invoke() /vagrant/mediawiki/vendor/phpunit/phpunit/src/Util/Test.php:377
    0.2591   11398208  10. CentralAuthPluginUsingDatabaseTest->provideAuthenticateWithPreRenameUsername() /vagrant/mediawiki/vendor/phpunit/phpunit/src/Util/Test.php:377
    0.2592   11398320  11. MediaWikiTestCase->dbPrefix() /vagrant/mediawiki/extensions/CentralAuth/tests/CentralAuthPluginUsingDatabaseTest.php:205
Comment 1 Antoine "hashar" Musso (WMF) 2014-07-28 09:53:22 UTC
*** Bug 68650 has been marked as a duplicate of this bug. ***
Comment 2 Antoine "hashar" Musso (WMF) 2014-07-28 09:54:47 UTC
bug 68650 logged the same issue with ProofreadPage\FileProviderTest::testGetForIndexPage and ProofreadPage\FileProviderTest::testGetForPagePage
Comment 3 Antoine "hashar" Musso (WMF) 2014-07-29 09:32:24 UTC
Thanks for filling this bug.  I have noticed that when running the PHPUnit test suite with the wmf deployed extensions (bug 67216).

An example run is:

CentralAuth is not used in that job because of an unrelated issue (it has a central database).  But ProofreadPage (was bug 68650) definitely does.
Comment 4 Gerrit Notification Bot 2014-07-29 09:44:36 UTC
Change 150169 had a related patch set uploaded by Hashar:
test: coverage for wfWikiID()
Comment 5 Antoine "hashar" Musso (WMF) 2014-07-29 09:50:13 UTC
About the stacktrace: PHPUnit providers are static functions which are evaluated before the test run.  So you can not rely on the object state (i.e. $this->dbprefix does not exist).
Comment 6 Gerrit Notification Bot 2014-07-29 15:11:10 UTC
Change 150169 merged by jenkins-bot:
test: coverage for wfWikiID()
Comment 7 Bryan Davis 2014-07-29 15:44:39 UTC
I have a work around for the particular test where I encountered this problem originally:,unified

Note You need to log in before you can comment on or make changes to this bug.