Ricordisamoa has uploaded a new change for review.

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

Change subject: Stop doing $that = $this in includes/db
......................................................................

Stop doing $that = $this in includes/db

Closures support $this as of PHP 5.4

Also made DatabaseBase::indexName() protected

Change-Id: Iff31e7d9186832a855a953b923ac182f1c66ffa0
---
M includes/db/Database.php
M includes/db/DatabaseMysqlBase.php
2 files changed, 11 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/20/269720/1

diff --git a/includes/db/Database.php b/includes/db/Database.php
index a4d0ad0..564cd2e 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -1929,10 +1929,7 @@
         * @param string $index
         * @return string
         */
-       public function indexName( $index ) {
-               // @FIXME: Make this protected once we move away from PHP 5.3
-               // Needs to be public because of usage in closure (in 
DatabaseBase::replaceVars)
-
+       protected function indexName( $index ) {
                // Backwards-compatibility hack
                $renamed = array(
                        'ar_usertext_timestamp' => 'usertext_timestamp',
@@ -3100,7 +3097,6 @@
         * @return string The new SQL statement with variables replaced
         */
        protected function replaceVars( $ins ) {
-               $that = $this;
                $vars = $this->getSchemaVars();
                return preg_replace_callback(
                        '!
@@ -3109,19 +3105,19 @@
                                `\{\$ (\w+) }`                    | # 4. 
addIdentifierQuotes
                                /\*\$ (\w+) \*/                     # 5. leave 
unencoded
                        !x',
-                       function ( $m ) use ( $that, $vars ) {
+                       function ( $m ) use ( $vars ) {
                                // Note: Because of 
<https://bugs.php.net/bug.php?id=51881>,
                                // check for both nonexistent keys *and* the 
empty string.
                                if ( isset( $m[1] ) && $m[1] !== '' ) {
                                        if ( $m[1] === 'i' ) {
-                                               return $that->indexName( $m[2] 
);
+                                               return $this->indexName( $m[2] 
);
                                        } else {
-                                               return $that->tableName( $m[2] 
);
+                                               return $this->tableName( $m[2] 
);
                                        }
                                } elseif ( isset( $m[3] ) && $m[3] !== '' && 
array_key_exists( $m[3], $vars ) ) {
-                                       return $that->addQuotes( $vars[$m[3]] );
+                                       return $this->addQuotes( $vars[$m[3]] );
                                } elseif ( isset( $m[4] ) && $m[4] !== '' && 
array_key_exists( $m[4], $vars ) ) {
-                                       return $that->addIdentifierQuotes( 
$vars[$m[4]] );
+                                       return $this->addIdentifierQuotes( 
$vars[$m[4]] );
                                } elseif ( isset( $m[5] ) && $m[5] !== '' && 
array_key_exists( $m[5], $vars ) ) {
                                        return $vars[$m[5]];
                                } else {
@@ -3179,10 +3175,9 @@
                        return null;
                }
 
-               $that = $this;
-               $unlocker = new ScopedCallback( function () use ( $that, 
$lockKey, $fname ) {
-                       $that->commit( __METHOD__, 'flush' );
-                       $that->unlock( $lockKey, $fname );
+               $unlocker = new ScopedCallback( function () use ( $lockKey, 
$fname ) {
+                       $this->commit( __METHOD__, 'flush' );
+                       $this->unlock( $lockKey, $fname );
                } );
 
                $this->commit( __METHOD__, 'flush' );
diff --git a/includes/db/DatabaseMysqlBase.php 
b/includes/db/DatabaseMysqlBase.php
index 29106ab..c5aafea 100644
--- a/includes/db/DatabaseMysqlBase.php
+++ b/includes/db/DatabaseMysqlBase.php
@@ -692,17 +692,16 @@
                        $this->getLBInfo( 'clusterMasterHost' ) ?: 
$this->getServer()
                );
 
-               $that = $this;
                return $cache->getWithSetCallback(
                        $key,
                        $cache::TTL_INDEFINITE,
-                       function () use ( $that, $cache, $key ) {
+                       function () use ( $cache, $key ) {
                                // Get and leave a lock key in place for a 
short period
                                if ( !$cache->lock( $key, 0, 10 ) ) {
                                        return false; // avoid master 
connection spike slams
                                }
 
-                               $conn = $that->getLazyMasterHandle();
+                               $conn = $this->getLazyMasterHandle();
                                if ( !$conn ) {
                                        return false; // something is 
misconfigured
                                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iff31e7d9186832a855a953b923ac182f1c66ffa0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <ricordisa...@openmailbox.org>

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

Reply via email to