From: Kunal Mehta Date: Tue, 27 May 2014 00:50:11 +0000 (-0700) Subject: Allow more flexibility in RC feeds X-Git-Tag: 1.31.0-rc.0~15583^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=8e980dfbf518836e958cb2351ee5ff9e44fc9081;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 );