private $mAllPages; // [ns][dbkey] => page_id or 0 when missing
private $mGoodTitles, $mMissingTitles, $mMissingPageIDs, $mRedirectTitles, $mNormalizedTitles;
private $mResolveRedirects, $mPendingRedirectIDs;
+ private $mGoodRevIDs, $mMissingRevIDs;
private $mRequestedPageFields;
$this->mMissingPageIDs = array ();
$this->mRedirectTitles = array ();
$this->mNormalizedTitles = array ();
+ $this->mGoodRevIDs = array();
+ $this->mMissingRevIDs = array();
$this->mRequestedPageFields = array ();
$this->mResolveRedirects = $resolveRedirects;
/**
* Get the list of revision IDs (requested with revids= parameter)
+ * @return array revID (int) => pageID (int)
*/
public function getRevisionIDs() {
- $this->dieUsage(__METHOD__ . ' is not implemented', 'notimplemented');
+ return $this->mGoodRevIDs;
+ }
+
+ /**
+ * Revision IDs that were not found in the database
+ * @return array of revision IDs
+ */
+ public function getMissingRevisionIDs() {
+ return $this->mMissingRevIDs;
}
/**
* Returns the number of revisions (requested with revids= parameter)
*/
public function getRevisionCount() {
- return 0; // TODO: implement
+ return count($this->getRevisionIDs());
}
/**
$this->initFromPageIds($pageids);
break;
case 'revids' :
+ if($this->mResolveRedirects)
+ $this->dieUsage('revids may not be used with redirect resolution', 'params');
$this->initFromRevIDs($revids);
break;
default :
}
private function initFromRevIDs($revids) {
- $this->dieUsage(__METHOD__ . ' is not implemented', 'notimplemented');
+
+ $db = $this->getDB();
+ $pageids = array();
+ $remaining = array_flip($revids);
+
+ $tables = array('page', 'revision');
+ $fields = array('rev_id','rev_page');
+ $where = array( 'rev_deleted' => 0, 'rev_id' => $revids );
+
+ // Get pageIDs data from the `page` table
+ $this->profileDBIn();
+ $res = $db->select( $tables, $fields, $where, __METHOD__ );
+ while ( $row = $db->fetchObject( $res ) ) {
+ $revid = intval($row->rev_id);
+ $pageid = intval($row->rev_page);
+ $this->mGoodRevIDs[$revid] = $pageid;
+ $pageids[$pageid] = '';
+ unset($remaining[$revid]);
+ }
+ $db->freeResult( $res );
+ $this->profileDBOut();
+
+ $this->mMissingRevIDs = array_keys($remaining);
+
+ // Populate all the page information
+ if($this->mResolveRedirects)
+ $this->dieDebug('revids may not be used with redirect resolution');
+ $pageids = array_keys($pageids);
+ if(!empty($pageids))
+ $this->initFromPageIds($pageids);
}
private function resolvePendingRedirects() {
if ($revCount === 0 && $pageCount === 0)
return;
- if ($revCount > 0 && $pageCount > 0)
- $this->dieUsage('The revids= parameter may not be used with titles, pageids, or generator options.', 'revids');
-
if ($revCount > 0 && $enumRevMode)
$this->dieUsage('The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).', 'revids');
- if ($revCount === 0 && $pageCount > 1 && $enumRevMode)
+ if ($pageCount > 1 && $enumRevMode)
$this->dieUsage('titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, start, and end parameters may only be used on a single page.', 'multpages');
$tables = array (