From: David Causse Date: Wed, 11 Sep 2019 14:48:02 +0000 (+0200) Subject: Expose LinksUpdate recursive flag with a getter X-Git-Tag: 1.34.0-rc.0~235^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=b2ac2a41dd3fe03ec6877348c375ccff0fb4c95b;p=lhc%2Fweb%2Fwiklou.git 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 --- 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' ); + } }