Merge "SquidUpdate doc cleanups"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 19 Nov 2015 07:23:53 +0000 (07:23 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 19 Nov 2015 07:23:53 +0000 (07:23 +0000)
includes/db/DatabaseMysqlBase.php
includes/db/DatabaseOracle.php
includes/db/loadbalancer/LoadMonitorMySQL.php
includes/filerepo/file/File.php
includes/gallery/TraditionalImageGallery.php
includes/installer/PostgresUpdater.php
includes/parser/LinkHolderArray.php
maintenance/namespaceDupes.php
tests/phpunit/includes/db/DatabaseSqliteTest.php
tests/phpunit/includes/parser/NewParserTest.php

index 38aae58..a839314 100644 (file)
@@ -722,10 +722,13 @@ abstract class DatabaseMysqlBase extends Database {
                $res = $this->doQuery( $sql );
 
                $status = false;
-               if ( $res && $row = $this->fetchRow( $res ) ) {
-                       $status = $row[0]; // can be NULL, -1, or 0+ per the MySQL manual
-                       if ( ctype_digit( $status ) ) { // success
-                               $this->lastKnownSlavePos = $pos;
+               if ( $res ) {
+                       $row = $this->fetchRow( $res );
+                       if ( $row ) {
+                               $status = $row[0]; // can be NULL, -1, or 0+ per the MySQL manual
+                               if ( ctype_digit( $status ) ) { // success
+                                       $this->lastKnownSlavePos = $pos;
+                               }
                        }
                }
 
index 66004ec..a3d7c1b 100644 (file)
@@ -395,7 +395,8 @@ class DatabaseOracle extends Database {
 
                MediaWiki\suppressWarnings();
 
-               if ( ( $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql ) ) === false ) {
+               $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql );
+               if ( $stmt === false ) {
                        $e = oci_error( $this->mConn );
                        $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
 
@@ -637,7 +638,8 @@ class DatabaseOracle extends Database {
                }
                $sql .= ')';
 
-               if ( ( $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql ) ) === false ) {
+               $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql );
+               if ( $stmt === false ) {
                        $e = oci_error( $this->mConn );
                        $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
 
@@ -668,7 +670,8 @@ class DatabaseOracle extends Database {
                                }
                        } else {
                                /** @var OCI_Lob[] $lob */
-                               if ( ( $lob[$col] = oci_new_descriptor( $this->mConn, OCI_D_LOB ) ) === false ) {
+                               $lob[$col] = oci_new_descriptor( $this->mConn, OCI_D_LOB );
+                               if ( $lob[$col] === false ) {
                                        $e = oci_error( $stmt );
                                        throw new DBUnexpectedError( $this, "Cannot create LOB descriptor: " . $e['message'] );
                                }
@@ -731,7 +734,8 @@ class DatabaseOracle extends Database {
                        $srcTable = $this->tableName( $srcTable );
                }
 
-               if ( ( $sequenceData = $this->getSequenceData( $destTable ) ) !== false &&
+               $sequenceData = $this->getSequenceData( $destTable );
+               if ( $sequenceData !== false &&
                        !isset( $varMap[$sequenceData['column']] )
                ) {
                        $varMap[$sequenceData['column']] = 'GET_SEQUENCE_VALUE(\'' . $sequenceData['sequence'] . '\')';
@@ -987,7 +991,8 @@ class DatabaseOracle extends Database {
                        'SELECT version FROM product_component_version ' .
                                'WHERE UPPER(product) LIKE \'ORACLE DATABASE%\''
                );
-               if ( !( $row = $rset->fetchRow() ) ) {
+               $row = $rset->fetchRow();
+               if ( !$row ) {
                        return oci_server_version( $this->mConn );
                }
 
@@ -1428,7 +1433,8 @@ class DatabaseOracle extends Database {
                        $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND );
                }
 
-               if ( ( $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql ) ) === false ) {
+               $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql );
+               if ( $stmt === false ) {
                        $e = oci_error( $this->mConn );
                        $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
 
@@ -1458,7 +1464,8 @@ class DatabaseOracle extends Database {
                                }
                        } else {
                                /** @var OCI_Lob[] $lob */
-                               if ( ( $lob[$col] = oci_new_descriptor( $this->mConn, OCI_D_LOB ) ) === false ) {
+                               $lob[$col] = oci_new_descriptor( $this->mConn, OCI_D_LOB );
+                               if ( $lob[$col] === false ) {
                                        $e = oci_error( $stmt );
                                        throw new DBUnexpectedError( $this, "Cannot create LOB descriptor: " . $e['message'] );
                                }
index 39077c2..31f6163 100644 (file)
@@ -90,9 +90,15 @@ class LoadMonitorMySQL implements LoadMonitor {
                foreach ( $serverIndexes as $i ) {
                        if ( $i == 0 ) { # Master
                                $lagTimes[$i] = 0;
-                       } elseif ( false !== ( $conn = $this->parent->getAnyOpenConnection( $i ) ) ) {
+                               continue;
+                       }
+                       $conn = $this->parent->getAnyOpenConnection( $i );
+                       if ( $conn !== false ) {
                                $lagTimes[$i] = $conn->getLag();
-                       } elseif ( false !== ( $conn = $this->parent->openConnection( $i, $wiki ) ) ) {
+                               continue;
+                       }
+                       $conn = $this->parent->openConnection( $i, $wiki );
+                       if ( $conn !== false ) {
                                $lagTimes[$i] = $conn->getLag();
                                # Close the connection to avoid sleeper connections piling up.
                                # Note that the caller will pick one of these DBs and reconnect,
index ee11df9..72f12d1 100644 (file)
@@ -1176,8 +1176,13 @@ abstract class File implements IDBAccessObject {
                if ( !$this->repo
                        || !isset( $params['physicalWidth'] )
                        || !isset( $params['physicalHeight'] )
-                       || !( $bucket = $this->getThumbnailBucket( $params['physicalWidth'] ) )
-                       || $bucket == $params['physicalWidth'] ) {
+               ) {
+                       return false;
+               }
+
+               $bucket = $this->getThumbnailBucket( $params['physicalWidth'] );
+
+               if ( !$bucket || $bucket == $params['physicalWidth'] ) {
                        return false;
                }
 
index 181c7b8..d2f7417 100644 (file)
@@ -111,48 +111,51 @@ class TraditionalImageGallery extends ImageGalleryBase {
                                                htmlspecialchars( $nt->getText() )
                                        ) .
                                        '</div>';
-                       } elseif ( !( $thumb = $img->transform( $transformOptions ) ) ) {
-                               # Error generating thumbnail.
-                               $thumbhtml = "\n\t\t\t" . '<div class="thumb" style="height: '
-                                       . ( $this->getThumbPadding() + $this->mHeights ) . 'px;">'
-                                       . htmlspecialchars( $img->getLastError() ) . '</div>';
                        } else {
-                               /** @var MediaTransformOutput $thumb */
-                               $vpad = $this->getVPad( $this->mHeights, $thumb->getHeight() );
-
-                               $imageParameters = array(
-                                       'desc-link' => true,
-                                       'desc-query' => $descQuery,
-                                       'alt' => $alt,
-                                       'custom-url-link' => $link
-                               );
-
-                               // In the absence of both alt text and caption, fall back on
-                               // providing screen readers with the filename as alt text
-                               if ( $alt == '' && $text == '' ) {
-                                       $imageParameters['alt'] = $nt->getText();
-                               }
-
-                               $this->adjustImageParameters( $thumb, $imageParameters );
-
-                               Linker::processResponsiveImages( $img, $thumb, $transformOptions );
-
-                               # Set both fixed width and min-height.
-                               $thumbhtml = "\n\t\t\t"
-                                       . '<div class="thumb" style="width: '
-                                       . $this->getThumbDivWidth( $thumb->getWidth() ) . 'px;">'
-                                       # Auto-margin centering for block-level elements. Needed
-                                       # now that we have video handlers since they may emit block-
-                                       # level elements as opposed to simple <img> tags. ref
-                                       # http://css-discuss.incutio.com/?page=CenteringBlockElement
-                                       . '<div style="margin:' . $vpad . 'px auto;">'
-                                       . $thumb->toHtml( $imageParameters ) . '</div></div>';
-
-                               // Call parser transform hook
-                               /** @var MediaHandler $handler */
-                               $handler = $img->getHandler();
-                               if ( $this->mParser && $handler ) {
-                                       $handler->parserTransformHook( $this->mParser, $img );
+                               $thumb = $img->transform( $transformOptions );
+                               if ( !$thumb ) {
+                                       # Error generating thumbnail.
+                                       $thumbhtml = "\n\t\t\t" . '<div class="thumb" style="height: '
+                                               . ( $this->getThumbPadding() + $this->mHeights ) . 'px;">'
+                                               . htmlspecialchars( $img->getLastError() ) . '</div>';
+                               } else {
+                                       /** @var MediaTransformOutput $thumb */
+                                       $vpad = $this->getVPad( $this->mHeights, $thumb->getHeight() );
+
+                                       $imageParameters = array(
+                                               'desc-link' => true,
+                                               'desc-query' => $descQuery,
+                                               'alt' => $alt,
+                                               'custom-url-link' => $link
+                                       );
+
+                                       // In the absence of both alt text and caption, fall back on
+                                       // providing screen readers with the filename as alt text
+                                       if ( $alt == '' && $text == '' ) {
+                                               $imageParameters['alt'] = $nt->getText();
+                                       }
+
+                                       $this->adjustImageParameters( $thumb, $imageParameters );
+
+                                       Linker::processResponsiveImages( $img, $thumb, $transformOptions );
+
+                                       # Set both fixed width and min-height.
+                                       $thumbhtml = "\n\t\t\t"
+                                               . '<div class="thumb" style="width: '
+                                               . $this->getThumbDivWidth( $thumb->getWidth() ) . 'px;">'
+                                               # Auto-margin centering for block-level elements. Needed
+                                               # now that we have video handlers since they may emit block-
+                                               # level elements as opposed to simple <img> tags. ref
+                                               # http://css-discuss.incutio.com/?page=CenteringBlockElement
+                                               . '<div style="margin:' . $vpad . 'px auto;">'
+                                               . $thumb->toHtml( $imageParameters ) . '</div></div>';
+
+                                       // Call parser transform hook
+                                       /** @var MediaHandler $handler */
+                                       $handler = $img->getHandler();
+                                       if ( $this->mParser && $handler ) {
+                                               $handler->parserTransformHook( $this->mParser, $img );
+                                       }
                                }
                        }
 
index 7414d92..87e6566 100644 (file)
@@ -512,7 +512,8 @@ END;
                if ( !$res ) {
                        return null;
                }
-               if ( !( $r = $this->db->fetchRow( $res ) ) ) {
+               $r = $this->db->fetchRow( $res );
+               if ( !$r ) {
                        return null;
                }
 
@@ -532,7 +533,8 @@ END;
                        if ( !$r2 ) {
                                return null;
                        }
-                       if ( !( $row2 = $this->db->fetchRow( $r2 ) ) ) {
+                       $row2 = $this->db->fetchRow( $r2 );
+                       if ( !$row2 ) {
                                return null;
                        }
                        $colnames[] = $row2[0];
@@ -555,7 +557,8 @@ END;
                                $this->db->addQuotes( $fkey )
                        )
                );
-               if ( !( $row = $this->db->fetchRow( $r ) ) ) {
+               $row = $this->db->fetchRow( $r );
+               if ( !$row ) {
                        return null;
                }
 
index 41b5dec..6329fd7 100644 (file)
@@ -315,15 +315,18 @@ class LinkHolderArray {
                                        $colours[$pdbk] = '';
                                } elseif ( $ns == NS_SPECIAL ) {
                                        $colours[$pdbk] = 'new';
-                               } elseif ( ( $id = $linkCache->getGoodLinkID( $pdbk ) ) != 0 ) {
-                                       $colours[$pdbk] = Linker::getLinkColour( $title, $threshold );
-                                       $output->addLink( $title, $id );
-                                       $linkcolour_ids[$id] = $pdbk;
-                               } elseif ( $linkCache->isBadLink( $pdbk ) ) {
-                                       $colours[$pdbk] = 'new';
                                } else {
-                                       # Not in the link cache, add it to the query
-                                       $queries[$ns][] = $title->getDBkey();
+                                       $id = $linkCache->getGoodLinkID( $pdbk );
+                                       if ( $id != 0 ) {
+                                               $colours[$pdbk] = Linker::getLinkColour( $title, $threshold );
+                                               $output->addLink( $title, $id );
+                                               $linkcolour_ids[$id] = $pdbk;
+                                       } elseif ( $linkCache->isBadLink( $pdbk ) ) {
+                                               $colours[$pdbk] = 'new';
+                                       } else {
+                                               # Not in the link cache, add it to the query
+                                               $queries[$ns][] = $title->getDBkey();
+                                       }
                                }
                        }
                }
index 184cba8..28176a5 100644 (file)
@@ -390,7 +390,8 @@ class NamespaceConflictChecker extends Maintenance {
                                                $titleField => $row->$titleField,
                                                $fromField => $row->$fromField
                                        ),
-                                       __METHOD__
+                                       __METHOD__,
+                                       array( 'IGNORE' )
                                );
                                $this->output( "$table $logTitle -> " .
                                        $destTitle->getPrefixedDBkey() . "\n" );
index 0db7af9..c742f74 100644 (file)
@@ -100,7 +100,8 @@ class DatabaseSqliteTest extends MediaWikiTestCase {
 
                $this->assertTrue( $re !== false, 'query failed' );
 
-               if ( $row = $re->fetchRow() ) {
+               $row = $re->fetchRow();
+               if ( $row ) {
                        if ( $value instanceof Blob ) {
                                $value = $value->fetch();
                        }
index ff4a527..f7c428a 100644 (file)
@@ -640,11 +640,12 @@ class NewParserTest extends MediaWikiTestCase {
                        $backend->delete( array( 'src' => $file ), array( 'force' => 1 ) );
                }
                foreach ( $files as $file ) {
-                       $tmp = $file;
-                       while ( $tmp = FileBackend::parentStoragePath( $tmp ) ) {
+                       $tmp = FileBackend::parentStoragePath( $file );
+                       while ( $tmp ) {
                                if ( !$backend->clean( array( 'dir' => $tmp ) )->isOK() ) {
                                        break;
                                }
+                               $tmp = FileBackend::parentStoragePath( $tmp );
                        }
                }
        }