From efe5761c93e0987d4cb76f7aa653dabd1fbbb395 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Sat, 17 Nov 2018 00:30:28 +0100 Subject: [PATCH] build: Updating mediawiki/mediawiki-codesniffer to 23.0.0 Avoid use of __METHOD__ magic constant in closure Change-Id: I28d519530ca2fcde026a6cbb419848098d4617ca --- composer.json | 2 +- includes/actions/RollbackAction.php | 7 ++++--- includes/api/ApiRollback.php | 7 ++++--- includes/changetags/ChangeTags.php | 14 ++++++++------ includes/deferred/UserEditCountUpdate.php | 9 +++++---- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index d923db1809..01f210844f 100644 --- a/composer.json +++ b/composer.json @@ -64,7 +64,7 @@ "jakub-onderka/php-parallel-lint": "0.9.2", "jetbrains/phpstorm-stubs": "dev-master#38ff1a581b297f7901e961b8c923862ea80c3b96", "justinrainbow/json-schema": "~5.2", - "mediawiki/mediawiki-codesniffer": "22.0.0", + "mediawiki/mediawiki-codesniffer": "23.0.0", "monolog/monolog": "~1.22.1", "nikic/php-parser": "3.1.3", "seld/jsonlint": "1.7.1", diff --git a/includes/actions/RollbackAction.php b/includes/actions/RollbackAction.php index dec3e61535..3e6d4028a4 100644 --- a/includes/actions/RollbackAction.php +++ b/includes/actions/RollbackAction.php @@ -70,11 +70,12 @@ class RollbackAction extends FormlessAction { } // @TODO: remove this hack once rollback uses POST (T88044) + $fname = __METHOD__; $trxLimits = $this->context->getConfig()->get( 'TrxProfilerLimits' ); $trxProfiler = Profiler::instance()->getTransactionProfiler(); - $trxProfiler->setExpectations( $trxLimits['POST'], __METHOD__ ); - DeferredUpdates::addCallableUpdate( function () use ( $trxProfiler, $trxLimits ) { - $trxProfiler->setExpectations( $trxLimits['PostSend-POST'], __METHOD__ ); + $trxProfiler->setExpectations( $trxLimits['POST'], $fname ); + DeferredUpdates::addCallableUpdate( function () use ( $trxProfiler, $trxLimits, $fname ) { + $trxProfiler->setExpectations( $trxLimits['PostSend-POST'], $fname ); } ); $data = null; diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php index 10ba4782b7..78696daa28 100644 --- a/includes/api/ApiRollback.php +++ b/includes/api/ApiRollback.php @@ -56,11 +56,12 @@ class ApiRollback extends ApiBase { } // @TODO: remove this hack once rollback uses POST (T88044) + $fname = __METHOD__; $trxLimits = $this->getConfig()->get( 'TrxProfilerLimits' ); $trxProfiler = Profiler::instance()->getTransactionProfiler(); - $trxProfiler->setExpectations( $trxLimits['POST'], __METHOD__ ); - DeferredUpdates::addCallableUpdate( function () use ( $trxProfiler, $trxLimits ) { - $trxProfiler->setExpectations( $trxLimits['PostSend-POST'], __METHOD__ ); + $trxProfiler->setExpectations( $trxLimits['POST'], $fname ); + DeferredUpdates::addCallableUpdate( function () use ( $trxProfiler, $trxLimits, $fname ) { + $trxProfiler->setExpectations( $trxLimits['PostSend-POST'], $fname ); } ); $retval = $pageObj->doRollback( diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index 5e83f9509a..17b445d4c2 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -348,13 +348,14 @@ class ChangeTags { foreach ( $tagsToAdd as $tag ) { $changeTagMapping[$tag] = $changeTagDefStore->acquireId( $tag ); } + $fname = __METHOD__; // T207881: update the counts at the end of the transaction - $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tagsToAdd ) { + $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tagsToAdd, $fname ) { $dbw->update( 'change_tag_def', [ 'ctd_count = ctd_count + 1' ], [ 'ctd_name' => $tagsToAdd ], - __METHOD__ + $fname ); } ); @@ -381,6 +382,7 @@ class ChangeTags { // delete from change_tag if ( count( $tagsToRemove ) ) { + $fname = __METHOD__; foreach ( $tagsToRemove as $tag ) { $conds = array_filter( [ @@ -393,18 +395,18 @@ class ChangeTags { $dbw->delete( 'change_tag', $conds, __METHOD__ ); if ( $dbw->affectedRows() ) { // T207881: update the counts at the end of the transaction - $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tag ) { + $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tag, $fname ) { $dbw->update( 'change_tag_def', [ 'ctd_count = ctd_count - 1' ], [ 'ctd_name' => $tag ], - __METHOD__ + $fname ); $dbw->delete( 'change_tag_def', [ 'ctd_name' => $tag, 'ctd_count' => 0, 'ctd_user_defined' => 0 ], - __METHOD__ + $fname ); } ); } @@ -1459,7 +1461,7 @@ class ChangeTags { 'change_tag_def', 'ctd_name', [ 'ctd_user_defined' => 1 ], - __METHOD__ + $fname ); return array_filter( array_unique( $tags ) ); diff --git a/includes/deferred/UserEditCountUpdate.php b/includes/deferred/UserEditCountUpdate.php index 5194e4f1cc..4ce0b18ec6 100644 --- a/includes/deferred/UserEditCountUpdate.php +++ b/includes/deferred/UserEditCountUpdate.php @@ -68,14 +68,15 @@ class UserEditCountUpdate implements DeferrableUpdate, MergeableUpdate { public function doUpdate() { $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); $dbw = $lb->getConnection( DB_MASTER ); + $fname = __METHOD__; - ( new AutoCommitUpdate( $dbw, __METHOD__, function () use ( $lb, $dbw ) { + ( new AutoCommitUpdate( $dbw, __METHOD__, function () use ( $lb, $dbw, $fname ) { foreach ( $this->infoByUser as $userId => $info ) { $dbw->update( 'user', [ 'user_editcount=user_editcount+' . (int)$info['increment'] ], [ 'user_id' => $userId, 'user_editcount IS NOT NULL' ], - __METHOD__ + $fname ); /** @var User[] $affectedInstances */ $affectedInstances = $info['instances']; @@ -87,7 +88,7 @@ class UserEditCountUpdate implements DeferrableUpdate, MergeableUpdate { if ( $dbr !== $dbw ) { // This method runs after the new revisions were committed. // Wait for the replica to catch up so they will all be counted. - $dbr->flushSnapshot( __METHOD__ ); + $dbr->flushSnapshot( $fname ); $lb->safeWaitForMasterPos( $dbr ); } $affectedInstances[0]->initEditCountInternal(); @@ -96,7 +97,7 @@ class UserEditCountUpdate implements DeferrableUpdate, MergeableUpdate { 'user', [ 'user_editcount' ], [ 'user_id' => $userId ], - __METHOD__ + $fname ); // Update the edit count in the instance caches. This is mostly useful -- 2.20.1