Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/367747 )
Change subject: Get rid of return-a-reference option ...................................................................... Get rid of return-a-reference option We aren't using it any more, and we shouldn't start. Bug: T171560 Change-Id: I28e310da3f86f8540a61b81ae466ff4c848bdca7 --- M Core/Configuration.php M Core/DataStores/QueueWrapper.php M Core/Listeners/ListenerBase.php 3 files changed, 15 insertions(+), 30 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/SmashPig refs/changes/47/367747/1 diff --git a/Core/Configuration.php b/Core/Configuration.php index 3923c7a..bf59f2a 100644 --- a/Core/Configuration.php +++ b/Core/Configuration.php @@ -104,15 +104,12 @@ * Obtain a value from the configuration. If the key does not exist this will throw an * exception. * - * @param string $node Parameter node to obtain. If this contains '/' it is assumed that the + * @param string $path Parameter node to obtain. If this contains '/' it is assumed that the * value is contained under additional keys. - * @param bool $returnRef If true will return a reference to the configuration node. This will - * mean that any modifications to the node will be stored in RAM for the - * duration of the session. * @return mixed * @throws ConfigurationKeyException */ - public function &val( $node, $returnRef = false ) { + public function val( $path ) { /* * Magic "/" returns the entire configuration tree. * @@ -122,34 +119,22 @@ * Note: Never log this tree insecurely, it will contain processor * credentials and other sensitive information. */ - if ( $node === '/' ) { - if ( $returnRef ) { - // TODO: Don't offer a return-by-reference. - $options = &$this->options; - } else { - $options = $this->options; - } - return $options; + if ( $path === '/' ) { + return $this->options; } - $keys = explode( '/', $node ); + $segments = explode( '/', $path ); - $croot = & $this->options; - foreach ( $keys as $key ) { - if ( array_key_exists( $key, $croot ) ) { - $croot = & $croot[ $key ]; + $currentNode = $this->options; + foreach ( $segments as $segment ) { + if ( array_key_exists( $segment, $currentNode ) ) { + $currentNode = $currentNode[$segment]; } else { - throw new ConfigurationKeyException( "Configuration key '{$node}' does not exist.", $node ); + throw new ConfigurationKeyException( "Configuration key '{$path}' does not exist.", $path ); } } - if ( $returnRef ) { - return $croot; - } else { - // Dereference the variable - $obj = $croot; - return $obj; - } + return $currentNode; } /** @@ -208,7 +193,7 @@ */ public function nodeExists( $node ) { try { - $this->val( $node, true ); + $this->val( $node ); return true; } catch ( ConfigurationKeyException $ex ) { return false; diff --git a/Core/DataStores/QueueWrapper.php b/Core/DataStores/QueueWrapper.php index ac504f6..537038d 100644 --- a/Core/DataStores/QueueWrapper.php +++ b/Core/DataStores/QueueWrapper.php @@ -30,7 +30,7 @@ $key = "data-store/$queueName"; // Examine the config node for a queue name - $node = $config->val( $key, true ); + $node = $config->val( $key ); if ( empty( $node['constructor-parameters'] ) || empty( $node['constructor-parameters'][0]['queue'] ) @@ -52,4 +52,4 @@ return $config->object( $key ); } -} \ No newline at end of file +} diff --git a/Core/Listeners/ListenerBase.php b/Core/Listeners/ListenerBase.php index 2c32225..9d35737 100644 --- a/Core/Listeners/ListenerBase.php +++ b/Core/Listeners/ListenerBase.php @@ -49,7 +49,7 @@ */ protected function validateRemoteIp() { // Obtain whitelist - $whitelist = $this->c->val( 'security/ip-whitelist', true ); + $whitelist = $this->c->val( 'security/ip-whitelist' ); // Obtain remote party IP $remote_ip = $this->request->getClientIp(); -- To view, visit https://gerrit.wikimedia.org/r/367747 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I28e310da3f86f8540a61b81ae466ff4c848bdca7 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/SmashPig Gerrit-Branch: deployment Gerrit-Owner: Ejegg <ej...@ejegg.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits