From 8e980dfbf518836e958cb2351ee5ff9e44fc9081 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Mon, 26 May 2014 17:50:11 -0700 Subject: [PATCH] Allow more flexibility in RC feeds The user can now specify which feeds to send to in RecentChange::notifyFeeds if they don't want to use $wgRCFeeds. Additionally, the 'formatter' in $wgRCFeeds can now be an object rather than just a class name. Change-Id: Ibfdffc17a934e35223887c123331795563102752 --- includes/DefaultSettings.php | 2 +- includes/changes/RecentChange.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 796e0c079d..84a9e2146f 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -5608,7 +5608,7 @@ $wgRC2UDPOmitBots = false; * The common options are: * * 'uri' -- the address to which the notices are to be sent. * * 'formatter' -- the class name (implementing RCFeedFormatter) which will - * produce the text to send. + * produce the text to send. This can also be an object of the class. * * 'omit_bots' -- whether the bot edits should be in the feed * * 'omit_anon' -- whether anonymous edits should be in the feed * * 'omit_user' -- whether edits by registered users should be in the feed diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php index 3a5a86906e..370e109a87 100644 --- a/includes/changes/RecentChange.php +++ b/includes/changes/RecentChange.php @@ -390,13 +390,17 @@ class RecentChange { /** * Notify all the feeds about the change. + * @param array $feeds Optional feeds to send to, defaults to $wgRCFeeds */ - public function notifyRCFeeds() { + public function notifyRCFeeds( array $feeds = null ) { global $wgRCFeeds; + if ( $feeds === null ) { + $feeds = $wgRCFeeds; + } $performer = $this->getPerformer(); - foreach ( $wgRCFeeds as $feed ) { + foreach ( $feeds as $feed ) { $feed += array( 'omit_bots' => false, 'omit_anon' => false, @@ -425,7 +429,7 @@ class RecentChange { } /** @var $formatter RCFeedFormatter */ - $formatter = new $feed['formatter'](); + $formatter = is_object( $feed['formatter'] ) ? $feed['formatter'] : new $feed['formatter'](); $line = $formatter->getLine( $feed, $this, $actionComment ); $engine->send( $feed, $line ); -- 2.20.1