- var $rev2date;
- var $date2ref;
-
- # Reads all revision information of the specified article
- function prepareRevisions( $id ) {
- global $wgDBprefix;
- $this->rev2date = array();
- $this->date2rev = array();
- $sql = "SELECT * FROM {$wgDBprefix}revision WHERE rev_page='{$id}'";
- $res = wfQuery( $sql, DB_READ );
- while( $x = wfFetchObject( $res ) ) {
- $this->rev2date[$x->rev_id] = $x;
- $this->date2rev[$x->rev_timestamp] = $x;
- }
+ var $page_id;
+
+ function getRevisionFromId( $rev_id ) {
+ if( isset( $this->id2rev[$rev_id] ) ) return $this->id2rev[$rev_id];
+
+ $db =& wfGetDB( DB_SLAVE );
+ $fname = 'SpecialValidate::getRevisionFromId';
+ $res = $db->select( 'revision', '*', array( 'rev_id' => $rev_id ), $fname, array( 'LIMIT' => 1 ) );
+ $rev = $db->fetchObject($res);
+ $db->freeResult($res);
+
+ $this->id2rev[$rev->rev_id] = $rev;
+ $this->ts2rev[$rev->rev_timestamp] = $rev;
+
+ return $rev;
+ }
+
+ function getRevisionFromTimestamp( $timestamp ) {
+ if( isset( $this->ts2rev[$timestamp] ) ) return $this->ts2rev[$timestamp];
+
+ $db =& wfGetDB( DB_SLAVE );
+ $fname = 'SpecialValidate::getRevisionFromTimestamp';
+ $res = $db->select( 'revision', '*',
+ array( 'rev_page' => $this->page_id, 'rev_timestamp' => $timestamp ),
+ $fname, array( 'LIMIT' => 1 )
+ );
+ $rev = $db->fetchObject($res);
+ $db->freeResult($res);
+
+ $this->id2rev[$rev->rev_id] = $rev;
+ $this->ts2rev[$rev->rev_timestamp] = $rev;
+
+ return $rev;