Forward the User object from WikiPage to Revision.
This affects the following methods of WikiPage: - getText() - getUser() - getCreator() - getUserText() - getComment() These are wrapper to methods in the Revision class that accept an optional User object as second parameter in the case FOR_THIS_USER is passed as first parameter. Change-Id: I81a2470378bc1134dd144743d376ba31f4fe13d1
This commit is contained in:
parent
100473d60e
commit
726f30786f
1 changed files with 25 additions and 15 deletions
|
|
@ -559,14 +559,16 @@ class WikiPage extends Page implements IDBAccessObject {
|
|||
*
|
||||
* @param $audience Integer: one of:
|
||||
* Revision::FOR_PUBLIC to be displayed to all users
|
||||
* Revision::FOR_THIS_USER to be displayed to $wgUser
|
||||
* Revision::FOR_THIS_USER to be displayed to the given user
|
||||
* Revision::RAW get the text regardless of permissions
|
||||
* @param $user User object to check for, only if FOR_THIS_USER is passed
|
||||
* to the $audience parameter
|
||||
* @return String|bool The text of the current revision. False on failure
|
||||
*/
|
||||
public function getText( $audience = Revision::FOR_PUBLIC ) {
|
||||
public function getText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
|
||||
$this->loadLastEdit();
|
||||
if ( $this->mLastRevision ) {
|
||||
return $this->mLastRevision->getText( $audience );
|
||||
return $this->mLastRevision->getText( $audience, $user );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -608,14 +610,16 @@ class WikiPage extends Page implements IDBAccessObject {
|
|||
/**
|
||||
* @param $audience Integer: one of:
|
||||
* Revision::FOR_PUBLIC to be displayed to all users
|
||||
* Revision::FOR_THIS_USER to be displayed to $wgUser
|
||||
* Revision::FOR_THIS_USER to be displayed to the given user
|
||||
* Revision::RAW get the text regardless of permissions
|
||||
* @param $user User object to check for, only if FOR_THIS_USER is passed
|
||||
* to the $audience parameter
|
||||
* @return int user ID for the user that made the last article revision
|
||||
*/
|
||||
public function getUser( $audience = Revision::FOR_PUBLIC ) {
|
||||
public function getUser( $audience = Revision::FOR_PUBLIC, User $user = null ) {
|
||||
$this->loadLastEdit();
|
||||
if ( $this->mLastRevision ) {
|
||||
return $this->mLastRevision->getUser( $audience );
|
||||
return $this->mLastRevision->getUser( $audience, $user );
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -625,14 +629,16 @@ class WikiPage extends Page implements IDBAccessObject {
|
|||
* Get the User object of the user who created the page
|
||||
* @param $audience Integer: one of:
|
||||
* Revision::FOR_PUBLIC to be displayed to all users
|
||||
* Revision::FOR_THIS_USER to be displayed to $wgUser
|
||||
* Revision::FOR_THIS_USER to be displayed to the given user
|
||||
* Revision::RAW get the text regardless of permissions
|
||||
* @param $user User object to check for, only if FOR_THIS_USER is passed
|
||||
* to the $audience parameter
|
||||
* @return User|null
|
||||
*/
|
||||
public function getCreator( $audience = Revision::FOR_PUBLIC ) {
|
||||
public function getCreator( $audience = Revision::FOR_PUBLIC, User $user = null ) {
|
||||
$revision = $this->getOldestRevision();
|
||||
if ( $revision ) {
|
||||
$userName = $revision->getUserText( $audience );
|
||||
$userName = $revision->getUserText( $audience, $user );
|
||||
return User::newFromName( $userName, false );
|
||||
} else {
|
||||
return null;
|
||||
|
|
@ -642,14 +648,16 @@ class WikiPage extends Page implements IDBAccessObject {
|
|||
/**
|
||||
* @param $audience Integer: one of:
|
||||
* Revision::FOR_PUBLIC to be displayed to all users
|
||||
* Revision::FOR_THIS_USER to be displayed to $wgUser
|
||||
* Revision::FOR_THIS_USER to be displayed to the given user
|
||||
* Revision::RAW get the text regardless of permissions
|
||||
* @param $user User object to check for, only if FOR_THIS_USER is passed
|
||||
* to the $audience parameter
|
||||
* @return string username of the user that made the last article revision
|
||||
*/
|
||||
public function getUserText( $audience = Revision::FOR_PUBLIC ) {
|
||||
public function getUserText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
|
||||
$this->loadLastEdit();
|
||||
if ( $this->mLastRevision ) {
|
||||
return $this->mLastRevision->getUserText( $audience );
|
||||
return $this->mLastRevision->getUserText( $audience, $user );
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
|
@ -658,14 +666,16 @@ class WikiPage extends Page implements IDBAccessObject {
|
|||
/**
|
||||
* @param $audience Integer: one of:
|
||||
* Revision::FOR_PUBLIC to be displayed to all users
|
||||
* Revision::FOR_THIS_USER to be displayed to $wgUser
|
||||
* Revision::FOR_THIS_USER to be displayed to the given user
|
||||
* Revision::RAW get the text regardless of permissions
|
||||
* @param $user User object to check for, only if FOR_THIS_USER is passed
|
||||
* to the $audience parameter
|
||||
* @return string Comment stored for the last article revision
|
||||
*/
|
||||
public function getComment( $audience = Revision::FOR_PUBLIC ) {
|
||||
public function getComment( $audience = Revision::FOR_PUBLIC, User $user = null ) {
|
||||
$this->loadLastEdit();
|
||||
if ( $this->mLastRevision ) {
|
||||
return $this->mLastRevision->getComment( $audience );
|
||||
return $this->mLastRevision->getComment( $audience, $user );
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue