Introduce EditPage::getExpectedParentRevision, deprecate using Revision
Hard deprecate public variable EditPage::$mBaseRevision, unused outside of the class and being replaced with a private RevisionRecord object Soft deprecate EditPage::getBaseRevision Bug: T248655 Change-Id: I8d8b0f74b66a30e951d09fd5d2881d0d5d63777a
This commit is contained in:
parent
9b125a09ae
commit
3474b24707
2 changed files with 48 additions and 6 deletions
|
|
@ -644,6 +644,9 @@ because of Phabricator reports.
|
|||
::getLimitOffsetForUser and pass a User object.
|
||||
* PageArchive::undelete is hard deprecated. Instead, use ::undeleteAsUser
|
||||
and pass a User object.
|
||||
* EditPage::getBaseRevision was soft deprecated. Instead, use the new
|
||||
::getExpectedParentRevision method.
|
||||
* The public variable EditPage::$mBaseRevision was hard deprecated.
|
||||
* FileDeleteForm previously did not accept a user parameter in its constructor,
|
||||
instead relying on the global $wgUser. A user parameter has been added,
|
||||
and //not// providing a user is deprecated. There are no known callers
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ use Wikimedia\ScopedCallback;
|
|||
* headaches, which may be fatal.
|
||||
*/
|
||||
class EditPage {
|
||||
|
||||
use DeprecationHelper;
|
||||
|
||||
/**
|
||||
* Used for Unicode support checks
|
||||
*/
|
||||
|
|
@ -315,8 +318,23 @@ class EditPage {
|
|||
/** @var bool Has a summary been preset using GET parameter &summary= ? */
|
||||
public $hasPresetSummary = false;
|
||||
|
||||
/** @var Revision|bool|null A revision object corresponding to $this->editRevId. */
|
||||
public $mBaseRevision = false;
|
||||
/**
|
||||
* @var Revision|bool|null
|
||||
*
|
||||
* A revision object corresponding to $this->editRevId.
|
||||
* Formerly public as part of using Revision objects
|
||||
*
|
||||
* @deprecated since 1.35
|
||||
*/
|
||||
protected $mBaseRevision = false;
|
||||
|
||||
/**
|
||||
* @var RevisionRecord|bool|null
|
||||
*
|
||||
* A RevisionRecord corresponding to $this->editRevId or $this->edittime
|
||||
* Replaced $mBaseRevision
|
||||
*/
|
||||
private $mExpectedParentRevision = false;
|
||||
|
||||
/** @var bool */
|
||||
public $mShowSummaryField = true;
|
||||
|
|
@ -519,6 +537,8 @@ class EditPage {
|
|||
$this->editConflictHelperFactory = [ $this, 'newTextConflictHelper' ];
|
||||
$this->permManager = $services->getPermissionManager();
|
||||
$this->revisionStore = $services->getRevisionStore();
|
||||
|
||||
$this->deprecatePublicProperty( 'mBaseRevision', '1.35', __CLASS__ );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2516,8 +2536,10 @@ ERROR;
|
|||
private function mergeChangesIntoContent( &$editContent ) {
|
||||
// This is the revision that was current at the time editing was initiated on the client,
|
||||
// even if the edit was based on an old revision.
|
||||
$baseRevision = $this->getBaseRevision();
|
||||
$baseContent = $baseRevision ? $baseRevision->getContent() : null;
|
||||
$baseRevRecord = $this->getExpectedParentRevision();
|
||||
$baseContent = $baseRevRecord ?
|
||||
$baseRevRecord->getContent( SlotRecord::MAIN ) :
|
||||
null;
|
||||
|
||||
if ( $baseContent === null ) {
|
||||
return false;
|
||||
|
|
@ -2555,6 +2577,8 @@ ERROR;
|
|||
* Returns the revision that was current at the time editing was initiated on the client,
|
||||
* even if the edit was based on an old revision.
|
||||
*
|
||||
* @deprecated since 1.35, use ::getExpectedParentRevision
|
||||
*
|
||||
* @warning this method is very poorly named. If the user opened the form with ?oldid=X,
|
||||
* one might think of X as the "base revision", which is NOT what this returns,
|
||||
* see oldid for that. One might further assume that this corresponds to the $baseRevId
|
||||
|
|
@ -2565,6 +2589,21 @@ ERROR;
|
|||
*/
|
||||
public function getBaseRevision() {
|
||||
if ( $this->mBaseRevision === false ) {
|
||||
$revRecord = $this->getExpectedParentRevision();
|
||||
$this->mBaseRevision = $revRecord ? new Revision( $revRecord ) : null;
|
||||
}
|
||||
return $this->mBaseRevision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the RevisionRecord corresponding to the revision that was current at the time
|
||||
* editing was initiated on the client even if the edit was based on an old revision
|
||||
*
|
||||
* @since 1.35
|
||||
* @return RevisionRecord|null Current revision when editing was initiated on the client
|
||||
*/
|
||||
public function getExpectedParentRevision() {
|
||||
if ( $this->mExpectedParentRevision === false ) {
|
||||
$revRecord = null;
|
||||
if ( $this->editRevId ) {
|
||||
$revRecord = $this->revisionStore->getRevisionById(
|
||||
|
|
@ -2578,9 +2617,9 @@ ERROR;
|
|||
RevisionStore::READ_LATEST
|
||||
);
|
||||
}
|
||||
$this->mBaseRevision = $revRecord ? new Revision( $revRecord ) : null;
|
||||
$this->mExpectedParentRevision = $revRecord;
|
||||
}
|
||||
return $this->mBaseRevision;
|
||||
return $this->mExpectedParentRevision;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue