Fix CatMemberChanges for numeric category names
authoraddshore <addshorewiki@gmail.com>
Thu, 3 Dec 2015 13:09:34 +0000 (14:09 +0100)
committeraddshore <addshorewiki@gmail.com>
Thu, 3 Dec 2015 13:19:44 +0000 (14:19 +0100)
Change-Id: I5ff3ff2d26d8e2d0b4250843f028eabc96020ccc

includes/jobqueue/jobs/CategoryMembershipChangeJob.php

index 4487970..2b0018d 100644 (file)
@@ -205,6 +205,13 @@ class CategoryMembershipChangeJob extends Job {
                return array( $categoryInserts, $categoryDeletes );
        }
 
+       /**
+        * @param Title $title
+        * @param Revision $rev
+        * @param string $parseTimestamp TS_MW
+        *
+        * @return string[] category names
+        */
        private function getCategoriesAtRev( Title $title, Revision $rev, $parseTimestamp ) {
                $content = $rev->getContent();
                $options = $content->getContentHandler()->makeParserOptions( 'canonical' );
@@ -213,7 +220,9 @@ class CategoryMembershipChangeJob extends Job {
                // but that's more complicated than it's worth.
                $output = $content->getParserOutput( $title, $rev->getId(), $options );
 
-               return array_keys( $output->getCategories() );
+               // array keys will cast numeric category names to ints
+               // so we need to cast them back to strings to avoid breaking things!
+               return array_map( 'strval', array_keys( $output->getCategories() ) );
        }
 
        public function getDeduplicationInfo() {