From 61adc1e146dbfc782af0a3fcc9ead094d1513706 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 11 Oct 2016 22:36:03 -0700 Subject: [PATCH] Use namespaced ScopedCallback The un-namespaced \ScopedCallback is deprecated. Change-Id: Ie014d5a775ead66335a24acac9d339915884d1a4 --- includes/EditPage.php | 1 + includes/api/ApiStashEdit.php | 1 + includes/auth/AuthManager.php | 2 +- includes/cache/MessageCache.php | 1 + includes/context/RequestContext.php | 1 + includes/deferred/LinksDeletionUpdate.php | 1 + includes/deferred/LinksUpdate.php | 1 + includes/jobqueue/JobQueueDB.php | 1 + includes/jobqueue/JobRunner.php | 1 + .../jobqueue/jobs/AssembleUploadChunksJob.php | 1 + .../jobqueue/jobs/PublishStashedFileJob.php | 1 + includes/libs/filebackend/FileBackend.php | 1 + includes/libs/objectcache/BagOStuff.php | 1 + includes/libs/rdbms/database/Database.php | 1 + includes/libs/rdbms/database/IDatabase.php | 1 + includes/libs/rdbms/lbfactory/LBFactory.php | 1 + .../libs/rdbms/loadbalancer/LoadBalancer.php | 1 + includes/libs/rdbms/loadmonitor/LoadMonitor.php | 1 + includes/libs/xmp/XMP.php | 1 + includes/media/SVG.php | 1 + includes/parser/Parser.php | 5 +++++ includes/parser/ParserOptions.php | 1 + includes/profiler/Profiler.php | 1 + .../resourceloader/ResourceLoaderModule.php | 1 + includes/session/Session.php | 2 +- includes/session/SessionBackend.php | 6 +++--- includes/session/SessionManager.php | 2 +- includes/user/User.php | 1 + tests/parser/ParserTestRunner.php | 3 ++- tests/parser/fuzzTest.php | 2 ++ .../includes/WatchedItemStoreUnitTest.php | 1 + tests/phpunit/includes/auth/AuthManagerTest.php | 17 +++++++++-------- ...locksSecondaryAuthenticationProviderTest.php | 2 +- ...asswordPrimaryAuthenticationProviderTest.php | 12 +++++++----- .../includes/changes/RecentChangeTest.php | 1 + .../includes/page/WikiCategoryPageTest.php | 2 ++ .../includes/parser/ParserIntegrationTest.php | 1 + .../includes/session/PHPSessionHandlerTest.php | 10 +++++----- .../includes/session/SessionBackendTest.php | 14 +++++++------- .../includes/session/SessionManagerTest.php | 2 +- tests/phpunit/includes/session/TestUtils.php | 2 +- .../specialpage/SpecialPageFactoryTest.php | 2 ++ tests/phpunit/includes/user/BotPasswordTest.php | 1 + .../phpunit/suites/ParserTestTopLevelSuite.php | 1 + 44 files changed, 78 insertions(+), 35 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 0d8def3486..770a74ec00 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -22,6 +22,7 @@ use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; +use Wikimedia\ScopedCallback; /** * The edit page/HTML interface (split from Article) diff --git a/includes/api/ApiStashEdit.php b/includes/api/ApiStashEdit.php index 5a2492de3a..92cbe9053a 100644 --- a/includes/api/ApiStashEdit.php +++ b/includes/api/ApiStashEdit.php @@ -21,6 +21,7 @@ use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; +use Wikimedia\ScopedCallback; /** * Prepare an edit in shared cache so that it can be reused on edit diff --git a/includes/auth/AuthManager.php b/includes/auth/AuthManager.php index eeb233e465..d88a5b27e2 100644 --- a/includes/auth/AuthManager.php +++ b/includes/auth/AuthManager.php @@ -2382,7 +2382,7 @@ class AuthManager implements LoggerAwareInterface { $session->set( 'AuthManager:lastAuthTimestamp', time() ); $session->persist(); - \ScopedCallback::consume( $delay ); + \Wikimedia\ScopedCallback::consume( $delay ); \Hooks::run( 'UserLoggedIn', [ $user ] ); } diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index 6834ac0981..48a13c5eaf 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -21,6 +21,7 @@ * @ingroup Cache */ use MediaWiki\MediaWikiServices; +use Wikimedia\ScopedCallback; /** * MediaWiki message cache structure version. diff --git a/includes/context/RequestContext.php b/includes/context/RequestContext.php index a8cad9f3bc..ebedb7e518 100644 --- a/includes/context/RequestContext.php +++ b/includes/context/RequestContext.php @@ -25,6 +25,7 @@ use Liuggio\StatsdClient\Factory\StatsdDataFactory; use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; +use Wikimedia\ScopedCallback; /** * Group all the pieces relevant to the context of a request into one instance diff --git a/includes/deferred/LinksDeletionUpdate.php b/includes/deferred/LinksDeletionUpdate.php index 93b3ef6526..6aa3831fb3 100644 --- a/includes/deferred/LinksDeletionUpdate.php +++ b/includes/deferred/LinksDeletionUpdate.php @@ -20,6 +20,7 @@ * @file */ use MediaWiki\MediaWikiServices; +use Wikimedia\ScopedCallback; /** * Update object handling the cleanup of links tables after a page was deleted. diff --git a/includes/deferred/LinksUpdate.php b/includes/deferred/LinksUpdate.php index 895430414d..c7d378e926 100644 --- a/includes/deferred/LinksUpdate.php +++ b/includes/deferred/LinksUpdate.php @@ -21,6 +21,7 @@ */ use MediaWiki\MediaWikiServices; +use Wikimedia\ScopedCallback; /** * Class the manages updates of *_link tables as well as similar extension-managed tables diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php index 856cdfd61e..aa017688d4 100644 --- a/includes/jobqueue/JobQueueDB.php +++ b/includes/jobqueue/JobQueueDB.php @@ -21,6 +21,7 @@ * @author Aaron Schulz */ use MediaWiki\MediaWikiServices; +use Wikimedia\ScopedCallback; /** * Class to handle job queues stored in the DB diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index 84ded8d94e..0469eebc66 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -26,6 +26,7 @@ use MediaWiki\Logger\LoggerFactory; use Liuggio\StatsdClient\Factory\StatsdDataFactory; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; +use Wikimedia\ScopedCallback; /** * Job queue runner utility methods diff --git a/includes/jobqueue/jobs/AssembleUploadChunksJob.php b/includes/jobqueue/jobs/AssembleUploadChunksJob.php index 060cabb627..e2914be5e4 100644 --- a/includes/jobqueue/jobs/AssembleUploadChunksJob.php +++ b/includes/jobqueue/jobs/AssembleUploadChunksJob.php @@ -20,6 +20,7 @@ * @file * @ingroup Upload */ +use Wikimedia\ScopedCallback; /** * Assemble the segments of a chunked upload. diff --git a/includes/jobqueue/jobs/PublishStashedFileJob.php b/includes/jobqueue/jobs/PublishStashedFileJob.php index 78531dca52..37e80c24ce 100644 --- a/includes/jobqueue/jobs/PublishStashedFileJob.php +++ b/includes/jobqueue/jobs/PublishStashedFileJob.php @@ -21,6 +21,7 @@ * @ingroup Upload * @ingroup JobQueue */ +use Wikimedia\ScopedCallback; /** * Upload a file from the upload stash into the local file repo. diff --git a/includes/libs/filebackend/FileBackend.php b/includes/libs/filebackend/FileBackend.php index f33f52265b..5764cc3397 100644 --- a/includes/libs/filebackend/FileBackend.php +++ b/includes/libs/filebackend/FileBackend.php @@ -30,6 +30,7 @@ */ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; +use Wikimedia\ScopedCallback; /** * @brief Base class for all file backend classes (including multi-write backends). diff --git a/includes/libs/objectcache/BagOStuff.php b/includes/libs/objectcache/BagOStuff.php index d3deefb6fd..d0b68bcbd7 100644 --- a/includes/libs/objectcache/BagOStuff.php +++ b/includes/libs/objectcache/BagOStuff.php @@ -29,6 +29,7 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; +use Wikimedia\ScopedCallback; use Wikimedia\WaitConditionLoop; /** diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index a5a170ba06..a3544f194f 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -25,6 +25,7 @@ */ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; +use Wikimedia\ScopedCallback; /** * Relational database abstraction object diff --git a/includes/libs/rdbms/database/IDatabase.php b/includes/libs/rdbms/database/IDatabase.php index c32a7ff561..952a2d629a 100644 --- a/includes/libs/rdbms/database/IDatabase.php +++ b/includes/libs/rdbms/database/IDatabase.php @@ -23,6 +23,7 @@ * @file * @ingroup Database */ +use Wikimedia\ScopedCallback; /** * Basic database interface for live and lazy-loaded relation database handles diff --git a/includes/libs/rdbms/lbfactory/LBFactory.php b/includes/libs/rdbms/lbfactory/LBFactory.php index 929bd4d4f1..5b35d6b8e7 100644 --- a/includes/libs/rdbms/lbfactory/LBFactory.php +++ b/includes/libs/rdbms/lbfactory/LBFactory.php @@ -22,6 +22,7 @@ */ use Psr\Log\LoggerInterface; +use Wikimedia\ScopedCallback; /** * An interface for generating database load balancers diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index 32df19dcd7..b1c212ec32 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -21,6 +21,7 @@ * @ingroup Database */ use Psr\Log\LoggerInterface; +use Wikimedia\ScopedCallback; /** * Database connection, tracking, load balancing, and transaction manager for a cluster diff --git a/includes/libs/rdbms/loadmonitor/LoadMonitor.php b/includes/libs/rdbms/loadmonitor/LoadMonitor.php index 99c9126318..da4909d77f 100644 --- a/includes/libs/rdbms/loadmonitor/LoadMonitor.php +++ b/includes/libs/rdbms/loadmonitor/LoadMonitor.php @@ -20,6 +20,7 @@ */ use Psr\Log\LoggerInterface; +use Wikimedia\ScopedCallback; /** * Basic DB load monitor with no external dependencies diff --git a/includes/libs/xmp/XMP.php b/includes/libs/xmp/XMP.php index 70f67b7858..29bbf4055b 100644 --- a/includes/libs/xmp/XMP.php +++ b/includes/libs/xmp/XMP.php @@ -24,6 +24,7 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; +use Wikimedia\ScopedCallback; /** * Class for reading xmp data containing properties relevant to diff --git a/includes/media/SVG.php b/includes/media/SVG.php index 8360920456..f3b33ace35 100644 --- a/includes/media/SVG.php +++ b/includes/media/SVG.php @@ -20,6 +20,7 @@ * @file * @ingroup Media */ +use Wikimedia\ScopedCallback; /** * Handler for SVG images. diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index f0898bad51..2c152359cd 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -22,6 +22,7 @@ */ use MediaWiki\Linker\LinkRenderer; use MediaWiki\MediaWikiServices; +use Wikimedia\ScopedCallback; /** * @defgroup Parser Parser @@ -1445,6 +1446,7 @@ class Parser { $keyword = 'RFC'; $urlmsg = 'rfcurl'; $cssClass = 'mw-magiclink-rfc'; + $trackingCategory = 'magiclinks-rfc-category'; $id = $m[5]; } elseif ( substr( $m[0], 0, 4 ) === 'PMID' ) { if ( !$this->mOptions->getMagicPMIDLinks() ) { @@ -1453,12 +1455,14 @@ class Parser { $keyword = 'PMID'; $urlmsg = 'pubmedurl'; $cssClass = 'mw-magiclink-pmid'; + $trackingCategory = 'magiclinks-pmid-category'; $id = $m[5]; } else { throw new MWException( __METHOD__ . ': unrecognised match type "' . substr( $m[0], 0, 20 ) . '"' ); } $url = wfMessage( $urlmsg, $id )->inContentLanguage()->text(); + $this->addTrackingCategory( $trackingCategory ); return Linker::makeExternalLink( $url, "{$keyword} {$id}", true, $cssClass, [], $this->mTitle ); } elseif ( isset( $m[6] ) && $m[6] !== '' && $this->mOptions->getMagicISBNLinks() @@ -1472,6 +1476,7 @@ class Parser { ' ' => '', 'x' => 'X', ] ); + $this->addTrackingCategory( 'magiclinks-isbn-category' ); return $this->getLinkRenderer()->makeKnownLink( SpecialPage::getTitleFor( 'Booksources', $num ), "ISBN $isbn", diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 25c2aa45bc..9a1087886e 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -20,6 +20,7 @@ * @file * @ingroup Parser */ +use Wikimedia\ScopedCallback; /** * @brief Set options of the Parser diff --git a/includes/profiler/Profiler.php b/includes/profiler/Profiler.php index db9c95b195..8b4f01a306 100644 --- a/includes/profiler/Profiler.php +++ b/includes/profiler/Profiler.php @@ -21,6 +21,7 @@ * @ingroup Profiler * @defgroup Profiler Profiler */ +use Wikimedia\ScopedCallback; /** * Profiler base class that defines the interface and some trivial diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index 3e94460529..796c575885 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -25,6 +25,7 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; +use Wikimedia\ScopedCallback; /** * Abstraction for ResourceLoader modules, with name registration and maxage functionality. diff --git a/includes/session/Session.php b/includes/session/Session.php index 31761c31e7..12f16b662e 100644 --- a/includes/session/Session.php +++ b/includes/session/Session.php @@ -600,7 +600,7 @@ final class Session implements \Countable, \Iterator, \ArrayAccess { * * Calls to save() or clear() will not be delayed. * - * @return \ScopedCallback When this goes out of scope, a save will be triggered + * @return \Wikimedia\ScopedCallback When this goes out of scope, a save will be triggered */ public function delaySave() { return $this->backend->delaySave(); diff --git a/includes/session/SessionBackend.php b/includes/session/SessionBackend.php index ea811b6563..8633715d60 100644 --- a/includes/session/SessionBackend.php +++ b/includes/session/SessionBackend.php @@ -586,11 +586,11 @@ final class SessionBackend { * * Calls to save() will not be delayed. * - * @return \ScopedCallback When this goes out of scope, a save will be triggered + * @return \Wikimedia\ScopedCallback When this goes out of scope, a save will be triggered */ public function delaySave() { $this->delaySave++; - return new \ScopedCallback( function () { + return new \Wikimedia\ScopedCallback( function () { if ( --$this->delaySave <= 0 ) { $this->delaySave = 0; $this->save(); @@ -751,7 +751,7 @@ final class SessionBackend { private function checkPHPSession() { if ( !$this->checkPHPSessionRecursionGuard ) { $this->checkPHPSessionRecursionGuard = true; - $reset = new \ScopedCallback( function () { + $reset = new \Wikimedia\ScopedCallback( function () { $this->checkPHPSessionRecursionGuard = false; } ); diff --git a/includes/session/SessionManager.php b/includes/session/SessionManager.php index 87fdcd359d..b8e480f711 100644 --- a/includes/session/SessionManager.php +++ b/includes/session/SessionManager.php @@ -880,7 +880,7 @@ final class SessionManager implements SessionManagerInterface { $session->resetId(); } - \ScopedCallback::consume( $delay ); + \Wikimedia\ScopedCallback::consume( $delay ); return $session; } diff --git a/includes/user/User.php b/includes/user/User.php index 00fc9be4c3..df3b2ac163 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -26,6 +26,7 @@ use MediaWiki\Session\Token; use MediaWiki\Auth\AuthManager; use MediaWiki\Auth\AuthenticationResponse; use MediaWiki\Auth\AuthenticationRequest; +use Wikimedia\ScopedCallback; /** * String Some punctuation to prevent editing from broken text-mangling proxies. diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index a0d6b22cce..e433c2ed9a 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -26,6 +26,7 @@ * @ingroup Testing */ use MediaWiki\MediaWikiServices; +use Wikimedia\ScopedCallback; /** * @ingroup Testing @@ -175,7 +176,7 @@ class ParserTestRunner { // arrays: $setup and $teardown. The code snippets in the $setup array // are executed at the end of the method, before it returns, and the // code snippets in the $teardown array are executed in reverse order - // when the ScopedCallback object is consumed. + // when the Wikimedia\ScopedCallback object is consumed. // Because it is a common operation to save, set and restore global // variables, we have an additional convention: when the array key of diff --git a/tests/parser/fuzzTest.php b/tests/parser/fuzzTest.php index 743705370b..9a2a9c9370 100644 --- a/tests/parser/fuzzTest.php +++ b/tests/parser/fuzzTest.php @@ -1,5 +1,7 @@ setAccessible( true ); $old = $rProp->getValue(); - $cb = new \ScopedCallback( [ $rProp, 'setValue' ], [ $old ] ); + $cb = new ScopedCallback( [ $rProp, 'setValue' ], [ $old ] ); $rProp->setValue( null ); $singleton = AuthManager::singleton(); @@ -202,11 +203,11 @@ class AuthManagerTest extends \MediaWikiTestCase { list( $provider, $reset ) = $this->getMockSessionProvider( false ); $this->assertFalse( $this->manager->canAuthenticateNow() ); - \ScopedCallback::consume( $reset ); + ScopedCallback::consume( $reset ); list( $provider, $reset ) = $this->getMockSessionProvider( true ); $this->assertTrue( $this->manager->canAuthenticateNow() ); - \ScopedCallback::consume( $reset ); + ScopedCallback::consume( $reset ); } public function testNormalizeUsername() { @@ -385,7 +386,7 @@ class AuthManagerTest extends \MediaWikiTestCase { $this->unhook( 'SecuritySensitiveOperationStatus' ); } - \ScopedCallback::consume( $reset ); + ScopedCallback::consume( $reset ); } public function onSecuritySensitiveOperationStatus( &$status, $operation, $session, $time ) { @@ -585,7 +586,7 @@ class AuthManagerTest extends \MediaWikiTestCase { $this->initializeManager(); $context = \RequestContext::getMain(); - $reset = new \ScopedCallback( [ $context, 'setLanguage' ], [ $context->getLanguage() ] ); + $reset = new ScopedCallback( [ $context, 'setLanguage' ], [ $context->getLanguage() ] ); $context->setLanguage( 'de' ); $this->setMwGlobals( 'wgContLang', \Language::factory( 'zh' ) ); @@ -712,7 +713,7 @@ class AuthManagerTest extends \MediaWikiTestCase { } $this->unhook( 'UserLoggedIn' ); $this->assertNull( $this->request->getSession()->getSecret( 'AuthManager::authnState' ) ); - \ScopedCallback::consume( $reset ); + ScopedCallback::consume( $reset ); $this->initializeManager( true ); // CreatedAccountAuthenticationRequest @@ -1449,11 +1450,11 @@ class AuthManagerTest extends \MediaWikiTestCase { ]; $block = new \Block( $blockOptions ); $block->insert(); - $scopeVariable = new \ScopedCallback( [ $block, 'delete' ] ); + $scopeVariable = new ScopedCallback( [ $block, 'delete' ] ); $status = $this->manager->checkAccountCreatePermissions( new \User ); $this->assertFalse( $status->isOK() ); $this->assertTrue( $status->hasMessage( 'cantcreateaccount-range-text' ) ); - \ScopedCallback::consume( $scopeVariable ); + ScopedCallback::consume( $scopeVariable ); $this->setMwGlobals( [ 'wgEnableDnsBlacklist' => true, diff --git a/tests/phpunit/includes/auth/CheckBlocksSecondaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/CheckBlocksSecondaryAuthenticationProviderTest.php index e6d3ecfa12..68f574b6b4 100644 --- a/tests/phpunit/includes/auth/CheckBlocksSecondaryAuthenticationProviderTest.php +++ b/tests/phpunit/includes/auth/CheckBlocksSecondaryAuthenticationProviderTest.php @@ -152,7 +152,7 @@ class CheckBlocksSecondaryAuthenticationProviderTest extends \MediaWikiTestCase ]; $block = new \Block( $blockOptions ); $block->insert(); - $scopeVariable = new \ScopedCallback( [ $block, 'delete' ] ); + $scopeVariable = new \Wikimedia\ScopedCallback( [ $block, 'delete' ] ); $user = \User::newFromName( 'UTNormalUser' ); if ( $user->getID() == 0 ) { diff --git a/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php index 8161ed4206..bc78c08f2c 100644 --- a/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php +++ b/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php @@ -2,6 +2,8 @@ namespace MediaWiki\Auth; +use Wikimedia\ScopedCallback; + /** * @group AuthManager * @group Database @@ -70,7 +72,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC } ); } - return new \ScopedCallback( function () { + return new ScopedCallback( function () { \Hooks::clear( 'AlternateUserMailer' ); \Hooks::register( 'AlternateUserMailer', function () { return false; @@ -414,7 +416,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC $dbw = wfGetDB( DB_MASTER ); $oldHash = $dbw->selectField( 'user', 'user_newpassword', [ 'user_name' => $cuser ] ); - $cb = new \ScopedCallback( function () use ( $dbw, $cuser, $oldHash ) { + $cb = new ScopedCallback( function () use ( $dbw, $cuser, $oldHash ) { $dbw->update( 'user', [ 'user_newpassword' => $oldHash ], [ 'user_name' => $cuser ] ); } ); @@ -451,7 +453,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC $changeReq->password = $newpass; $resetMailer = $this->hookMailer(); $provider->providerChangeAuthenticationData( $changeReq ); - \ScopedCallback::consume( $resetMailer ); + ScopedCallback::consume( $resetMailer ); $loginReq->password = $oldpass; $ret = $provider->beginPrimaryAuthentication( $loginReqs ); @@ -573,7 +575,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC return false; } ); $provider->providerChangeAuthenticationData( $req ); - \ScopedCallback::consume( $resetMailer ); + ScopedCallback::consume( $resetMailer ); $this->assertTrue( $mailed ); $priv = \TestingAccessWrapper::newFromObject( $provider ); @@ -723,7 +725,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC $this->assertSame( 'byemail', $provider->finishAccountCreation( $user, $creator, $res ) ); $this->assertTrue( $mailed ); - \ScopedCallback::consume( $resetMailer ); + ScopedCallback::consume( $resetMailer ); $this->assertTrue( $mailed ); } diff --git a/tests/phpunit/includes/changes/RecentChangeTest.php b/tests/phpunit/includes/changes/RecentChangeTest.php index 45f1382c47..995c4be16b 100644 --- a/tests/phpunit/includes/changes/RecentChangeTest.php +++ b/tests/phpunit/includes/changes/RecentChangeTest.php @@ -1,4 +1,5 @@ setAccessible( true ); @@ -30,7 +30,7 @@ class PHPSessionHandlerTest extends MediaWikiTestCase { $oldManager = $old->manager; $oldStore = $old->store; $oldLogger = $old->logger; - $reset[] = new \ScopedCallback( + $reset[] = new \Wikimedia\ScopedCallback( [ PHPSessionHandler::class, 'install' ], [ $oldManager, $oldStore, $oldLogger ] ); @@ -49,7 +49,7 @@ class PHPSessionHandlerTest extends MediaWikiTestCase { $rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' ); $rProp->setAccessible( true ); - $reset = new \ScopedCallback( [ $rProp, 'setValue' ], [ $rProp->getValue() ] ); + $reset = new \Wikimedia\ScopedCallback( [ $rProp, 'setValue' ], [ $rProp->getValue() ] ); $rProp->setValue( $handler ); $handler->setEnableFlags( 'enable' ); @@ -123,7 +123,7 @@ class PHPSessionHandlerTest extends MediaWikiTestCase { ] ); PHPSessionHandler::install( $manager ); $wrap = \TestingAccessWrapper::newFromObject( $rProp->getValue() ); - $reset[] = new \ScopedCallback( + $reset[] = new \Wikimedia\ScopedCallback( [ $wrap, 'setEnableFlags' ], [ $wrap->enable ? $wrap->warn ? 'warn' : 'enable' : 'disable' ] ); @@ -326,7 +326,7 @@ class PHPSessionHandlerTest extends MediaWikiTestCase { \TestingAccessWrapper::newFromObject( $handler )->setEnableFlags( 'disable' ); $oldValue = $rProp->getValue(); $rProp->setValue( $handler ); - $reset = new \ScopedCallback( [ $rProp, 'setValue' ], [ $oldValue ] ); + $reset = new \Wikimedia\ScopedCallback( [ $rProp, 'setValue' ], [ $oldValue ] ); call_user_func_array( [ $handler, $method ], $args ); } diff --git a/tests/phpunit/includes/session/SessionBackendTest.php b/tests/phpunit/includes/session/SessionBackendTest.php index a3d5de772c..8a0adbad76 100644 --- a/tests/phpunit/includes/session/SessionBackendTest.php +++ b/tests/phpunit/includes/session/SessionBackendTest.php @@ -464,7 +464,7 @@ class SessionBackendTest extends MediaWikiTestCase { // Save happens when delay is consumed $this->onSessionMetadataCalled = false; $priv->metaDirty = true; - \ScopedCallback::consume( $delay ); + \Wikimedia\ScopedCallback::consume( $delay ); $this->assertTrue( $this->onSessionMetadataCalled ); // Test multiple delays @@ -475,11 +475,11 @@ class SessionBackendTest extends MediaWikiTestCase { $priv->metaDirty = true; $priv->autosave(); $this->assertFalse( $this->onSessionMetadataCalled ); - \ScopedCallback::consume( $delay3 ); + \Wikimedia\ScopedCallback::consume( $delay3 ); $this->assertFalse( $this->onSessionMetadataCalled ); - \ScopedCallback::consume( $delay1 ); + \Wikimedia\ScopedCallback::consume( $delay1 ); $this->assertFalse( $this->onSessionMetadataCalled ); - \ScopedCallback::consume( $delay2 ); + \Wikimedia\ScopedCallback::consume( $delay2 ); $this->assertTrue( $this->onSessionMetadataCalled ); } @@ -822,7 +822,7 @@ class SessionBackendTest extends MediaWikiTestCase { $rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' ); $rProp->setAccessible( true ); $handler = \TestingAccessWrapper::newFromObject( $rProp->getValue() ); - $resetHandler = new \ScopedCallback( function () use ( $handler ) { + $resetHandler = new \Wikimedia\ScopedCallback( function () use ( $handler ) { session_write_close(); $handler->enable = false; } ); @@ -862,7 +862,7 @@ class SessionBackendTest extends MediaWikiTestCase { $rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' ); $rProp->setAccessible( true ); $handler = \TestingAccessWrapper::newFromObject( $rProp->getValue() ); - $resetHandler = new \ScopedCallback( function () use ( $handler ) { + $resetHandler = new \Wikimedia\ScopedCallback( function () use ( $handler ) { session_write_close(); $handler->enable = false; } ); @@ -898,7 +898,7 @@ class SessionBackendTest extends MediaWikiTestCase { $rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' ); $rProp->setAccessible( true ); $handler = \TestingAccessWrapper::newFromObject( $rProp->getValue() ); - $resetHandler = new \ScopedCallback( function () use ( $handler ) { + $resetHandler = new \Wikimedia\ScopedCallback( function () use ( $handler ) { session_write_close(); $handler->enable = false; } ); diff --git a/tests/phpunit/includes/session/SessionManagerTest.php b/tests/phpunit/includes/session/SessionManagerTest.php index 1ebb07c8e6..6273f477c8 100644 --- a/tests/phpunit/includes/session/SessionManagerTest.php +++ b/tests/phpunit/includes/session/SessionManagerTest.php @@ -62,7 +62,7 @@ class SessionManagerTest extends MediaWikiTestCase { $rProp->setAccessible( true ); $handler = \TestingAccessWrapper::newFromObject( $rProp->getValue() ); $oldEnable = $handler->enable; - $reset[] = new \ScopedCallback( function () use ( $handler, $oldEnable ) { + $reset[] = new \Wikimedia\ScopedCallback( function () use ( $handler, $oldEnable ) { if ( $handler->enable ) { session_write_close(); } diff --git a/tests/phpunit/includes/session/TestUtils.php b/tests/phpunit/includes/session/TestUtils.php index 0cc8ebf134..f00de55a30 100644 --- a/tests/phpunit/includes/session/TestUtils.php +++ b/tests/phpunit/includes/session/TestUtils.php @@ -45,7 +45,7 @@ class TestUtils { PHPSessionHandler::install( $manager ); } - return new \ScopedCallback( function () use ( &$reset, $oldInstance ) { + return new \Wikimedia\ScopedCallback( function () use ( &$reset, $oldInstance ) { foreach ( $reset as &$arr ) { $arr[0]->setValue( $arr[1] ); } diff --git a/tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php b/tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php index 3d407fbc32..145ffb3547 100644 --- a/tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php +++ b/tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php @@ -1,4 +1,6 @@