+
+ /**
+ * Get rev_timestamp from rev_id, without loading the rest of the row
+ * @param Title $title
+ * @param integer $id
+ */
+ static function getTimestampFromId( $title, $id ) {
+ $dbr = wfGetDB( DB_SLAVE );
+ // Casting fix for DB2
+ if ($id == '') {
+ $id = 0;
+ }
+ $conds = array( 'rev_id' => $id );
+ $conds['rev_page'] = $title->getArticleId();
+ $timestamp = $dbr->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ );
+ if ( $timestamp === false && wfGetLB()->getServerCount() > 1 ) {
+ # Not in slave, try master
+ $dbw = wfGetDB( DB_MASTER );
+ $timestamp = $dbw->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ );
+ }
+ return wfTimestamp( TS_MW, $timestamp );
+ }
+
+ /**
+ * Get count of revisions per page...not very efficient
+ * @param Database $db
+ * @param int $id, page id
+ */
+ static function countByPageId( $db, $id ) {
+ $row = $db->selectRow( 'revision', 'COUNT(*) AS revCount',
+ array( 'rev_page' => $id ), __METHOD__ );
+ if( $row ) {
+ return $row->revCount;
+ }
+ return 0;
+ }
+
+ /**
+ * Get count of revisions per page...not very efficient
+ * @param Database $db
+ * @param Title $title
+ */
+ static function countByTitle( $db, $title ) {
+ $id = $title->getArticleId();
+ if( $id ) {
+ return Revision::countByPageId( $db, $id );
+ }
+ return 0;
+ }