From: Aaron Schulz Date: Sat, 2 Jul 2011 09:30:55 +0000 (+0000) Subject: Added filterByIds() function to Rev_List and made ID based filtering optional. It... X-Git-Tag: 1.31.0-rc.0~29106 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=2b3af1695ef4c3c3a179780e508d027f774be233;p=lhc%2Fweb%2Fwiklou.git Added filterByIds() function to Rev_List and made ID based filtering optional. It's still mandatory for RevDel_List however. --- 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.