Aaron Schulz has uploaded a new change for review.

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

Change subject: Break long lines and generalize some comments in /rdbms
......................................................................

Break long lines and generalize some comments in /rdbms

Change-Id: Ibf80c67b59df748e98d74eeab492b1f33d198024
---
M includes/libs/rdbms/database/Database.php
M includes/libs/rdbms/database/IDatabase.php
M includes/libs/rdbms/database/resultwrapper/MssqlResultWrapper.php
M includes/libs/rdbms/exception/DBAccessError.php
4 files changed, 40 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/38/312338/1

diff --git a/includes/libs/rdbms/database/Database.php 
b/includes/libs/rdbms/database/Database.php
index 0bd1e9e..f81c8dc 100644
--- a/includes/libs/rdbms/database/Database.php
+++ b/includes/libs/rdbms/database/Database.php
@@ -1249,19 +1249,24 @@
                $useIndexes = ( isset( $options['USE INDEX'] ) && is_array( 
$options['USE INDEX'] ) )
                        ? $options['USE INDEX']
                        : [];
-               $ignoreIndexes = ( isset( $options['IGNORE INDEX'] ) && 
is_array( $options['IGNORE INDEX'] ) )
+               $ignoreIndexes = (
+                       isset( $options['IGNORE INDEX'] ) &&
+                       is_array( $options['IGNORE INDEX'] )
+               )
                        ? $options['IGNORE INDEX']
                        : [];
 
                if ( is_array( $table ) ) {
                        $from = ' FROM ' .
-                               $this->tableNamesWithIndexClauseOrJOIN( $table, 
$useIndexes, $ignoreIndexes, $join_conds );
+                               $this->tableNamesWithIndexClauseOrJOIN(
+                                       $table, $useIndexes, $ignoreIndexes, 
$join_conds );
                } elseif ( $table != '' ) {
                        if ( $table[0] == ' ' ) {
                                $from = ' FROM ' . $table;
                        } else {
                                $from = ' FROM ' .
-                                       $this->tableNamesWithIndexClauseOrJOIN( 
[ $table ], $useIndexes, $ignoreIndexes, [] );
+                                       $this->tableNamesWithIndexClauseOrJOIN(
+                                               [ $table ], $useIndexes, 
$ignoreIndexes, [] );
                        }
                } else {
                        $from = '';
@@ -1274,7 +1279,8 @@
                        if ( is_array( $conds ) ) {
                                $conds = $this->makeList( $conds, 
self::LIST_AND );
                        }
-                       $sql = "SELECT $startOpts $vars $from $useIndex 
$ignoreIndex WHERE $conds $preLimitTail";
+                       $sql = "SELECT $startOpts $vars $from $useIndex 
$ignoreIndex " .
+                               "WHERE $conds $preLimitTail";
                } else {
                        $sql = "SELECT $startOpts $vars $from $useIndex 
$ignoreIndex $preLimitTail";
                }
@@ -1915,7 +1921,8 @@
                                        }
                                }
                                if ( isset( $ignore_index[$alias] ) ) { // has 
IGNORE INDEX?
-                                       $ignore = $this->ignoreIndexClause( 
implode( ',', (array)$ignore_index[$alias] ) );
+                                       $ignore = $this->ignoreIndexClause(
+                                               implode( ',', 
(array)$ignore_index[$alias] ) );
                                        if ( $ignore != '' ) {
                                                $tableClause .= ' ' . $ignore;
                                        }
@@ -2349,7 +2356,8 @@
                        $srcTable = $this->tableName( $srcTable );
                }
 
-               $sql = "INSERT $insertOptions INTO $destTable (" . implode( 
',', array_keys( $varMap ) ) . ')' .
+               $sql = "INSERT $insertOptions" .
+                       " INTO $destTable (" . implode( ',', array_keys( 
$varMap ) ) . ')' .
                        " SELECT $startOpts " . implode( ',', $varMap ) .
                        " FROM $srcTable $useIndex $ignoreIndex ";
 
