Follows-up
39a6e3dc4d. Class-based feeds are always given their parameters
by RCFeed::factory. However because the old getEngine() method insists
on creating its own object, the constructor parameters were not given.
Add it as optional parameter and pass it through there.
This is backwards-compatible still because before the
39a6e3dc4d refactor,
an RCFeedEngine also was not given information about any formatter and it
was the callers responsibility to format the line before calling send().
CentralAuth still uses it this way and that works fine. The core-caller
that expected the construction parameters since
39a6e3dc4d is hereby fixed.
The test couldn't catch this because it constructed the class instance there,
since PHPUnit does not support a mock class that is instantiated by foreign
code, and the parameter is passed there.
Bug: T156996
Bug: T157106
Change-Id: I83433cf57b6e040cdb69f3ad8807a999c4f931a5
* 'omit_bots' => true,
* ];
* @example $wgRCFeeds['example'] = [
- * 'class' => 'ExampleRCFeed',
+ * 'class' => 'ExampleRCFeed',
* ];
* @since 1.22
*/
* @return RCFeedEngine The engine object
* @throws MWException
*/
- public static function getEngine( $uri ) {
+ public static function getEngine( $uri, $params = [] ) {
// TODO: Merge into RCFeed::factory().
global $wgRCEngines;
$scheme = parse_url( $uri, PHP_URL_SCHEME );
if ( defined( 'MW_PHPUNIT_TEST' ) && is_object( $wgRCEngines[$scheme] ) ) {
return $wgRCEngines[$scheme];
}
- return new $wgRCEngines[$scheme];
+ return new $wgRCEngines[$scheme]( $params );
}
/**
if ( !isset( $params['uri'] ) ) {
throw new Exception( "RCFeeds must have a 'class' or 'uri' set." );
}
- return RecentChange::getEngine( $params['uri'] );
+ return RecentChange::getEngine( $params['uri'], $params );
}
$class = $params['class'];
if ( !class_exists( $class ) ) {