From a76af536004a770835fe65f747c022f1e42c4e3f Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sat, 4 Jan 2014 21:10:13 -0800 Subject: [PATCH] Cleanup of includes/rcfeed * Added license headers to everything * Added @since tags for all classes * Use wfParseUrl instead of parse_url * Check for RedisConnectionPool::getConnection returning false Change-Id: I7db808c0465bd869de3f2daa82444b5e3d1268c2 --- .../rcfeed/IRCColourfulRCFeedFormatter.php | 27 +++++++- includes/rcfeed/JSONRCFeedFormatter.php | 25 ++++++++ includes/rcfeed/RCFeedEngine.php | 25 ++++++++ includes/rcfeed/RCFeedFormatter.php | 27 +++++++- includes/rcfeed/RedisPubSubFeedEngine.php | 62 ++++++++++++++----- includes/rcfeed/UDPRCFeedEngine.php | 26 +++++++- 6 files changed, 173 insertions(+), 19 deletions(-) diff --git a/includes/rcfeed/IRCColourfulRCFeedFormatter.php b/includes/rcfeed/IRCColourfulRCFeedFormatter.php index 507369f390..ddbb548540 100644 --- a/includes/rcfeed/IRCColourfulRCFeedFormatter.php +++ b/includes/rcfeed/IRCColourfulRCFeedFormatter.php @@ -1,7 +1,32 @@ 'JSONRCFeedFormatter', + * 'uri' => "redis://127.0.0.1:6379/rc.$wgDBname", + * ); + * + * @since 1.22 + */ class RedisPubSubFeedEngine implements RCFeedEngine { + /** - * Emit a recent change notification via Redis Pub/Sub - * - * If the feed URI contains a path component, it will be used to generate a - * channel name by stripping the leading slash and replacing any remaining - * slashes with '.'. If no path component is present, the channel is set to - * 'rc'. If the URI contains a query string, its parameters will be parsed - * as RedisConnectionPool options. - * - * @example $wgRCFeeds['redis'] = array( - * 'formatter' => 'JSONRCFeedFormatter', - * 'uri' => "redis://127.0.0.1:6379/rc.$wgDBname", - * ); - * - * @since 1.22 + * @see RCFeedEngine::send */ public function send( array $feed, $line ) { - $parsed = parse_url( $feed['uri'] ); + $parsed = wfParseUrl( $feed['uri'] ); $server = $parsed['host']; $options = array( 'serializer' => 'none' ); $channel = 'rc'; @@ -36,6 +61,11 @@ class RedisPubSubFeedEngine implements RCFeedEngine { } $pool = RedisConnectionPool::singleton( $options ); $conn = $pool->getConnection( $server ); - $conn->publish( $channel, $line ); + if ( $conn !== false ) { + $conn->publish( $channel, $line ); + return true; + } else { + return false; + } } } diff --git a/includes/rcfeed/UDPRCFeedEngine.php b/includes/rcfeed/UDPRCFeedEngine.php index beeb73bd78..8554670e13 100644 --- a/includes/rcfeed/UDPRCFeedEngine.php +++ b/includes/rcfeed/UDPRCFeedEngine.php @@ -1,7 +1,31 @@