From c71a50e2a065240d0d57a25f73cb449da49481a4 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Sun, 24 Mar 2019 22:44:46 +0100 Subject: [PATCH] Rename PoolCounter_Stub to PoolCounterNull Also move to own file Remove "Stub", because it refers a php concept, which is not used here Change-Id: Ife952901b5ad8e4a408d229ee72de953a9acc220 --- .phpcs.xml | 1 - autoload.php | 2 +- includes/poolcounter/PoolCounter.php | 24 ++----------- includes/poolcounter/PoolCounterNull.php | 44 ++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 24 deletions(-) create mode 100644 includes/poolcounter/PoolCounterNull.php diff --git a/.phpcs.xml b/.phpcs.xml index 69346483b8..d1e54a706c 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -228,7 +228,6 @@ */includes/parser/Preprocessor_Hash\.php */includes/parser/Preprocessor\.php */includes/PathRouter\.php - */includes/poolcounter/PoolCounter\.php */includes/PrefixSearch\.php */includes/profiler/SectionProfiler\.php */includes/search/SearchEngine\.php diff --git a/autoload.php b/autoload.php index bbfe251283..94a99faaa7 100644 --- a/autoload.php +++ b/autoload.php @@ -1108,10 +1108,10 @@ $wgAutoloadLocalClasses = [ 'PhpXmlBugTester' => __DIR__ . '/includes/installer/PhpBugTests.php', 'Pingback' => __DIR__ . '/includes/Pingback.php', 'PoolCounter' => __DIR__ . '/includes/poolcounter/PoolCounter.php', + 'PoolCounterNull' => __DIR__ . '/includes/poolcounter/PoolCounterNull.php', 'PoolCounterRedis' => __DIR__ . '/includes/poolcounter/PoolCounterRedis.php', 'PoolCounterWork' => __DIR__ . '/includes/poolcounter/PoolCounterWork.php', 'PoolCounterWorkViaCallback' => __DIR__ . '/includes/poolcounter/PoolCounterWorkViaCallback.php', - 'PoolCounter_Stub' => __DIR__ . '/includes/poolcounter/PoolCounter.php', 'PoolWorkArticleView' => __DIR__ . '/includes/poolcounter/PoolWorkArticleView.php', 'PopulateArchiveRevId' => __DIR__ . '/maintenance/populateArchiveRevId.php', 'PopulateBacklinkNamespace' => __DIR__ . '/maintenance/populateBacklinkNamespace.php', diff --git a/includes/poolcounter/PoolCounter.php b/includes/poolcounter/PoolCounter.php index ba0b4cb318..060faec52e 100644 --- a/includes/poolcounter/PoolCounter.php +++ b/includes/poolcounter/PoolCounter.php @@ -39,7 +39,7 @@ * that start with "nowait:". However, only 0 timeouts (non-blocking requests) * can be used with "nowait:" keys. * - * By default PoolCounter_Stub is used, which provides no locking. You + * By default PoolCounterNull is used, which provides no locking. You * can get a useful one in the PoolCounter extension. */ abstract class PoolCounter { @@ -111,7 +111,7 @@ abstract class PoolCounter { public static function factory( $type, $key ) { global $wgPoolCounterConf; if ( !isset( $wgPoolCounterConf[$type] ) ) { - return new PoolCounter_Stub; + return new PoolCounterNull; } $conf = $wgPoolCounterConf[$type]; $class = $conf['class']; @@ -208,23 +208,3 @@ abstract class PoolCounter { return $type . ':' . ( hexdec( substr( sha1( $key ), 0, 4 ) ) % $slots ); } } - -// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps -class PoolCounter_Stub extends PoolCounter { - - public function __construct() { - /* No parameters needed */ - } - - public function acquireForMe() { - return Status::newGood( PoolCounter::LOCKED ); - } - - public function acquireForAnyone() { - return Status::newGood( PoolCounter::LOCKED ); - } - - public function release() { - return Status::newGood( PoolCounter::RELEASED ); - } -} diff --git a/includes/poolcounter/PoolCounterNull.php b/includes/poolcounter/PoolCounterNull.php new file mode 100644 index 0000000000..95a5057131 --- /dev/null +++ b/includes/poolcounter/PoolCounterNull.php @@ -0,0 +1,44 @@ +