From 2b3af1695ef4c3c3a179780e508d027f774be233 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 2 Jul 2011 09:30:55 +0000 Subject: [PATCH] Added filterByIds() function to Rev_List and made ID based filtering optional. It's still mandatory for RevDel_List however. --- includes/RevisionList.php | 32 ++++++++++++++----- .../RevisionDeleteAbstracts.php | 5 +++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/includes/RevisionList.php b/includes/RevisionList.php index e64ac5a471..baeaedfbae 100644 --- a/includes/RevisionList.php +++ b/includes/RevisionList.php @@ -14,9 +14,21 @@ abstract class Rev_List { var $ids, $res, $current; - function __construct( RequestContext $context, Title $title, array $ids ) { + /** + * Construct a revision list for a given title + * @param $context RequestContext + * @param $title Title + */ + function __construct( RequestContext $context, Title $title ) { $this->context = $context; $this->title = $title; + } + + /** + * Select items only where the ID is any of the specified values + * @param $ids Array + */ + function filterByIds( array $ids ) { $this->ids = $ids; } @@ -238,13 +250,17 @@ class RevisionList extends Rev_List { * @return mixed */ public function doQuery( $db ) { - $ids = array_map( 'intval', $this->ids ); - return $db->select( array('revision','page'), '*', - array( - 'rev_page' => $this->title->getArticleID(), - 'rev_id' => array_map( 'intval', $this->ids ), - 'rev_page = page_id' - ), + $conds = array( + 'rev_page' => $this->title->getArticleID(), + 'rev_page = page_id' + ); + if ( $this->ids !== null ) { + $conds['rev_id'] = array_map( 'intval', $this->ids ); + } + return $db->select( + array( 'revision', 'page' ), + '*', + $conds, __METHOD__, array( 'ORDER BY' => 'rev_id DESC' ) ); diff --git a/includes/revisiondelete/RevisionDeleteAbstracts.php b/includes/revisiondelete/RevisionDeleteAbstracts.php index de39053722..2a1236b9f1 100644 --- a/includes/revisiondelete/RevisionDeleteAbstracts.php +++ b/includes/revisiondelete/RevisionDeleteAbstracts.php @@ -7,6 +7,11 @@ * to wrap bulk update operations. */ abstract class RevDel_List extends Rev_List { + function __construct( RequestContext $context, Title $title, array $ids ) { + parent::__construct( $context, $title ); + $this->ids = $ids; + } + /** * Get the DB field name associated with the ID list. * This used to populate the log_search table for finding log entries. -- 2.20.1