Alexia has uploaded a new change for review.

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

Change subject: Redis scan functions require iterator passed by reference.
......................................................................

Redis scan functions require iterator passed by reference.

Change-Id: I158647ab8bc656f6f0afb1ef1f6d2f19b2fb7cb5
---
M includes/clientpool/RedisConnectionPool.php
1 file changed, 16 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/55/252455/1

diff --git a/includes/clientpool/RedisConnectionPool.php 
b/includes/clientpool/RedisConnectionPool.php
index 64db0d6..4da59de 100644
--- a/includes/clientpool/RedisConnectionPool.php
+++ b/includes/clientpool/RedisConnectionPool.php
@@ -471,24 +471,34 @@
 
        public function __call( $name, $arguments ) {
                $conn = $this->conn; // convenience
+               $_arguments = $arguments; //Necessary for the iterator 
reference fix below to work.
 
                // Work around https://github.com/nicolasff/phpredis/issues/70
                $lname = strtolower( $name );
                if ( ( $lname === 'blpop' || $lname == 'brpop' )
-                       && is_array( $arguments[0] ) && isset( $arguments[1] )
+                       && is_array( $_arguments[0] ) && isset( $_arguments[1] )
                ) {
-                       $this->pool->resetTimeout( $conn, $arguments[1] + 1 );
-               } elseif ( $lname === 'brpoplpush' && isset( $arguments[2] ) ) {
-                       $this->pool->resetTimeout( $conn, $arguments[2] + 1 );
+                       $this->pool->resetTimeout( $conn, $_arguments[1] + 1 );
+               } elseif ( $lname === 'brpoplpush' && isset( $_arguments[2] ) ) 
{
+                       $this->pool->resetTimeout( $conn, $_arguments[2] + 1 );
+               }
+
+               if ( $lname === 'scan' || $lname === 'hscan' || $lname === 
'sscan' || $lname === 'zscan' ) {
+                       //Work around for iterator reference in scan functions.
+                       
//http://stackoverflow.com/questions/8101071/call-user-func-array-with-references
+                       $_arguments = array();
+                       foreach ( $arguments as $key => $value ) {
+                               $_arguments[$key] = &$arguments[$key];
+                       }
                }
 
                $conn->clearLastError();
                try {
-                       $res = call_user_func_array( array( $conn, $name ), 
$arguments );
+                       $res = call_user_func_array( array( $conn, $name ), 
$_arguments );
                        if ( preg_match( '/^ERR operation not permitted\b/', 
$conn->getLastError() ) ) {
                                $this->pool->reauthenticateConnection( 
$this->server, $conn );
                                $conn->clearLastError();
-                               $res = call_user_func_array( array( $conn, 
$name ), $arguments );
+                               $res = call_user_func_array( array( $conn, 
$name ), $_arguments );
                                $this->logger->info(
                                        "Used automatic re-authentication for 
method '$name'.",
                                        array( 'redis_server' => $this->server )

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I158647ab8bc656f6f0afb1ef1f6d2f19b2fb7cb5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alexia <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to