Daniel Kinzler has uploaded a new change for review.

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

Change subject: Avoid static access to settings.
......................................................................

Avoid static access to settings.

Note that some classes in lib still use Settings::get, so they
can use the repo or client settings, depending on context. That
should also be fixed, but is beyond the scope of this patch.

Change-Id: If4e080b2f9901edd3d8253a2df3d9299b7a9f5d8
---
M repo/includes/Hooks/OutputPageJsConfigHookHandler.php
M repo/maintenance/dispatchChanges.php
2 files changed, 24 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/25/203025/1

diff --git a/repo/includes/Hooks/OutputPageJsConfigHookHandler.php 
b/repo/includes/Hooks/OutputPageJsConfigHookHandler.php
index 34a8f7b..618989b 100644
--- a/repo/includes/Hooks/OutputPageJsConfigHookHandler.php
+++ b/repo/includes/Hooks/OutputPageJsConfigHookHandler.php
@@ -4,7 +4,7 @@
 
 use OutputPage;
 use Wikibase\OutputPageJsConfigBuilder;
-use Wikibase\Settings;
+use Wikibase\SettingsArray;
 
 /**
  * @since 0.5
@@ -15,7 +15,7 @@
 class OutputPageJsConfigHookHandler {
 
        /**
-        * @var Settings
+        * @var SettingsArray
         */
        protected $settings;
 
@@ -25,9 +25,11 @@
        protected $outputPageConfigBuilder;
 
        /**
-        * @param Settings $settings
+        * @todo: don't pass around SettingsArray, just take specific 
constructor params.
+        *
+        * @param SettingsArray $settings
         */
-       public function __construct( Settings $settings ) {
+       public function __construct( SettingsArray $settings ) {
                $this->settings = $settings;
                $this->outputPageConfigBuilder = new 
OutputPageJsConfigBuilder();
        }
@@ -49,9 +51,9 @@
         * @return array
         */
        private function buildConfigVars( OutputPage $out, $isExperimental ) {
-               $rightsUrl = $this->settings->get( 'dataRightsUrl' );
-               $rightsText = $this->settings->get( 'dataRightsText' );
-               $badgeItems = $this->settings->get( 'badgeItems' );
+               $rightsUrl = $this->settings->getSetting( 'dataRightsUrl' );
+               $rightsText = $this->settings->getSetting( 'dataRightsText' );
+               $badgeItems = $this->settings->getSetting( 'badgeItems' );
 
                $configVars = $this->outputPageConfigBuilder->build(
                        $out,
diff --git a/repo/maintenance/dispatchChanges.php 
b/repo/maintenance/dispatchChanges.php
index bfe87e1..d35bb63 100644
--- a/repo/maintenance/dispatchChanges.php
+++ b/repo/maintenance/dispatchChanges.php
@@ -2,11 +2,13 @@
 
 namespace Wikibase;
 
+use MWException;
 use Wikibase\Lib\Reporting\ObservableMessageReporter;
 use Wikibase\Lib\Reporting\ReportingExceptionHandler;
 use Wikibase\Lib\Store\SiteLinkTable;
 use Wikibase\Repo\ChangeDispatcher;
 use Wikibase\Repo\Notifications\JobQueueChangeNotificationSender;
+use Wikibase\Repo\WikibaseRepo;
 use Wikibase\Store\DualSubscriptionLookup;
 use Wikibase\Store\SiteLinkSubscriptionLookup;
 use Wikibase\Store\Sql\SqlChangeDispatchCoordinator;
@@ -58,15 +60,20 @@
 
        /**
         * Initializes members from command line options and configuration 
settings.
+        *
+        * @param SettingsArray $settings
+        *
+        * @return ChangeDispatcher
+        * @throws MWException
         */
-       private function newChangeDispatcher() {
+       private function newChangeDispatcher( SettingsArray $settings ) {
                $changesTable = new ChangesTable(); //TODO: allow injection of 
a mock instance for testing
 
-               $repoDB = Settings::get( 'changesDatabase' );
-               $clientWikis = Settings::get( 'localClientDatabases' );
-               $batchChunkFactor = Settings::get( 'dispatchBatchChunkFactor' );
-               $batchCacheFactor = Settings::get( 'dispatchBatchCacheFactor' );
-               $subscriptionLookupMode = Settings::get( 
'subscriptionLookupMode' );
+               $repoDB = $settings->getSetting( 'changesDatabase' );
+               $clientWikis = $settings->getSetting( 'localClientDatabases' );
+               $batchChunkFactor = $settings->getSetting( 
'dispatchBatchChunkFactor' );
+               $batchCacheFactor = $settings->getSetting( 
'dispatchBatchCacheFactor' );
+               $subscriptionLookupMode = $settings->getSetting( 
'subscriptionLookupMode' );
 
                $batchSize = intval( $this->getOption( 'batch-size', 1000 ) );
                $dispatchInterval = intval( $this->getOption( 
'dispatch-interval', 60 ) );
@@ -144,7 +151,8 @@
                $maxPasses = intval( $this->getOption( 'max-passes', $maxTime < 
PHP_INT_MAX ? PHP_INT_MAX : 1 ) );
                $delay = intval( $this->getOption( 'idle-delay', 10 ) );
 
-               $dispatcher = $this->newChangeDispatcher();
+               $settings = WikibaseRepo::getDefaultInstance()->getSettings();
+               $dispatcher = $this->newChangeDispatcher( $settings );
 
                $dispatcher->getDispatchCoordinator()->initState();
 

-- 
To view, visit https://gerrit.wikimedia.org/r/203025
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If4e080b2f9901edd3d8253a2df3d9299b7a9f5d8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <daniel.kinz...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to