Clean up database access in revisiondelete
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 30 Jan 2009 00:15:19 +0000 (00:15 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 30 Jan 2009 00:15:19 +0000 (00:15 +0000)
includes/specials/SpecialRevisiondelete.php

index ed79ce8..c0247d8 100644 (file)
@@ -189,10 +189,11 @@ class RevisionDeleteForm {
                        foreach( $this->revisions as $revid ) {
                                $where[] = intval($revid);
                        }
-                       $whereClause = 'rev_id IN(' . implode(',',$where) . ')';
                        $result = $dbr->select( array('revision','page'), '*',
-                               array( 'rev_page' => $this->page->getArticleID(),
-                                       $whereClause, 'rev_page = page_id' ),
+                               array(
+                                       'rev_page' => $this->page->getArticleID(),
+                                       'rev_id' => $where,
+                                       'rev_page = page_id' ),
                                __METHOD__ );
                        while( $row = $dbr->fetchObject( $result ) ) {
                                $revObjs[$row->rev_id] = new Revision( $row );
@@ -219,11 +220,11 @@ class RevisionDeleteForm {
                        foreach( $this->archrevs as $timestamp ) {
                                $where[] = $dbr->addQuotes( $timestamp );
                        }
-                       $whereClause = 'ar_timestamp IN(' . implode(',',$where) . ')';
                        $result = $dbr->select( 'archive', '*',
-                               array( 'ar_namespace' => $this->page->getNamespace(),
+                               array(
+                                       'ar_namespace' => $this->page->getNamespace(),
                                        'ar_title' => $this->page->getDBKey(),
-                                               $whereClause ),
+                                       'ar_timestamp' => $where ),
                                __METHOD__ );
                        while( $row = $dbr->fetchObject( $result ) ) {
                                $revObjs[$row->ar_timestamp] = new Revision( array(
@@ -334,10 +335,10 @@ class RevisionDeleteForm {
                        foreach( $this->ofiles as $timestamp ) {
                                $where[] = $dbr->addQuotes( $timestamp.'!'.$this->page->getDBKey() );
                        }
-                       $whereClause = 'oi_archive_name IN(' . implode(',',$where) . ')';
                        $result = $dbr->select( 'oldimage', '*',
-                               array( 'oi_name' => $this->page->getDBKey(),
-                                       $whereClause ),
+                               array(
+                                       'oi_name' => $this->page->getDBKey(),
+                                       'oi_archive_name' => $where ),
                                __METHOD__ );
                        while( $row = $dbr->fetchObject( $result ) ) {
                                $filesObjs[$row->oi_archive_name] = RepoGroup::singleton()->getLocalRepo()->newFileFromRow( $row );
@@ -368,10 +369,10 @@ class RevisionDeleteForm {
                        foreach( $this->afiles as $id ) {
                                $where[] = intval($id);
                        }
-                       $whereClause = 'fa_id IN(' . implode(',',$where) . ')';
                        $result = $dbr->select( 'filearchive', '*',
-                               array( 'fa_name' => $this->page->getDBKey(),
-                                       $whereClause ),
+                               array(
+                                       'fa_name' => $this->page->getDBKey(),
+                                       'fa_id' => $where ),
                                __METHOD__ );
                        while( $row = $dbr->fetchObject( $result ) ) {
                                $filesObjs[$row->fa_id] = ArchivedFile::newFromRow( $row );
@@ -465,9 +466,10 @@ class RevisionDeleteForm {
                        $where[] = intval($logid);
                }
                list($log,$logtype) = explode( '/',$this->page->getDBKey(), 2 );
-               $whereClause = "log_type = '$logtype' AND log_id IN(" . implode(',',$where) . ")";
                $result = $dbr->select( 'logging', '*',
-                       array( $whereClause ),
+                       array(
+                               'log_type' => $logtype,
+                               'log_id' => $where ),
                        __METHOD__ );
                while( $row = $dbr->fetchObject( $result ) ) {
                        $logRows[$row->log_id] = $row;
@@ -818,10 +820,10 @@ class RevisionDeleter {
                foreach( $items as $revid ) {
                        $where[] = intval($revid);
                }
-               $whereClause = 'rev_id IN(' . implode(',',$where) . ')';
                $result = $this->dbw->select( 'revision', '*',
-                       array( 'rev_page' => $title->getArticleID(),
-                               $whereClause ),
+                       array(
+                               'rev_page' => $title->getArticleID(),
+                               'rev_id' => $where ),
                        __METHOD__ );
                while( $row = $this->dbw->fetchObject( $result ) ) {
                        $revObjs[$row->rev_id] = new Revision( $row );
@@ -877,11 +879,11 @@ class RevisionDeleter {
                foreach( $items as $timestamp ) {
                        $where[] = $this->dbw->addQuotes( $timestamp );
                }
-               $whereClause = 'ar_timestamp IN(' . implode(',',$where) . ')';
                $result = $this->dbw->select( 'archive', '*',
-                       array( 'ar_namespace' => $title->getNamespace(),
+                       array(
+                               'ar_namespace' => $title->getNamespace(),
                                'ar_title' => $title->getDBKey(),
-                                       $whereClause ),
+                               'ar_timestamp' => $where ),
                        __METHOD__ );
                while( $row = $this->dbw->fetchObject( $result ) ) {
                        $revObjs[$row->ar_timestamp] = new Revision( array(
@@ -947,10 +949,10 @@ class RevisionDeleter {
                foreach( $items as $timestamp ) {
                        $where[] = $this->dbw->addQuotes( $timestamp.'!'.$title->getDBKey() );
                }
-               $whereClause = 'oi_archive_name IN(' . implode(',',$where) . ')';
                $result = $this->dbw->select( 'oldimage', '*',
-                       array( 'oi_name' => $title->getDBKey(),
-                               $whereClause ),
+                       array(
+                               'oi_name' => $title->getDBKey(),
+                               'oi_archive_name' => $where ),
                        __METHOD__ );
                while( $row = $this->dbw->fetchObject( $result ) ) {
                        $filesObjs[$row->oi_archive_name] = RepoGroup::singleton()->getLocalRepo()->newFileFromRow( $row );
@@ -1040,10 +1042,9 @@ class RevisionDeleter {
                foreach( $items as $id ) {
                        $where[] = intval($id);
                }
-               $whereClause = 'fa_id IN(' . implode(',',$where) . ')';
                $result = $this->dbw->select( 'filearchive', '*',
                        array( 'fa_name' => $title->getDBKey(),
-                               $whereClause ),
+                               'fa_id' => $where ),
                        __METHOD__ );
                while( $row = $this->dbw->fetchObject( $result ) ) {
                        $filesObjs[$row->fa_id] = ArchivedFile::newFromRow( $row );
@@ -1097,9 +1098,10 @@ class RevisionDeleter {
                        $where[] = intval($logid);
                }
                list($log,$logtype) = explode( '/',$title->getDBKey(), 2 );
-               $whereClause = "log_type ='$logtype' AND log_id IN(" . implode(',',$where) . ")";
                $result = $this->dbw->select( 'logging', '*',
-                       array( $whereClause ),
+                       array(
+                               'log_type' => $logtype,
+                               'log_id' => $where ),
                        __METHOD__ );
                while( $row = $this->dbw->fetchObject( $result ) ) {
                        $logRows[$row->log_id] = $row;