From: jenkins-bot Date: Thu, 22 Sep 2016 21:29:44 +0000 (+0000) Subject: Merge "Break long lines and generalize some comments in /rdbms" X-Git-Tag: 1.31.0-rc.0~5380 X-Git-Url: http://git.cyclocoop.org//%22%22.str_replace%28%27%22%27%2C?a=commitdiff_plain;h=26c0ffd8dd7c59b2996e163377bbc3de397e7c9c;hp=-c;p=lhc%2Fweb%2Fwiklou.git Merge "Break long lines and generalize some comments in /rdbms" --- 26c0ffd8dd7c59b2996e163377bbc3de397e7c9c diff --combined includes/libs/rdbms/database/Database.php index bf3a5f0002,f81c8dcdd2..d58ffdf2a6 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@@ -1249,19 -1249,24 +1249,24 @@@ abstract class Database implements IDat $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 +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 +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; } @@@ -1964,7 -1971,18 +1971,7 @@@ * @return string */ protected function indexName( $index ) { - // Backwards-compatibility hack - $renamed = [ - 'ar_usertext_timestamp' => 'usertext_timestamp', - 'un_user_id' => 'user_id', - 'un_user_ip' => 'user_ip', - ]; - - if ( isset( $renamed[$index] ) ) { - return $renamed[$index]; - } else { - return $index; - } + return $index; } public function addQuotes( $s ) { @@@ -2338,7 -2356,8 +2345,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 "; @@@ -2795,7 -2814,8 +2803,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 @@@ -3148,7 -3168,11 +3157,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' ); @@@ -3163,7 -3187,8 +3176,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; @@@ -3191,8 -3216,12 +3205,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 = ''; @@@ -3222,7 -3251,7 +3240,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 ) { @@@ -3252,7 -3281,8 +3270,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; } @@@ -3502,8 -3532,7 +3521,8 @@@ // Open a new connection resource without messing with the old one $this->mOpened = false; $this->mConn = false; - $this->mTrxLevel = 0; // no trx anymore + $this->mTrxEndCallbacks = []; // don't copy + $this->handleSessionLoss(); // no trx or locks anymore $this->open( $this->mServer, $this->mUser, $this->mPassword, $this->mDBname ); $this->lastPing = microtime( true ); }