* Boolean parameters are widely accepted to reduce readability. Replaced the new boolean parameters with class constant parameters instead.
* Re-added Revision::revText(), for backwards compatibility
* The getUser()/getUserText() changes near line 1223 of SpecialUndelete.php were incorrect, $file is an ArchivedFile not a Revision, and doesn't have any $isPublic parameters.
// FIXME: Horrible, horrible! This content-loading interface just plain sucks.
// We should instead work with the Revision object when we need it...
- $this->mContent = $revision->getText( false ); // Loads if user is allowed
+ $this->mContent = $revision->getText( Revision::FOR_THIS_USER ); // Loads if user is allowed
$this->mUser = $revision->getUser();
$this->mUserText = $revision->getUserText();
if( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
$link = wfMsgHtml( 'rev-deleted-user' );
} else if( $rev->userCan( Revision::DELETED_USER ) ) {
- $link = $this->userLink( $rev->getUser(false), $rev->getUserText(false) );
+ $link = $this->userLink( $rev->getUser( Revision::FOR_THIS_USER ),
+ $rev->getUserText( Revision::FOR_THIS_USER ) );
} else {
$link = wfMsgHtml( 'rev-deleted-user' );
}
if( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
$link = wfMsgHtml( 'rev-deleted-user' );
} else if( $rev->userCan( Revision::DELETED_USER ) ) {
- $link = $this->userLink( $rev->getUser(false), $rev->getUserText(false) ) .
- ' ' . $this->userToolLinks( $rev->getUser(false), $rev->getUserText(false) );
+ $userId = $rev->getUser( Revision::FOR_THIS_USER );
+ $userText = $rev->getUserText( Revision::FOR_THIS_USER );
+ $link = $this->userLink( $userId, $userText ) .
+ ' ' . $this->userToolLinks( $userId, $userText );
} else {
$link = wfMsgHtml( 'rev-deleted-user' );
}
if( $rev->isDeleted( Revision::DELETED_COMMENT ) && $isPublic ) {
$block = " <span class=\"comment\">" . wfMsgHtml( 'rev-deleted-comment' ) . "</span>";
} else if( $rev->userCan( Revision::DELETED_COMMENT ) ) {
- $block = $this->commentBlock( $rev->getComment(false), $rev->getTitle(), $local );
+ $block = $this->commentBlock( $rev->getComment( Revision::FOR_THIS_USER ),
+ $rev->getTitle(), $local );
} else {
$block = " <span class=\"comment\">" . wfMsgHtml( 'rev-deleted-comment' ) . "</span>";
}
const DELETED_USER = 4;
const DELETED_RESTRICTED = 8;
+ // Audience options for Revision::getText()
+ const FOR_PUBLIC = 1;
+ const FOR_THIS_USER = 2;
+ const RAW = 3;
+
/**
* Load a page revision from a given revision ID number.
* Returns null if no such revision can be found.
}
/**
- * Fetch revision's user id if it's available to all users
+ * Fetch revision's user id if it's available to the specified audience.
+ * If the specified audience does not have access to it, zero will be
+ * returned.
+ *
+ * @param integer $audience One of:
+ * Revision::FOR_PUBLIC to be displayed to all users
+ * Revision::FOR_THIS_USER to be displayed to $wgUser
+ * Revision::RAW get the ID regardless of permissions
+ *
+ *
* @return int
*/
- public function getUser( $isPublic = true ) {
- if( $isPublic && $this->isDeleted( self::DELETED_USER ) ) {
+ public function getUser( $audience = self::FOR_PUBLIC ) {
+ if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) {
return 0;
- } else if( !$this->userCan( self::DELETED_USER ) ) {
+ } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER ) ) {
return 0;
} else {
return $this->mUser;
}
/**
- * Fetch revision's username if it's available to all users
+ * Fetch revision's username if it's available to the specified audience.
+ * If the specified audience does not have access to the username, an
+ * empty string will be returned.
+ *
+ * @param integer $audience One of:
+ * Revision::FOR_PUBLIC to be displayed to all users
+ * Revision::FOR_THIS_USER to be displayed to $wgUser
+ * Revision::RAW get the text regardless of permissions
+ *
* @return string
*/
- public function getUserText( $isPublic = true ) {
- if( $isPublic && $this->isDeleted( self::DELETED_USER ) ) {
+ public function getUserText( $audience = self::FOR_PUBLIC ) {
+ if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) {
return "";
- } else if( !$this->userCan( self::DELETED_USER ) ) {
+ } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER ) ) {
return "";
} else {
return $this->mUserText;
}
/**
- * Fetch revision comment if it's available to all users
+ * Fetch revision comment if it's available to the specified audience.
+ * If the specified audience does not have access to the comment, an
+ * empty string will be returned.
+ *
+ * @param integer $audience One of:
+ * Revision::FOR_PUBLIC to be displayed to all users
+ * Revision::FOR_THIS_USER to be displayed to $wgUser
+ * Revision::RAW get the text regardless of permissions
+ *
* @return string
*/
- function getComment( $isPublic = true ) {
- if( $isPublic && $this->isDeleted( self::DELETED_COMMENT ) ) {
+ function getComment( $audience = self::FOR_PUBLIC ) {
+ if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_COMMENT ) ) {
return "";
- } else if( !$this->userCan( self::DELETED_COMMENT ) ) {
+ } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_COMMENT ) ) {
return "";
} else {
return $this->mComment;
}
/**
- * Fetch revision text if it's available to all users
+ * Fetch revision text if it's available to the specified audience.
+ * If the specified audience does not have the ability to view this
+ * revision, an empty string will be returned.
+ *
+ * @param integer $audience One of:
+ * Revision::FOR_PUBLIC to be displayed to all users
+ * Revision::FOR_THIS_USER to be displayed to $wgUser
+ * Revision::RAW get the text regardless of permissions
+ *
+ *
* @return string
*/
- public function getText( $isPublic = true ) {
- if( $isPublic && $this->isDeleted( self::DELETED_TEXT ) ) {
+ public function getText( $audience = self::FOR_PUBLIC ) {
+ if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_TEXT ) ) {
return "";
- } else if( !$this->userCan( self::DELETED_TEXT ) ) {
+ } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_TEXT ) ) {
return "";
} else {
return $this->getRawText();
}
}
+ /**
+ * Alias for getText(Revision::FOR_THIS_USER)
+ */
+ public function revText() {
+ return $this->getText( self::FOR_THIS_USER );
+ }
+
/**
* Fetch revision text without regard for view restrictions
* @return string
$this->dieUsage("There is no revision ID $oldid", 'missingrev');
if(!$rev->userCan(Revision::DELETED_TEXT))
$this->dieUsage("You don't have permission to view deleted revisions", 'permissiondenied');
- $text = $rev->getText(false);
+ $text = $rev->getText( Revision::FOR_THIS_USER );
$titleObj = $rev->getTitle();
$p_result = $wgParser->parse($text, $titleObj, $popts);
}
$change = RecentChange::newFromConds(
array(
// Add redundant user,timestamp condition so we can use the existing index
- 'rc_user_text' => $this->mNewRev->getUserText(false),
+ 'rc_user_text' => $this->mNewRev->getUserText( Revision::FOR_THIS_USER ),
'rc_timestamp' => $db->timestamp( $this->mNewRev->getTimestamp() ),
'rc_this_oldid' => $this->mNewid,
'rc_last_oldid' => $this->mOldid,
return false;
}
if ( $this->mOldRev ) {
- $this->mOldtext = $this->mOldRev->getText( false );
+ $this->mOldtext = $this->mOldRev->getText( Revision::FOR_THIS_USER );
if ( $this->mOldtext === false ) {
return false;
}
}
if ( $this->mNewRev ) {
- $this->mNewtext = $this->mNewRev->getText( false );
+ $this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER );
if ( $this->mNewtext === false ) {
return false;
}
}
wfProfileOut( __METHOD__ );
}
-}
\ No newline at end of file
+}
$popts = $wgOut->parserOptions();
$popts->setEditSection( false );
$wgOut->parserOptions( $popts );
- $wgOut->addWikiTextTitleTidy( $rev->getText( false ), $this->mTargetObj, true );
+ $wgOut->addWikiTextTitleTidy( $rev->getText( Revision::FOR_THIS_USER ), $this->mTargetObj, true );
}
$wgOut->addHtml(
'readonly' => 'readonly',
'cols' => intval( $wgUser->getOption( 'cols' ) ),
'rows' => intval( $wgUser->getOption( 'rows' ) ) ),
- $rev->getText( false ) . "\n" ) .
+ $rev->getText( Revision::FOR_THIS_USER ) . "\n" ) .
wfOpenElement( 'div' ) .
wfOpenElement( 'form', array(
'method' => 'post',
if( !$file->userCan(File::DELETED_USER) ) {
return '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
} else {
- $link = $sk->userLink( $file->getUser(false), $file->getUserText(false) ) .
- $sk->userToolLinks( $file->getUser(false), $file->getUserText(false) );
+ $link = $sk->userLink( $file->getUser(), $file->getUserText() ) .
+ $sk->userToolLinks( $file->getUser(), $file->getUserText() );
if( $file->isDeleted(File::DELETED_USER) )
$link = '<span class="history-deleted">' . $link . '</span>';
return $link;