From c767dfdea00ab090eb0bf9263754b7d1bc5ff5b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerg=C5=91=20Tisza?= Date: Wed, 11 Jul 2018 10:54:58 +0200 Subject: [PATCH] Deprecate public access to some DifferenceEngine properties These had no business being public in the first place and there is no usage in Gerrit. In case something does use them, it will probably be broken by the refactoring that's soon to come, so the deprecation warning makes it easier to figure out where the problem lies. Change-Id: I72ba5cfbf91f4af16028ba4f8619df6a7168a786 --- RELEASE-NOTES-1.32 | 4 ++++ includes/diff/DifferenceEngine.php | 31 +++++++++++++++++++++--------- includes/page/Article.php | 2 +- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index 486645a867..c91ae7d24f 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -283,6 +283,10 @@ because of Phabricator reports. Set $wgShowExceptionDetails and/or $wgShowHostnames instead. * The $wgShowDBErrorBacktrace global is deprecated and nonfunctional. Set $wgShowExceptionDetails instead. +* Public access to the DifferenceEngine properties mOldid, mNewid, mOldPage, + mNewPage, mOldContent, mNewContent, mRevisionsLoaded, mTextLoaded and + mCacheHit is deprecated. Use getOldid() / getNewid() for the first two, + do your own lookup for page/content. mNewRev / mOldRev remains public. === Other changes in 1.32 === * (T198811) The following tables have had their UNIQUE indexes turned into diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index fbc3dd3c60..e6a15cef32 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -28,6 +28,9 @@ use MediaWiki\Shell\Shell; * @ingroup DifferenceEngine */ class DifferenceEngine extends ContextSource { + + use DeprecationHelper; + /** * Constant to indicate diff cache compatibility. * Bump this when changing the diff formatting in a way that @@ -37,28 +40,28 @@ class DifferenceEngine extends ContextSource { const DIFF_VERSION = '1.12'; /** @var int Revision ID or 0 for current */ - public $mOldid; + protected $mOldid; /** @var int|string Revision ID or null for current or an alias such as 'next' */ - public $mNewid; + protected $mNewid; private $mOldTags; private $mNewTags; /** @var Content|null */ - public $mOldContent; + protected $mOldContent; /** @var Content|null */ - public $mNewContent; + protected $mNewContent; /** @var Language */ protected $mDiffLang; /** @var Title */ - public $mOldPage; + protected $mOldPage; /** @var Title */ - public $mNewPage; + protected $mNewPage; /** @var Revision|null */ public $mOldRev; @@ -70,10 +73,10 @@ class DifferenceEngine extends ContextSource { private $mRevisionsIdsLoaded = false; /** @var bool Have the revisions been loaded */ - public $mRevisionsLoaded = false; + protected $mRevisionsLoaded = false; /** @var int How many text blobs have been loaded, 0, 1 or 2? */ - public $mTextLoaded = 0; + protected $mTextLoaded = 0; /** * Was the content overridden via setContent()? @@ -83,7 +86,7 @@ class DifferenceEngine extends ContextSource { protected $isContentOverridden = false; /** @var bool Was the diff fetched from cache? */ - public $mCacheHit = false; + protected $mCacheHit = false; /** * Set this to true to add debug info to the HTML output. @@ -119,6 +122,16 @@ class DifferenceEngine extends ContextSource { public function __construct( $context = null, $old = 0, $new = 0, $rcid = 0, $refreshCache = false, $unhide = false ) { + $this->deprecatePublicProperty( 'mOldid', '1.32', __CLASS__ ); + $this->deprecatePublicProperty( 'mNewid', '1.32', __CLASS__ ); + $this->deprecatePublicProperty( 'mOldPage', '1.32', __CLASS__ ); + $this->deprecatePublicProperty( 'mNewPage', '1.32', __CLASS__ ); + $this->deprecatePublicProperty( 'mOldContent', '1.32', __CLASS__ ); + $this->deprecatePublicProperty( 'mNewContent', '1.32', __CLASS__ ); + $this->deprecatePublicProperty( 'mRevisionsLoaded', '1.32', __CLASS__ ); + $this->deprecatePublicProperty( 'mTextLoaded', '1.32', __CLASS__ ); + $this->deprecatePublicProperty( 'mCacheHit', '1.32', __CLASS__ ); + if ( $context instanceof IContextSource ) { $this->setContext( $context ); } diff --git a/includes/page/Article.php b/includes/page/Article.php index 9015a32300..49912c77dd 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -733,7 +733,7 @@ class Article implements Page { ); // DifferenceEngine directly fetched the revision: - $this->mRevIdFetched = $de->mNewid; + $this->mRevIdFetched = $de->getNewid(); $de->showDiffPage( $diffOnly ); // Run view updates for the newer revision being diffed (and shown -- 2.20.1