jenkins-bot has submitted this change and it was merged.

Change subject: Add ContentHandler::supportsCategories method
......................................................................


Add ContentHandler::supportsCategories method

and check for this in WikiPage::doEditUpdates before
inserting a new CategoryMembershipChangeJob.

Some content models like the Wikibase ones do not
have categories and it's wasteful to add these jobs
for all Wikibase edits.

Bug: T126977
Change-Id: I2c54a4ba1546445dc41101e15cb83a2c6cc2b1c9
---
M RELEASE-NOTES-1.27
M includes/content/ContentHandler.php
M includes/page/WikiPage.php
M tests/phpunit/includes/content/ContentHandlerTest.php
4 files changed, 19 insertions(+), 0 deletions(-)

Approvals:
  Daniel Kinzler: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27
index 867abd7..b8ec76d 100644
--- a/RELEASE-NOTES-1.27
+++ b/RELEASE-NOTES-1.27
@@ -319,6 +319,9 @@
   a user forgot password/account was stolen.
 * wfCheckEntropy() was removed (deprecated in 1.27).
 * Browser support for Internet Explorer 8 lowered from Grade A to Grade C.
+* ContentHandler::supportsCategories method added. Default is true.
+  CategoryMembershipChangeJob updates are skipped for content that
+  does not support categories.
 
 == Compatibility ==
 
diff --git a/includes/content/ContentHandler.php 
b/includes/content/ContentHandler.php
index 6bc6abf..9ab11f3 100644
--- a/includes/content/ContentHandler.php
+++ b/includes/content/ContentHandler.php
@@ -1083,6 +1083,16 @@
        }
 
        /**
+        * Returns true if this content model supports categories.
+        * The default implementation returns true.
+        *
+        * @return bool Always true.
+        */
+       public function supportsCategories() {
+               return true;
+       }
+
+       /**
         * Returns true if this content model supports redirects.
         * This default implementation returns false.
         *
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index 3308890..27412ed 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -2261,6 +2261,7 @@
                                DeferredUpdates::addUpdate( $update );
                        }
                        if ( $wgRCWatchCategoryMembership
+                               && 
$this->getContentHandler()->supportsCategories() === true
                                && ( $options['changed'] || $options['created'] 
)
                                && !$options['restored']
                        ) {
diff --git a/tests/phpunit/includes/content/ContentHandlerTest.php 
b/tests/phpunit/includes/content/ContentHandlerTest.php
index 9c17c3e..91f27fb 100644
--- a/tests/phpunit/includes/content/ContentHandlerTest.php
+++ b/tests/phpunit/includes/content/ContentHandlerTest.php
@@ -350,6 +350,11 @@
        }
        */
 
+       public function testSupportsCategories() {
+               $handler = new DummyContentHandlerForTesting( 
CONTENT_MODEL_WIKITEXT );
+               $this->assertTrue( $handler->supportsCategories(), 'content 
model supports categories' );
+       }
+
        public function testSupportsDirectEditing() {
                $handler = new DummyContentHandlerForTesting( 
CONTENT_MODEL_JSON );
                $this->assertFalse( $handler->supportsDirectEditing(), 'direct 
editing is not supported' );

-- 
To view, visit https://gerrit.wikimedia.org/r/270749
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2c54a4ba1546445dc41101e15cb83a2c6cc2b1c9
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to