Replace more problematic uses of "SELECT *"
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 13 Sep 2017 12:13:02 +0000 (08:13 -0400)
committerAnomie <bjorsch@wikimedia.org>
Wed, 13 Sep 2017 13:09:51 +0000 (13:09 +0000)
With the introduction of CommentStore, selects from various table
require certain joins or column aliases for proper operation.

Change-Id: I2ecb6030bf253664c3227d69b5ed2277596a83f0

includes/diff/DifferenceEngine.php
includes/filerepo/file/LocalFile.php

index 34f2852..ed8cbb4 100644 (file)
@@ -181,7 +181,8 @@ class DifferenceEngine extends ContextSource {
        public function deletedLink( $id ) {
                if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
                        $dbr = wfGetDB( DB_REPLICA );
-                       $row = $dbr->selectRow( 'archive', '*',
+                       $row = $dbr->selectRow( 'archive',
+                               Revision::selectArchiveFields(),
                                [ 'ar_rev_id' => $id ],
                                __METHOD__ );
                        if ( $row ) {
index 8aea7ab..96e7a7e 100644 (file)
@@ -1129,11 +1129,9 @@ class LocalFile extends File {
 
                if ( $this->historyLine == 0 ) { // called for the first time, return line from cur
                        $this->historyRes = $dbr->select( 'image',
-                               [
-                                       '*',
-                                       "'' AS oi_archive_name",
-                                       '0 as oi_deleted',
-                                       'img_sha1'
+                               self::selectFields() + [
+                                       'oi_archive_name' => $dbr->addQuotes( '' ),
+                                       'oi_deleted' => 0,
                                ],
                                [ 'img_name' => $this->title->getDBkey() ],
                                $fname
@@ -1145,7 +1143,9 @@ class LocalFile extends File {
                                return false;
                        }
                } elseif ( $this->historyLine == 1 ) {
-                       $this->historyRes = $dbr->select( 'oldimage', '*',
+                       $this->historyRes = $dbr->select(
+                               'oldimage',
+                               OldLocalFile::selectFields(),
                                [ 'oi_name' => $this->title->getDBkey() ],
                                $fname,
                                [ 'ORDER BY' => 'oi_timestamp DESC' ]