From b2ac2a41dd3fe03ec6877348c375ccff0fb4c95b Mon Sep 17 00:00:00 2001 From: David Causse Date: Wed, 11 Sep 2019 16:48:02 +0200 Subject: [PATCH] Expose LinksUpdate recursive flag with a getter knowing if recursion is enabled might help extensions implementing LinksUpdate hooks to take some decisions. E.g. CirrusSearch would like to know if a particular update needs to go to a priorized queue or not (template transclusion). Change-Id: I0a0de0d4621ed302b4fb550a1ddecd4ac8c5775a --- includes/deferred/LinksUpdate.php | 10 ++++++++++ .../phpunit/includes/deferred/LinksUpdateTest.php | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/includes/deferred/LinksUpdate.php b/includes/deferred/LinksUpdate.php index 8345ee6575..59418498c4 100644 --- a/includes/deferred/LinksUpdate.php +++ b/includes/deferred/LinksUpdate.php @@ -1192,4 +1192,14 @@ class LinksUpdate extends DataUpdate { return $this->db; } + + /** + * Whether or not this LinksUpdate will also update pages which transclude the + * current page or otherwise depend on it. + * + * @return bool + */ + public function isRecursive() { + return $this->mRecursive; + } } diff --git a/tests/phpunit/includes/deferred/LinksUpdateTest.php b/tests/phpunit/includes/deferred/LinksUpdateTest.php index cd3ddfa8e8..1f9d29e26c 100644 --- a/tests/phpunit/includes/deferred/LinksUpdateTest.php +++ b/tests/phpunit/includes/deferred/LinksUpdateTest.php @@ -430,4 +430,18 @@ class LinksUpdateTest extends MediaWikiLangTestCase { $queueGroup->ack( $job ); } } + + public function testIsRecursive() { + list( $title, $po ) = $this->makeTitleAndParserOutput( 'Test', 1 ); + $linksUpdate = new LinksUpdate( $title, $po ); + $this->assertTrue( $linksUpdate->isRecursive(), 'LinksUpdate is recursive by default' ); + + $linksUpdate = new LinksUpdate( $title, $po, true ); + $this->assertTrue( $linksUpdate->isRecursive(), + 'LinksUpdate is recursive when asked to be recursive' ); + + $linksUpdate = new LinksUpdate( $title, $po, false ); + $this->assertFalse( $linksUpdate->isRecursive(), + 'LinksUpdate is not recursive when asked to be not recursive' ); + } } -- 2.20.1