Add ContentHandler::supportsCategories method
authoraude <aude.wiki@gmail.com>
Mon, 15 Feb 2016 15:19:58 +0000 (16:19 +0100)
committeraude <aude.wiki@gmail.com>
Wed, 2 Mar 2016 14:20:56 +0000 (15:20 +0100)
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

RELEASE-NOTES-1.27
includes/content/ContentHandler.php
includes/page/WikiPage.php
tests/phpunit/includes/content/ContentHandlerTest.php

index 867abd7..b8ec76d 100644 (file)
@@ -319,6 +319,9 @@ changes to languages because of Phabricator reports.
   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 ==
 
index 6bc6abf..9ab11f3 100644 (file)
@@ -1082,6 +1082,16 @@ abstract class ContentHandler {
                return false;
        }
 
+       /**
+        * 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.
index 3308890..27412ed 100644 (file)
@@ -2261,6 +2261,7 @@ class WikiPage implements Page, IDBAccessObject {
                                DeferredUpdates::addUpdate( $update );
                        }
                        if ( $wgRCWatchCategoryMembership
+                               && $this->getContentHandler()->supportsCategories() === true
                                && ( $options['changed'] || $options['created'] )
                                && !$options['restored']
                        ) {
index 9c17c3e..91f27fb 100644 (file)
@@ -350,6 +350,11 @@ class ContentHandlerTest extends MediaWikiTestCase {
        }
        */
 
+       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' );