* Load a page revision from a given revision ID number.
* Returns null if no such revision can be found.
*
- * @param DatabaseBase $db
+ * @param IDatabase $db
* @param int $id
* @return Revision|null
*/
* that's attached to a given page. If not attached
* to that page, will return null.
*
- * @param DatabaseBase $db
+ * @param IDatabase $db
* @param int $pageid
* @param int $id
* @return Revision|null
* that's attached to a given page. If not attached
* to that page, will return null.
*
- * @param DatabaseBase $db
+ * @param IDatabase $db
* @param Title $title
* @param int $id
* @return Revision|null
* WARNING: Timestamps may in some circumstances not be unique,
* so this isn't the best key to use.
*
- * @param DatabaseBase $db
+ * @param IDatabase $db
* @param Title $title
* @param string $timestamp
* @return Revision|null
* Given a set of conditions, fetch a revision from
* the given database connection.
*
- * @param DatabaseBase $db
+ * @param IDatabase $db
* @param array $conditions
* @param int $flags (optional)
* @return Revision|null
* which will return matching database rows with the
* fields necessary to build Revision objects.
*
- * @param DatabaseBase $db
+ * @param IDatabase $db
* @param array $conditions
* @param int $flags (optional)
* @return ResultWrapper
/**
* Do a batched query to get the parent revision lengths
- * @param DatabaseBase $db
+ * @param IDatabase $db
* @param array $revIds
* @return array
*/
/**
* Get the RC object belonging to the current revision, if there's one
*
+ * @param int $flags (optional) $flags include:
+ * Revision::READ_LATEST : Select the data from the master
+ *
* @since 1.22
* @return RecentChange|null
*/
- public function getRecentChange() {
+ public function getRecentChange( $flags = 0 ) {
$dbr = wfGetDB( DB_SLAVE );
+
+ list( $dbType, ) = DBAccessObjectUtils::getDBOptions( $flags );
+
return RecentChange::newFromConds(
array(
'rc_user_text' => $this->getUserText( Revision::RAW ),
'rc_timestamp' => $dbr->timestamp( $this->getTimestamp() ),
'rc_this_oldid' => $this->getId()
),
- __METHOD__
+ __METHOD__,
+ $dbType
);
}
* Get previous revision Id for this page_id
* This is used to populate rev_parent_id on save
*
- * @param DatabaseBase $db
+ * @param IDatabase $db
* @return int
*/
private function getPreviousRevisionId( $db ) {
* Insert a new revision into the database, returning the new revision ID
* number on success and dies horribly on failure.
*
- * @param DatabaseBase $dbw (master connection)
+ * @param IDatabase $dbw (master connection)
* @throws MWException
* @return int
*/
protected function checkContentModel() {
global $wgContentHandlerUseDB;
- $title = $this->getTitle(); // note: may return null for revisions that have not yet been inserted.
+ // Note: may return null for revisions that have not yet been inserted
+ $title = $this->getTitle();
$model = $this->getContentModel();
$format = $this->getContentFormat();
*/
protected function loadText() {
// Caching may be beneficial for massive use of external storage
- global $wgRevisionCacheExpiry, $wgMemc;
+ global $wgRevisionCacheExpiry;
+ $cache = ObjectCache::getMainWANInstance();
$textId = $this->getTextId();
$key = wfMemcKey( 'revisiontext', 'textid', $textId );
if ( $wgRevisionCacheExpiry ) {
- $text = $wgMemc->get( $key );
+ $text = $cache->get( $key );
if ( is_string( $text ) ) {
wfDebug( __METHOD__ . ": got id $textId from cache\n" );
return $text;
# No negative caching -- negative hits on text rows may be due to corrupted slave servers
if ( $wgRevisionCacheExpiry && $text !== false ) {
- $wgMemc->set( $key, $text, $wgRevisionCacheExpiry );
+ $cache->set( $key, $text, $wgRevisionCacheExpiry );
}
return $text;
* Such revisions can for instance identify page rename
* operations and other such meta-modifications.
*
- * @param DatabaseBase $dbw
+ * @param IDatabase $dbw
* @param int $pageId ID number of the page to read from
* @param string $summary Revision's summary
* @param bool $minor Whether the revision should be considered as minor
/**
* Get count of revisions per page...not very efficient
*
- * @param DatabaseBase $db
+ * @param IDatabase $db
* @param int $id Page id
* @return int
*/
/**
* Get count of revisions per page...not very efficient
*
- * @param DatabaseBase $db
+ * @param IDatabase $db
* @param Title $title
* @return int
*/
* @since 1.20
* @deprecated since 1.24
*
- * @param DatabaseBase|int $db The Database to perform the check on. May be given as a
+ * @param IDatabase|int $db The Database to perform the check on. May be given as a
* Database object or a database identifier usable with wfGetDB.
* @param int $pageId The ID of the page in question
* @param int $userId The ID of the user in question