@@ -2806,7 +2814,8 @@
                        }
                } else {
                        if ( !$this->mTrxLevel ) {
-                               $this->queryLogger->error( "$fname: No 
transaction to commit, something got out of sync." );
+                               $this->queryLogger->error(
+                                       "$fname: No transaction to commit, 
something got out of sync." );
                                return; // nothing to do
                        } elseif ( $this->mTrxAutomatic ) {
                                // @TODO: make this an exception at some point
@@ -3159,7 +3168,11 @@
         * @throws Exception
         */
        public function sourceFile(
-               $filename, $lineCallback = false, $resultCallback = false, 
$fname = false, $inputCallback = false
+               $filename,
+               $lineCallback = false,
+               $resultCallback = false,
+               $fname = false,
+               $inputCallback = false
        ) {
                MediaWiki\suppressWarnings();
                $fp = fopen( $filename, 'r' );
@@ -3174,7 +3187,8 @@
                }
 
                try {
-                       $error = $this->sourceStream( $fp, $lineCallback, 
$resultCallback, $fname, $inputCallback );
+                       $error = $this->sourceStream(
+                               $fp, $lineCallback, $resultCallback, $fname, 
$inputCallback );
                } catch ( Exception $e ) {
                        fclose( $fp );
                        throw $e;
@@ -3202,8 +3216,12 @@
         * @param bool|callable $inputCallback Optional function called for 
each complete query sent
         * @return bool|string
         */
-       public function sourceStream( $fp, $lineCallback = false, 
$resultCallback = false,
-               $fname = __METHOD__, $inputCallback = false
+       public function sourceStream(
+               $fp,
+               $lineCallback = false,
+               $resultCallback = false,
+               $fname = __METHOD__,
+               $inputCallback = false
        ) {
                $cmd = '';
 
@@ -3233,7 +3251,7 @@
                        if ( $done || feof( $fp ) ) {
                                $cmd = $this->replaceVars( $cmd );
 
-                               if ( ( $inputCallback && call_user_func( 
$inputCallback, $cmd ) ) || !$inputCallback ) {
+                               if ( !$inputCallback || call_user_func( 
$inputCallback, $cmd ) ) {
                                        $res = $this->query( $cmd, $fname );
 
                                        if ( $resultCallback ) {
@@ -3263,7 +3281,8 @@
        public function streamStatementEnd( &$sql, &$newLine ) {
                if ( $this->delimiter ) {
                        $prev = $newLine;
-                       $newLine = preg_replace( '/' . preg_quote( 
$this->delimiter, '/' ) . '$/', '', $newLine );
+                       $newLine = preg_replace(
+                               '/' . preg_quote( $this->delimiter, '/' ) . 
'$/', '', $newLine );
                        if ( $newLine != $prev ) {
                                return true;
                        }
diff --git a/includes/libs/rdbms/database/IDatabase.php 
b/includes/libs/rdbms/database/IDatabase.php
index 21ffa8d..56eb002 100644
--- a/includes/libs/rdbms/database/IDatabase.php
+++ b/includes/libs/rdbms/database/IDatabase.php
@@ -84,15 +84,14 @@
        public function getServerInfo();
 
        /**
-        * Turns buffering of SQL result sets on (true) or off (false). Default 
is
-        * "on".
+        * Turns buffering of SQL result sets on (true) or off (false). Default 
is "on".
         *
         * Unbuffered queries are very troublesome in MySQL:
         *
         *   - If another query is executed while the first query is being read
         *     out, the first query is killed. This means you can't call normal
-        *     MediaWiki functions while you are reading an unbuffered query 
result
-        *     from a normal wfGetDB() connection.
+        *     Database functions while you are reading an unbuffered query 
result
+        *     from a normal Database connection.
         *
         *   - Unbuffered queries cause the MySQL server to use large amounts of
         *     memory and to hold broad locks which block other queries.
@@ -657,7 +656,7 @@
         *
         *   - OFFSET: Skip this many rows at the start of the result set. 
OFFSET
         *     with LIMIT can theoretically be used for paging through a result 
set,
-        *     but this is discouraged in MediaWiki for performance reasons.
+        *     but this is discouraged for performance reasons.
         *
         *   - LIMIT: Integer: return at most this many rows. The rows are 
sorted
         *     and then the first rows are taken until the limit is reached. 
LIMIT
@@ -1404,10 +1403,7 @@
         * The goal of this function is to create an atomic section of SQL 
queries
         * without having to start a new transaction if it already exists.
         *
-        * Atomic sections are more strict than transactions. With transactions,
-        * attempting to begin a new transaction when one is already running 
results
-        * in MediaWiki issuing a brief warning and doing an implicit commit. 
All
-        * atomic levels *must* be explicitly closed using 
IDatabase::endAtomic(),
+        * All atomic levels *must* be explicitly closed using 
IDatabase::endAtomic(),
         * and any database transactions cannot be began or committed until all 
atomic
         * levels are closed. There is no such thing as implicitly opening or 
closing
         * an atomic section.
diff --git a/includes/libs/rdbms/database/resultwrapper/MssqlResultWrapper.php 
b/includes/libs/rdbms/database/resultwrapper/MssqlResultWrapper.php
index 768511b..b591f4f 100644
--- a/includes/libs/rdbms/database/resultwrapper/MssqlResultWrapper.php
+++ b/includes/libs/rdbms/database/resultwrapper/MssqlResultWrapper.php
@@ -17,7 +17,7 @@
                        $result = sqlsrv_fetch_object( $res );
                }
 
-               // MediaWiki expects us to return boolean false when there are 
no more rows instead of null
+               // Return boolean false when there are no more rows instead of 
null
                if ( $result === null ) {
                        return false;
                }
@@ -39,7 +39,7 @@
                        $result = sqlsrv_fetch_array( $res );
                }
 
-               // MediaWiki expects us to return boolean false when there are 
no more rows instead of null
+               // Return boolean false when there are no more rows instead of 
null
                if ( $result === null ) {
                        return false;
                }
diff --git a/includes/libs/rdbms/exception/DBAccessError.php 
b/includes/libs/rdbms/exception/DBAccessError.php
index 7971dba..c00082c 100644
--- a/includes/libs/rdbms/exception/DBAccessError.php
+++ b/includes/libs/rdbms/exception/DBAccessError.php
@@ -25,8 +25,6 @@
  */
 class DBAccessError extends DBUnexpectedError {
        public function __construct() {
-               parent::__construct( "Mediawiki tried to access the database 
via wfGetDB(). " .
-                       "This is not allowed, because database access has been 
disabled." );
+               parent::__construct( "Database access has been disabled." );
        }
 }
-

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibf80c67b59df748e98d74eeab492b1f33d198024
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>

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

Reply via email to