# Get previous one from DB.
#
$this->mNewid = intval($old);
- $dbr =& wfGetDB( DB_SLAVE );
- $this->mOldid = $dbr->selectField( 'old', 'old_id',
- "old_title='" . $wgTitle->getDBkey() . "'" .
- ' AND old_namespace=' . $wgTitle->getNamespace() .
- " AND old_id<{$this->mNewid} ORDER BY old_id DESC" );
+
+ $this->mOldid = $wgTitle->getPreviousRevisionID( $this->mNewid );
+ #$dbr =& wfGetDB( DB_SLAVE );
+ #$this->mOldid = $dbr->selectField( 'old', 'old_id',
+ #"old_title='" . $wgTitle->getDBkey() . "'" .
+ #' AND old_namespace=' . $wgTitle->getNamespace() .
+ #" AND old_id<{$this->mNewid} ORDER BY old_id DESC" );
} elseif ( 'next' == $new ) {
# Get previous one from DB.
#
$this->mOldid = intval($old);
- $dbr =& wfGetDB( DB_SLAVE );
- $this->mNewid = $dbr->selectField( 'old', 'old_id',
- "old_title='" . $wgTitle->getDBkey() . "'" .
- ' AND old_namespace=' . $wgTitle->getNamespace() .
- " AND old_id>{$this->mOldid} ORDER BY old_id " );
+ $this->mNewid = $wgTitle->getNextRevisionID( $this->mOldid );
+ #$dbr =& wfGetDB( DB_SLAVE );
+ #$this->mNewid = $dbr->selectField( 'old', 'old_id',
+ # "old_title='" . $wgTitle->getDBkey() . "'" .
+ # ' AND old_namespace=' . $wgTitle->getNamespace() .
+ # " AND old_id>{$this->mOldid} ORDER BY old_id " );
if ( false === $this->mNewid ) {
# if no result, NewId points to the newest old revision. The only newer
# revision is cur, which is "0".
function oldCond() {
return array( 'old_namespace' => $this->mNamespace, 'old_title' => $this->mDbkeyform );
}
+
+ /**
+ * Get the revision ID of the previous revision
+ *
+ * @param integer $revision Revision ID. Get the revision that was before this one.
+ * @return interger $oldrevision|false
+ */
+ function getPreviousRevisionID( $revision ) {
+ $dbr =& wfGetDB( DB_SLAVE );
+ return $dbr->selectField( 'old', 'old_id',
+ "old_title='" . $this->getDBkey() . "'" .
+ ' AND old_namespace=' . $this->getNamespace() .
+ " AND old_id<{$revision} ORDER BY old_id DESC" );
+ }
+
+ /**
+ * Get the revision ID of the next revision
+ *
+ * @param integer $revision Revision ID. Get the revision that was after this one.
+ * @return interger $oldrevision|false
+ */
+ function getNextRevisionID( $revision ) {
+ $dbr =& wfGetDB( DB_SLAVE );
+ return $dbr->selectField( 'old', 'old_id',
+ "old_title='" . $this->getDBkey() . "'" .
+ ' AND old_namespace=' . $this->getNamespace() .
+ " AND old_id>{$revision} ORDER BY old_id" );
+ }
+
}
?>