Merge "Added per-backend profiling calls."
authorHashar <hashar@free.fr>
Thu, 22 Mar 2012 11:01:00 +0000 (11:01 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 22 Mar 2012 11:01:00 +0000 (11:01 +0000)
includes/HTMLForm.php
includes/RecentChange.php
includes/db/Database.php
includes/objectcache/MemcachedClient.php
languages/Language.php
languages/classes/LanguageKaa.php
maintenance/deleteDefaultMessages.php
tests/phpunit/languages/LanguageTest.php

index 3b3e1b6..dccf967 100644 (file)
@@ -271,7 +271,7 @@ class HTMLForm extends ContextSource {
 
        /**
         * The here's-one-I-made-earlier option: do the submission if
-        * posted, or display the form with or without funky valiation
+        * posted, or display the form with or without funky validation
         * errors
         * @return Bool or Status whether submission was successful.
         */
@@ -279,7 +279,7 @@ class HTMLForm extends ContextSource {
                $this->prepareForm();
 
                $result = $this->tryAuthorizedSubmit();
-               if ( $result === true || ( $result instanceof Status && $result->isGood() ) ){
+               if ( $result === true || ( $result instanceof Status && $result->isGood() ) ) {
                        return $result;
                }
 
index a1097be..e57efae 100644 (file)
@@ -751,7 +751,7 @@ class RecentChange {
                return ChangesList::showCharacterDifference( $old, $new );
        }
 
-       public static function checkIPAddress( $ip ) {
+       private static function checkIPAddress( $ip ) {
                global $wgRequest;
                if ( $ip ) {
                        if ( !IP::isIPAddress( $ip ) ) {
index 47eb596..5c03617 100644 (file)
@@ -680,7 +680,7 @@ abstract class DatabaseBase implements DatabaseType {
                $dbType = strtolower( $dbType );
                $class = 'Database' . ucfirst( $dbType );
 
-               if( in_array( $dbType, $canonicalDBTypes ) ) {
+               if( in_array( $dbType, $canonicalDBTypes ) || ( class_exists( $class ) && is_subclass_of( $class, 'DatabaseBase' ) ) ) {
                        return new $class(
                                isset( $p['host'] ) ? $p['host'] : false,
                                isset( $p['user'] ) ? $p['user'] : false,
@@ -689,8 +689,6 @@ abstract class DatabaseBase implements DatabaseType {
                                isset( $p['flags'] ) ? $p['flags'] : 0,
                                isset( $p['tablePrefix'] ) ? $p['tablePrefix'] : 'get from global'
                        );
-               } elseif ( class_exists( $class ) && is_subclass_of( $class, 'DatabaseBase' ) ) {
-                       return new $class( $p );
                } else {
                        return null;
                }
index f8208f6..4f49f7d 100644 (file)
@@ -344,11 +344,20 @@ class MWMemcached {
                return false;
        }
 
+       /**
+        * @param $key
+        * @param $timeout int
+        * @return bool
+        */
        public function lock( $key, $timeout = 0 ) {
                /* stub */
                return true;
        }
 
+       /**
+        * @param $key
+        * @return bool
+        */
        public function unlock( $key ) {
                /* stub */
                return true;
@@ -471,7 +480,7 @@ class MWMemcached {
                        $this->stats['get_multi'] = 1;
                }
                $sock_keys = array();
-
+               $socks = array();
                foreach ( $keys as $key ) {
                        $sock = $this->get_sock( $key );
                        if ( !is_resource( $sock ) ) {
@@ -485,6 +494,7 @@ class MWMemcached {
                        $sock_keys[$sock][] = $key;
                }
 
+               $gather = array();
                // Send out the requests
                foreach ( $socks as $sock ) {
                        $cmd = 'get';
@@ -579,6 +589,7 @@ class MWMemcached {
                        return array();
                }
 
+               $ret = array();
                while ( true ) {
                        $res = fgets( $sock );
                        $ret[] = $res;
@@ -744,6 +755,9 @@ class MWMemcached {
                $this->_dead_host( $host );
        }
 
+       /**
+        * @param $host
+        */
        function _dead_host( $host ) {
                $parts = explode( ':', $host );
                $ip = $parts[0];
@@ -774,8 +788,8 @@ class MWMemcached {
                }
 
                $hv = is_array( $key ) ? intval( $key[0] ) : $this->_hashfunc( $key );
-
                if ( $this->_buckets === null ) {
+                       $bu = array();
                        foreach ( $this->_servers as $v ) {
                                if ( is_array( $v ) ) {
                                        for( $i = 0; $i < $v[1]; $i++ ) {
@@ -851,7 +865,8 @@ class MWMemcached {
                        $this->stats[$cmd] = 1;
                }
                if ( !$this->_safe_fwrite( $sock, "$cmd $key $amt\r\n" ) ) {
-                       return $this->_dead_sock( $sock );
+                       $this->_dead_sock( $sock );
+                       return null;
                }
 
                $line = fgets( $sock );
@@ -998,7 +1013,8 @@ class MWMemcached {
                        }
                }
                if ( !$this->_safe_fwrite( $sock, "$cmd $key $flags $exp $len\r\n$val\r\n" ) ) {
-                       return $this->_dead_sock( $sock );
+                       $this->_dead_sock( $sock );
+                       return false;
                }
 
                $line = trim( fgets( $sock ) );
@@ -1038,7 +1054,8 @@ class MWMemcached {
                }
 
                if ( !$this->_connect_sock( $sock, $host ) ) {
-                       return $this->_dead_host( $host );
+                       $this->_dead_host( $host );
+                       return null;
                }
 
                // Do not buffer writes
@@ -1049,6 +1066,9 @@ class MWMemcached {
                return $this->_cache_sock[$host];
        }
 
+       /**
+        * @param $str string
+        */
        function _debugprint( $str ) {
                print( $str );
        }
@@ -1080,6 +1100,9 @@ class MWMemcached {
 
        /**
         * Original behaviour
+        * @param $f
+        * @param $buf
+        * @param $len bool
         * @return int
         */
        function _safe_fwrite( $f, $buf, $len = false ) {
@@ -1093,6 +1116,7 @@ class MWMemcached {
 
        /**
         * Flush the read buffer of a stream
+        * @param $f Resource
         */
        function _flush_read_buffer( $f ) {
                if ( !is_resource( $f ) ) {
index 854a9f1..d705b49 100644 (file)
@@ -3758,7 +3758,7 @@ class Language {
 
        /**
         * Decode an expiry (block, protection, etc) which has come from the DB
-        * 
+        *
         * @FIXME: why are we returnings DBMS-dependent strings???
         *
         * @param $expiry String: Database expiry String
index a40fb7a..22e8946 100644 (file)
@@ -41,11 +41,11 @@ class LanguageKaa extends Language {
        }
 
        /**
-        * It fixes issue with  lcfirst for transforming 'I' to 'ı'
+        * It fixes issue with lcfirst for transforming 'I' to 'ı'
         *
         * @param $string string
         *
-        * @return string
+        * @return mixed|string
         */
        function lcfirst ( $string ) {
                if ( substr( $string, 0, 1 ) === 'I' ) {
index 989f7bd..4f5889b 100644 (file)
@@ -74,7 +74,7 @@ class DeleteDefaultMessages extends Maintenance {
                        $dbw->commit( __METHOD__ );
                }
 
-               $this->output( 'done!\n', 'msg' );
+               $this->output( "done!\n", 'msg' );
        }
 }
 
index c83e01e..c089c31 100644 (file)
@@ -23,12 +23,12 @@ class LanguageTest extends MediaWikiTestCase {
                        'convertDoubleWidth() with the full alphabet and digits'
                );
        }
-       
+
        /** @dataProvider provideFormattableTimes */
        function testFormatTimePeriod( $seconds, $format, $expected, $desc ) {
                $this->assertEquals( $expected, $this->lang->formatTimePeriod( $seconds, $format ), $desc );
        }
-       
+
        function provideFormattableTimes() {
                return array(
                        array( 9.45, array(), '9.5s', 'formatTimePeriod() rounding (<10s)' ),
@@ -62,7 +62,7 @@ class LanguageTest extends MediaWikiTestCase {
                        array( 176460.55, array(), '2d 1h 1m 1s', 'formatTimePeriod() rounding, recursion, (>48h)' ),
                        array( 176460.55, array( 'noabbrevs' => true ), '2 days 1 hour 1 minute 1 second', 'formatTimePeriod() rounding, recursion, (>48h)' ),
                );
-               
+
        }
 
        function testTruncate() {
@@ -224,7 +224,7 @@ class LanguageTest extends MediaWikiTestCase {
                        "sprintfDate('$format', '$ts'): $msg"
                );
 
-               date_default_timezone_set( $oldTZ );            
+               date_default_timezone_set( $oldTZ );
        }
 
        function provideSprintfDateSamples() {