Fix categories with a namespace prefix in the cat name for CatWatch
authoraddshore <addshorewiki@gmail.com>
Fri, 4 Dec 2015 11:03:44 +0000 (12:03 +0100)
committeraddshore <addshorewiki@gmail.com>
Fri, 4 Dec 2015 11:03:44 +0000 (12:03 +0100)
Title::newFromText will use the given namespace as default, but when
parsing a title with a namespace at the begin the method will not use
the default, instead used the namespace from the given text.
Use Title::makeTitle to create a title with always belongs to the given
namespace.

Bug: T119763
Change-Id: Ic96671e1c33c6572b07f0f859d97c85a7a15bd39

includes/jobqueue/jobs/CategoryMembershipChangeJob.php

index 2b0018d..c9e20a9 100644 (file)
@@ -165,7 +165,7 @@ class CategoryMembershipChangeJob extends Job {
                $insertCount = 0;
 
                foreach ( $categoryInserts as $categoryName ) {
-                       $categoryTitle = Title::newFromText( $categoryName, NS_CATEGORY );
+                       $categoryTitle = Title::makeTitle( NS_CATEGORY, $categoryName );
                        $catMembChange->triggerCategoryAddedNotification( $categoryTitle );
                        if ( $insertCount++ && ( $insertCount % $batchSize ) == 0 ) {
                                $dbw->commit( __METHOD__, 'flush' );
@@ -174,7 +174,7 @@ class CategoryMembershipChangeJob extends Job {
                }
 
                foreach ( $categoryDeletes as $categoryName ) {
-                       $categoryTitle = Title::newFromText( $categoryName, NS_CATEGORY );
+                       $categoryTitle = Title::makeTitle( NS_CATEGORY, $categoryName );
                        $catMembChange->triggerCategoryRemovedNotification( $categoryTitle );
                        if ( $insertCount++ && ( $insertCount++ % $batchSize ) == 0 ) {
                                $dbw->commit( __METHOD__, 'flush' );