From: umherirrender Date: Tue, 8 Apr 2014 18:18:11 +0000 (+0200) Subject: Avoid using raw sql in SpecialUndelete.php X-Git-Tag: 1.31.0-rc.0~15519^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dcompta/operations/supprimer.php?a=commitdiff_plain;h=3938307eeab06dc72565b8da7bab4f92cc9948e7;p=lhc%2Fweb%2Fwiklou.git Avoid using raw sql in SpecialUndelete.php The where part for the ar_timestamp was raw sql. Refactored to avoid this. Now the IN-List is created by the database abstraction layer. The addQuotes and implode with comma is done there. Just the call to Database::timestamp is still needed. This also avoids a '1 = 1' in sql. Change-Id: I1deb055a1437ae84fc8a4e8cf2976e18c15bda39 --- diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 51235ee502..04b36c7fc4 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -492,15 +492,12 @@ class PageArchive { $previousTimestamp = 0; } - if ( $restoreAll ) { - $oldones = '1 = 1'; # All revisions... - } else { - $oldts = implode( ',', - array_map( array( &$dbw, 'addQuotes' ), - array_map( array( &$dbw, 'timestamp' ), - $timestamps ) ) ); - - $oldones = "ar_timestamp IN ( {$oldts} )"; + $oldWhere = array( + 'ar_namespace' => $this->title->getNamespace(), + 'ar_title' => $this->title->getDBkey(), + ); + if ( !$restoreAll ) { + $oldWhere['ar_timestamp'] = array_map( array( &$dbw, 'timestamp' ), $timestamps ); } $fields = array( @@ -529,10 +526,7 @@ class PageArchive { */ $result = $dbw->select( 'archive', $fields, - /* WHERE */ array( - 'ar_namespace' => $this->title->getNamespace(), - 'ar_title' => $this->title->getDBkey(), - $oldones ), + $oldWhere, __METHOD__, /* options */ array( 'ORDER BY' => 'ar_timestamp' ) ); @@ -618,10 +612,7 @@ class PageArchive { } # Now that it's safely stored, take it out of the archive $dbw->delete( 'archive', - /* WHERE */ array( - 'ar_namespace' => $this->title->getNamespace(), - 'ar_title' => $this->title->getDBkey(), - $oldones ), + $oldWhere, __METHOD__ ); // Was anything restored at all?