Expose LinksUpdate recursive flag with a getter
authorDavid Causse <dcausse@wikimedia.org>
Wed, 11 Sep 2019 14:48:02 +0000 (16:48 +0200)
committerDavid Causse <dcausse@wikimedia.org>
Wed, 11 Sep 2019 14:55:39 +0000 (16:55 +0200)
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
tests/phpunit/includes/deferred/LinksUpdateTest.php

index 8345ee6..5941849 100644 (file)
@@ -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;
+       }
 }
index cd3ddfa..1f9d29e 100644 (file)
@@ -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' );
+       }
 }