Aude has uploaded a new change for review.
https://gerrit.wikimedia.org/r/270749
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, 18 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/49/270749/1
diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27
index 3a83b36..974c189 100644
--- a/RELEASE-NOTES-1.27
+++ b/RELEASE-NOTES-1.27
@@ -317,6 +317,8 @@
rather than consume everything until the end of the page.
* New maintenance script resetUserEmail.php allows sysadmins to reset user
emails in case
a user forgot password/account was stolen.
+* ContentHandler::supportsCategories method added. 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 e898e72..8fd7837 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 cfd8d6b..58c6b91 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 a72247b..6e02e2f 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: newchange
Gerrit-Change-Id: I2c54a4ba1546445dc41101e15cb83a2c6cc2b1c9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits