$wgOut->addWikiMsg('anontalkpagetext');
}
+ # Only diffs and new page links from RC give rcid params, so if
+ # we are just viewing the page normally with no rcid, try to find it.
+ # This is more convenient for users.
+ if( empty($rcid) && $this->mTitle->userCan('patrol') ) {
+ $firstRev = $this->mTitle->getFirstRevision();
+ $rcid = $firstRev->isUnpatrolled();
+ }
# If we have been passed an &rcid= parameter, we want to give the user a
# chance to mark this new article as patrolled.
if( !empty($rcid) && $this->mTitle->exists() && $this->mTitle->userCan('patrol') ) {
} else {
throw new MWException( 'Revision constructor passed invalid row format.' );
}
+ $this->mUnpatrolled = NULL;
}
/**#@+
public function isMinor() {
return (bool)$this->mMinorEdit;
}
+
+ /**
+ * @return int rcid of the unpatrolled row, zero if there isn't one
+ */
+ public function isUnpatrolled() {
+ if( $this->mUnpatrolled !== NULL ) {
+ return $this->mUnpatrolled;
+ }
+ $dbr = wfGetDB( DB_SLAVE );
+ $this->mUnpatrolled = $dbr->selectField( 'recentchanges',
+ 'rc_id',
+ array( // Add redundant user,timestamp condition so we can use the existing index
+ 'rc_user_text' => $this->getRawUserText(),
+ 'rc_timestamp' => $dbr->timestamp( $this->getTimestamp() ),
+ 'rc_this_oldid' => $this->getId(),
+ 'rc_patrolled' => 0
+ ),
+ __METHOD__
+ );
+ return (int)$this->mUnpatrolled;
+ }
/**
* int $field one of DELETED_* bitfield constants
);
}
+ /**
+ * Get the first revision of the page
+ *
+ * @param $flags \type{\int} GAID_FOR_UPDATE
+ * @return Revision (or NULL if page doesn't exist)
+ */
+ public function getFirstRevision( $flags=0 ) {
+ $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
+ $pageId = $this->getArticleId($flags);
+ if( !$pageId ) return NULL;
+ $row = $db->selectRow( 'revision', '*',
+ array( 'rev_page' => $pageId ),
+ __METHOD__,
+ array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 )
+ );
+ if( !$row ) {
+ return NULL;
+ } else {
+ return new Revision( $row );
+ }
+ }
+
/**
* Check if this is a new page
*