RC: Handle getLine returning null, which breaks Redis engine (at least HHVM)
authorMatthew Flaschen <mflaschen@wikimedia.org>
Wed, 19 Aug 2015 02:57:39 +0000 (22:57 -0400)
committerMatthew Flaschen <mflaschen@wikimedia.org>
Wed, 19 Aug 2015 03:08:36 +0000 (23:08 -0400)
Bug: T109544
Change-Id: I02dcfc7a10a74571232a898f1ef348f8dbc48b45

includes/changes/RecentChange.php
includes/rcfeed/RCFeedFormatter.php

index 77bf5df..54ca2ab 100644 (file)
@@ -382,6 +382,13 @@ class RecentChange {
                        /** @var $formatter RCFeedFormatter */
                        $formatter = is_object( $feed['formatter'] ) ? $feed['formatter'] : new $feed['formatter']();
                        $line = $formatter->getLine( $feed, $this, $actionComment );
+                       if ( !$line ) {
+                               // T109544
+                               // If a feed formatter returns null, this will otherwise cause an
+                               // error in at least RedisPubSubFeedEngine.
+                               // Not sure where/how this should best be handled.
+                               continue;
+                       }
 
                        $engine->send( $feed, $line );
                }
index 2f15659..f7e62ee 100644 (file)
@@ -32,7 +32,8 @@ interface RCFeedFormatter {
         * @param RecentChange $rc The RecentChange object showing what sort
         *                         of event has taken place.
         * @param string|null $actionComment
-        * @return string The text to send.
+        * @return string|null The text to send.  If the formatter returns null,
+        *  the line will not be sent.
         */
        public function getLine( array $feed, RecentChange $rc, $actionComment );
 }