Page MenuHomePhabricator

BetaFeatures: AutoEnrollmentTest produce a fatal error with OATHAuth extension
Closed, ResolvedPublic

Description

I have been running unit tests with master versions of core BetaFeatures and OATHAuth. I am given a fatal error:

$ /bin/ls -1 extensions
BetaFeatures
OATHAuth
$

$ php tests/phpunit/phpunit.php extensions/BetaFeatures
PHPUnit 3.7.30 by Sebastian Bergmann.

Configuration read from tests/phpunit/suite.xml

Fatal error: Call to a member function isEnabled() on a non-object in /extensions/OATHAuth/OATHAuth.hooks.php on line 126

Call Stack:

  1. {main}() /core/tests/phpunit/phpunit.php:0
  2. MediaWikiPHPUnitCommand::main() /core/tests/phpunit/phpunit.php:160
  3. PHPUnit_TextUI_Command->run() /core/tests/phpunit/MediaWikiPHPUnitCommand.php:42
  4. PHPUnit_TextUI_TestRunner->doRun() /pear/PHPUnit/TextUI/Command.php:176
  5. PHPUnit_Framework_TestSuite->run() /pear/PHPUnit/TextUI/TestRunner.php:349
  6. PHPUnit_Framework_TestSuite->run() /pear/PHPUnit/Framework/TestSuite.php:705
  7. PHPUnit_Framework_TestSuite->run() /pear/PHPUnit/Framework/TestSuite.php:705
  8. PHPUnit_Framework_TestSuite->runTest() /pear/PHPUnit/Framework/TestSuite.php:745
  9. MediaWikiTestCase->run() /pear/PHPUnit/Framework/TestSuite.php:775
  10. PHPUnit_Framework_TestCase->run() /core/tests/phpunit/MediaWikiTestCase.php:133
  11. PHPUnit_Framework_TestResult->run() /pear/PHPUnit/Framework/TestCase.php:783
  12. PHPUnit_Framework_TestCase->runBare() /pear/PHPUnit/Framework/TestResult.php:648
  13. PHPUnit_Framework_TestCase->runTest() /pear/PHPUnit/Framework/TestCase.php:838
  14. ReflectionMethod->invokeArgs() /pear/PHPUnit/Framework/TestCase.php:983
  15. AutoEnrollmentTest->testAutoEnroll() /pear/PHPUnit/Framework/TestCase.php:983
  16. wfRunHooks() /extensions/BetaFeatures/tests/AutoEnrollmentTest.php:146
  17. Hooks::run() /core/includes/GlobalFunctions.php:4056
  18. call_user_func_array:{/core/includes/Hooks.php:206}() /core/includes/Hooks.php:206
  19. OATHAuthHooks::manageOATH() /core/includes/Hooks.php:206

OATHAuthHooks::manageOATH() calls OATHUser::newFromUser() which returns NULL when $user->getID() is 0.

Thus:

if ( $oathUser->isEnabled() )

produces a fatal.

I have made two tiny useless patches, but would appreciate someone that knows PHP to look at it :)


Version: unspecified
Severity: normal

Details

Reference
bz67138

Event Timeline

bzimport raised the priority of this task from to High.
bzimport set Reference to bz67138.
bzimport added a subscriber: Unknown Object (MLST).
hashar created this task.Jun 26 2014, 3:26 PM

Change 142252 had a related patch set uploaded by Hashar:
Only manage logged users

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

Change 142251 had a related patch set uploaded by Hashar:
Run test with a logged in user

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

We really need tests to pass when all wmf extensions are installed together. That is preventing us from progression toward the HHVM migrating. Raising priority to High.

A similar issue happens with the OpenStackManager. Both extensions are registered the GetPreferences hook.

Change 143042 had a related patch set uploaded by Hashar:
Avoid extensions conflicts by hook GetPreferences

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

This is a false positive issue, because OATHAuth and BetaFeatures aren't enabled on the same wikis, but let's get this fixed.

I talked with James about comment #6. The idea is to run tests with all wmf extensions installed regardless of configuration settings made in mediawiki-config.

The patch https://gerrit.wikimedia.org/r/143042 fix my test case (stock wiki with extensions BetaFeatures OATHAuth and OpenStackManager). Was due to GetPreference hooks being invoked while extensions are not properly configured.

Change 142252 abandoned by Hashar:
Only manage logged users

Reason:
I got BetaFeatures tests fixed with https://gerrit.wikimedia.org/r/#/c/143042/ . So this lame change is probably no more needed.
Free free to reopen.

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

Change 143042 merged by jenkins-bot:
Avoid extensions conflicts by hook GetPreferences

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

hashar added a comment.Jul 2 2014, 8:49 AM

Works for me locally.

amusso@aeriale:/srv/trunk(masteru=)$ /bin/ls extensions/
APC BetaFeatures OATHAuth README link_ext.sh wmfexts
amusso@aeriale:/srv/trunk(masteru=)$ php tests/phpunit/phpunit.php extensions/BetaFeatures
PHPUnit 3.7.30 by Sebastian Bergmann.

Configuration read from /Users/amusso/projects/mediawiki/core/tests/phpunit/suite.xml

.........................

Time: 650 ms, Memory: 22.50Mb

OK (25 tests, 38 assertions)
amusso@aeriale:/srv/trunk(masteru=)$

The fatal is gone from the Jenkins job that runs tests of all extensions together https://integration.wikimedia.org/ci/job/mediawiki-core-extensions-integration/59/console

Thank you!

Change 142251 abandoned by Hashar:
Run test with a logged in user

Reason:
No more needed AFAIK :-D

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