From 1ae8e89eb580763ba43ca1356b2338260b46a36e Mon Sep 17 00:00:00 2001 From: vladshapik Date: Tue, 26 Oct 2021 18:21:32 +0300 Subject: [PATCH] Hard deprecate LinkCache::addGoodLinkObj LinkCache::addGoodLinkObj was hard deprecated. Use addGoodLinkObjFromRow() instead. PHPUnit tests must use LinkCacheTestTrait::addGoodLinkObject(). Bug: T284955 Change-Id: I0c22be2f00e6d6d4ba6dd1511c5385cad55e8ff7 --- RELEASE-NOTES-1.38 | 1 + includes/cache/LinkCache.php | 1 + tests/phpunit/includes/TitleTest.php | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES-1.38 b/RELEASE-NOTES-1.38 index d8319c56873..ba654b82829 100644 --- a/RELEASE-NOTES-1.38 +++ b/RELEASE-NOTES-1.38 @@ -267,6 +267,7 @@ because of Phabricator reports. ::getArchivedRevisionRecord, ::getPreviousRevisionRecord and ::getLastRevisionId. - Use ArchivedRevisionLookup::hasArchivedRevisions instead of ::isDeleted. +* LinkCache::addGoodLinkObj() has been hard deprecated. * … === Other changes in 1.38 === diff --git a/includes/cache/LinkCache.php b/includes/cache/LinkCache.php index ebc40e7639b..4275067ba02 100644 --- a/includes/cache/LinkCache.php +++ b/includes/cache/LinkCache.php @@ -282,6 +282,7 @@ class LinkCache implements LoggerAwareInterface { public function addGoodLinkObj( $id, $page, $len = -1, $redir = null, $revision = 0, $model = null, $lang = null ) { + wfDeprecated( __METHOD__, '1.38' ); $this->addGoodLinkObjFromRow( $page, (object)[ 'page_id' => (int)$id, 'page_namespace' => $page->getNamespace(), diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php index 0f95c274705..4cb89ede5e1 100644 --- a/tests/phpunit/includes/TitleTest.php +++ b/tests/phpunit/includes/TitleTest.php @@ -16,6 +16,7 @@ use Wikimedia\TestingAccessWrapper; */ class TitleTest extends MediaWikiIntegrationTestCase { use DummyServicesTrait; + use LinkCacheTestTrait; protected function setUp(): void { parent::setUp(); @@ -367,10 +368,10 @@ class TitleTest extends MediaWikiIntegrationTestCase { * @covers Title::clearCaches */ public function testClearCaches() { - $linkCache = MediaWikiServices::getInstance()->getLinkCache(); + $linkCache = $this->getServiceContainer()->getLinkCache(); $title1 = Title::newFromText( 'Foo' ); - $linkCache->addGoodLinkObj( 23, $title1 ); + $this->addGoodLinkObject( 23, $title1 ); Title::clearCaches();