*/
const DIFF_VERSION = '1.12';
- /** @var int */
+ /** @var int Revision ID or 0 for current */
public $mOldid;
- /** @var int */
+ /** @var int|string Revision ID or null for current or an alias such as 'next' */
public $mNewid;
private $mOldTags;
private $mNewTags;
- /** @var Content */
+ /** @var Content|null */
public $mOldContent;
- /** @var Content */
+ /** @var Content|null */
public $mNewContent;
/** @var Language */
/** @var Title */
public $mNewPage;
- /** @var Revision */
+ /** @var Revision|null */
public $mOldRev;
- /** @var Revision */
+ /** @var Revision|null */
public $mNewRev;
/** @var bool Have the revisions IDs been loaded */
/** @var int How many text blobs have been loaded, 0, 1 or 2? */
public $mTextLoaded = 0;
+ /**
+ * Was the content overridden via setContent()?
+ * If the content was overridden, most internal state (e.g. mOldid or mOldRev) should be ignored.
+ * @var bool
+ */
+ protected $isContentOverridden = false;
+
/** @var bool Was the diff fetched from cache? */
public $mCacheHit = false;
$this->mTextLoaded = 2;
$this->mRevisionsLoaded = true;
+ $this->isContentOverridden = true;
}
/**
* to false. This is impossible via ordinary user input, and is provided for
* API convenience.
*
- * @return bool
+ * @return bool Whether both revisions were loaded successfully.
*/
public function loadRevisionData() {
if ( $this->mRevisionsLoaded ) {
- return true;
+ return $this->isContentOverridden || $this->mNewRev && $this->mOldRev;
}
// Whether it succeeds or fails, we don't want to try again
/**
* Load the text of the revisions, as well as revision data.
*
- * @return bool
+ * @return bool Whether the content of both revisions could be loaded successfully.
*/
public function loadText() {
if ( $this->mTextLoaded == 2 ) {
- return true;
+ return $this->loadRevisionData() && $this->mOldContent && $this->mNewContent;
}
// Whether it succeeds or fails, we don't want to try again
/**
* Load the text of the new revision, not the old one
*
- * @return bool
+ * @return bool Whether the content of the new revision could be loaded successfully.
*/
public function loadNewText() {
if ( $this->mTextLoaded >= 1 ) {
- return true;
+ return $this->loadRevisionData();
}
$this->mTextLoaded = 1;