aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--autoload.php10
-rw-r--r--docs/config-schema.yaml4
-rw-r--r--includes/Feed/AtomFeed.php (renamed from includes/changes/AtomFeed.php)4
-rw-r--r--includes/Feed/ChannelFeed.php (renamed from includes/changes/ChannelFeed.php)6
-rw-r--r--includes/Feed/FeedItem.php (renamed from includes/changes/FeedItem.php)6
-rw-r--r--includes/Feed/FeedUtils.php (renamed from includes/FeedUtils.php)40
-rw-r--r--includes/Feed/RSSFeed.php (renamed from includes/changes/RSSFeed.php)4
-rw-r--r--includes/MainConfigSchema.php4
-rw-r--r--includes/actions/HistoryAction.php6
-rw-r--r--includes/api/ApiFeedContributions.php3
-rw-r--r--includes/api/ApiFeedRecentChanges.php3
-rw-r--r--includes/api/ApiFeedWatchlist.php1
-rw-r--r--includes/api/ApiFormatFeedWrapper.php9
-rw-r--r--includes/api/Hook/ApiFeedContributions__feedItemHook.php9
-rw-r--r--includes/changes/ChangesFeed.php7
-rw-r--r--includes/config-schema.php4
-rw-r--r--includes/specials/SpecialNewpages.php1
-rw-r--r--tests/phpunit/unit/includes/Feed/FeedUtilsTest.php (renamed from tests/phpunit/unit/includes/FeedUtilsTest.php)4
18 files changed, 87 insertions, 38 deletions
diff --git a/autoload.php b/autoload.php
index 18ac924f021c..8874662c130b 100644
--- a/autoload.php
+++ b/autoload.php
@@ -160,7 +160,7 @@ $wgAutoloadLocalClasses = [
'ArrayUtils' => __DIR__ . '/includes/libs/ArrayUtils.php',
'Article' => __DIR__ . '/includes/page/Article.php',
'AssembleUploadChunksJob' => __DIR__ . '/includes/jobqueue/jobs/AssembleUploadChunksJob.php',
- 'AtomFeed' => __DIR__ . '/includes/changes/AtomFeed.php',
+ 'AtomFeed' => __DIR__ . '/includes/Feed/AtomFeed.php',
'AtomicSectionUpdate' => __DIR__ . '/includes/deferred/AtomicSectionUpdate.php',
'AttachLatest' => __DIR__ . '/maintenance/attachLatest.php',
'AuthManagerSpecialPage' => __DIR__ . '/includes/specialpage/AuthManagerSpecialPage.php',
@@ -241,7 +241,7 @@ $wgAutoloadLocalClasses = [
'ChangesListSpecialPage' => __DIR__ . '/includes/specialpage/ChangesListSpecialPage.php',
'ChangesListStringOptionsFilter' => __DIR__ . '/includes/changes/ChangesListStringOptionsFilter.php',
'ChangesListStringOptionsFilterGroup' => __DIR__ . '/includes/changes/ChangesListStringOptionsFilterGroup.php',
- 'ChannelFeed' => __DIR__ . '/includes/changes/ChannelFeed.php',
+ 'ChannelFeed' => __DIR__ . '/includes/Feed/ChannelFeed.php',
'CheckBadRedirects' => __DIR__ . '/maintenance/checkBadRedirects.php',
'CheckComposerLockUpToDate' => __DIR__ . '/maintenance/checkComposerLockUpToDate.php',
'CheckDependencies' => __DIR__ . '/maintenance/checkDependencies.php',
@@ -478,8 +478,8 @@ $wgAutoloadLocalClasses = [
'FauxResponse' => __DIR__ . '/includes/FauxResponse.php',
'FauxSearchResult' => __DIR__ . '/includes/search/FauxSearchResult.php',
'FauxSearchResultSet' => __DIR__ . '/includes/search/FauxSearchResultSet.php',
- 'FeedItem' => __DIR__ . '/includes/changes/FeedItem.php',
- 'FeedUtils' => __DIR__ . '/includes/FeedUtils.php',
+ 'FeedItem' => __DIR__ . '/includes/Feed/FeedItem.php',
+ 'FeedUtils' => __DIR__ . '/includes/Feed/FeedUtils.php',
'FetchText' => __DIR__ . '/maintenance/fetchText.php',
'Field' => __DIR__ . '/includes/libs/rdbms/field/Field.php',
'File' => __DIR__ . '/includes/filerepo/file/File.php',
@@ -1292,7 +1292,7 @@ $wgAutoloadLocalClasses = [
'RCFeedEngine' => __DIR__ . '/includes/rcfeed/FormattedRCFeed.php',
'RCFeedFormatter' => __DIR__ . '/includes/rcfeed/RCFeedFormatter.php',
'RESTBagOStuff' => __DIR__ . '/includes/libs/objectcache/RESTBagOStuff.php',
- 'RSSFeed' => __DIR__ . '/includes/changes/RSSFeed.php',
+ 'RSSFeed' => __DIR__ . '/includes/Feed/RSSFeed.php',
'RandomPage' => __DIR__ . '/includes/specials/SpecialRandomPage.php',
'RangeChronologicalPager' => __DIR__ . '/includes/pager/RangeChronologicalPager.php',
'RangeDifference' => __DIR__ . '/includes/diff/RangeDifference.php',
diff --git a/docs/config-schema.yaml b/docs/config-schema.yaml
index 879bd1f6e2e5..de1b614a5c96 100644
--- a/docs/config-schema.yaml
+++ b/docs/config-schema.yaml
@@ -6394,8 +6394,8 @@ config-schema:
```
FeedClasses:
default:
- rss: RSSFeed
- atom: AtomFeed
+ rss: MediaWiki\Feed\RSSFeed
+ atom: MediaWiki\Feed\AtomFeed
type: object
description: |-
Available feeds objects.
diff --git a/includes/changes/AtomFeed.php b/includes/Feed/AtomFeed.php
index e177e8e91114..4574a6230c66 100644
--- a/includes/changes/AtomFeed.php
+++ b/includes/Feed/AtomFeed.php
@@ -22,6 +22,8 @@
* @file
*/
+namespace MediaWiki\Feed;
+
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
@@ -114,3 +116,5 @@ class AtomFeed extends ChannelFeed {
print "</feed>";
}
}
+
+class_alias( AtomFeed::class, 'AtomFeed' );
diff --git a/includes/changes/ChannelFeed.php b/includes/Feed/ChannelFeed.php
index 88625bc64e77..2a58ba90784a 100644
--- a/includes/changes/ChannelFeed.php
+++ b/includes/Feed/ChannelFeed.php
@@ -22,8 +22,12 @@
* @file
*/
+namespace MediaWiki\Feed;
+
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
+use TemplateParser;
+use Title;
/**
* Class to support the outputting of syndication feeds in Atom and RSS format.
@@ -139,3 +143,5 @@ abstract class ChannelFeed extends FeedItem {
echo '<?xml version="1.0"?>' . "\n";
}
}
+
+class_alias( ChannelFeed::class, 'ChannelFeed' );
diff --git a/includes/changes/FeedItem.php b/includes/Feed/FeedItem.php
index dab7615393b5..2968b964e228 100644
--- a/includes/changes/FeedItem.php
+++ b/includes/Feed/FeedItem.php
@@ -21,8 +21,12 @@
* @file
*/
+namespace MediaWiki\Feed;
+
+use LanguageCode;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
+use Title;
/**
* @defgroup Feed Feed
@@ -227,3 +231,5 @@ class FeedItem {
/** #@- */
}
+
+class_alias( FeedItem::class, 'FeedItem' );
diff --git a/includes/FeedUtils.php b/includes/Feed/FeedUtils.php
index a907fc66e7d1..2e818f680673 100644
--- a/includes/FeedUtils.php
+++ b/includes/Feed/FeedUtils.php
@@ -21,10 +21,22 @@
* @ingroup Feed
*/
+namespace MediaWiki\Feed;
+
+use CommentStore;
+use Html;
+use Linker;
+use LogFormatter;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
+use OutputPage;
+use RequestContext;
+use TextContent;
+use Title;
+use User;
+use UtfNormal;
/**
* Helper functions for feeds
@@ -36,11 +48,11 @@ class FeedUtils {
/**
* Check whether feeds can be used and that $type is a valid feed type
*
- * @since 1.36 $output parameter added
- *
* @param string $type Feed type, as requested by the user
* @param OutputPage|null $output Null falls back to $wgOut
* @return bool
+ * @since 1.36 $output parameter added
+ *
*/
public static function checkFeedOutput( $type, $output = null ) {
$feed = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::Feed );
@@ -67,7 +79,7 @@ class FeedUtils {
/**
* Format a diff for the newsfeed
*
- * @param stdClass $row Row from the recentchanges table, including fields as
+ * @param \stdClass $row Row from the recentchanges table, including fields as
* appropriate for CommentStore
* @param string|null $formattedComment rc_comment in HTML format, or null
* to format it on demand.
@@ -98,8 +110,6 @@ class FeedUtils {
/**
* Really format a diff for the newsfeed
*
- * @deprecated since 1.38 use formatDiffRow2
- *
* @param Title $title
* @param int $oldid Old revision's id
* @param int $newid New revision's id
@@ -107,9 +117,11 @@ class FeedUtils {
* @param string $comment New revision's comment
* @param string $actiontext Text of the action; in case of log event
* @return string
+ * @deprecated since 1.38 use formatDiffRow2
+ *
*/
public static function formatDiffRow( $title, $oldid, $newid, $timestamp,
- $comment, $actiontext = ''
+ $comment, $actiontext = ''
) {
$formattedComment = MediaWikiServices::getInstance()->getCommentFormatter()
->format( $comment );
@@ -130,7 +142,7 @@ class FeedUtils {
* @return string
*/
public static function formatDiffRow2( $title, $oldid, $newid, $timestamp,
- $formattedComment, $actiontext = ''
+ $formattedComment, $actiontext = ''
) {
$feedDiffCutoff = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::FeedDiffCutoff );
@@ -283,19 +295,19 @@ class FeedUtils {
*/
public static function applyDiffStyle( $text ) {
$styles = [
- 'diff' => 'background-color: #fff; color: #202122;',
- 'diff-otitle' => 'background-color: #fff; color: #202122; text-align: center;',
- 'diff-ntitle' => 'background-color: #fff; color: #202122; text-align: center;',
- 'diff-addedline' => 'color: #202122; font-size: 88%; border-style: solid; '
+ 'diff' => 'background-color: #fff; color: #202122;',
+ 'diff-otitle' => 'background-color: #fff; color: #202122; text-align: center;',
+ 'diff-ntitle' => 'background-color: #fff; color: #202122; text-align: center;',
+ 'diff-addedline' => 'color: #202122; font-size: 88%; border-style: solid; '
. 'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; '
. 'vertical-align: top; white-space: pre-wrap;',
'diff-deletedline' => 'color: #202122; font-size: 88%; border-style: solid; '
. 'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; '
. 'vertical-align: top; white-space: pre-wrap;',
- 'diff-context' => 'background-color: #f8f9fa; color: #202122; font-size: 88%; '
+ 'diff-context' => 'background-color: #f8f9fa; color: #202122; font-size: 88%; '
. 'border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; '
. 'border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;',
- 'diffchange' => 'font-weight: bold; text-decoration: none;',
+ 'diffchange' => 'font-weight: bold; text-decoration: none;',
];
foreach ( $styles as $class => $style ) {
@@ -308,3 +320,5 @@ class FeedUtils {
}
}
+
+class_alias( FeedUtils::class, 'FeedUtils' );
diff --git a/includes/changes/RSSFeed.php b/includes/Feed/RSSFeed.php
index ec72d9f143c7..1e3efa727c83 100644
--- a/includes/changes/RSSFeed.php
+++ b/includes/Feed/RSSFeed.php
@@ -21,6 +21,8 @@
* @file
*/
+namespace MediaWiki\Feed;
+
/**
* Generate an RSS feed.
*
@@ -90,3 +92,5 @@ class RSSFeed extends ChannelFeed {
print "</channel></rss>";
}
}
+
+class_alias( RSSFeed::class, 'RSSFeed' );
diff --git a/includes/MainConfigSchema.php b/includes/MainConfigSchema.php
index bbd7ebbf3167..d8dcdd5b010d 100644
--- a/includes/MainConfigSchema.php
+++ b/includes/MainConfigSchema.php
@@ -10252,8 +10252,8 @@ class MainConfigSchema {
*/
public const FeedClasses = [
'default' => [
- 'rss' => 'RSSFeed',
- 'atom' => 'AtomFeed',
+ 'rss' => \MediaWiki\Feed\RSSFeed::class,
+ 'atom' => \MediaWiki\Feed\AtomFeed::class,
],
'type' => 'map',
];
diff --git a/includes/actions/HistoryAction.php b/includes/actions/HistoryAction.php
index f75e840680a0..88f7d28bebe0 100644
--- a/includes/actions/HistoryAction.php
+++ b/includes/actions/HistoryAction.php
@@ -21,6 +21,10 @@
* @ingroup Actions
*/
+use MediaWiki\Feed\AtomFeed;
+use MediaWiki\Feed\FeedItem;
+use MediaWiki\Feed\FeedUtils;
+use MediaWiki\Feed\RSSFeed;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\FakeResultWrapper;
@@ -426,7 +430,7 @@ class HistoryAction extends FormlessAction {
}
/**
- * Generate a FeedItem object from a given revision table row
+ * Generate a MediaWiki\Feed\FeedItem object from a given revision table row
* Borrows Recent Changes' feed generation functions for formatting;
* includes a diff to the previous revision (if any).
*
diff --git a/includes/api/ApiFeedContributions.php b/includes/api/ApiFeedContributions.php
index 352083b2cc29..9627fedaedac 100644
--- a/includes/api/ApiFeedContributions.php
+++ b/includes/api/ApiFeedContributions.php
@@ -23,6 +23,7 @@
use MediaWiki\Api\ApiHookRunner;
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\CommentFormatter\CommentFormatter;
+use MediaWiki\Feed\FeedItem;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\Linker\LinkRenderer;
use MediaWiki\MainConfigNames;
@@ -282,7 +283,7 @@ class ApiFeedContributions extends ApiBase {
// XXX: we could get an HTML representation of the content via getParserOutput, but that may
// contain JS magic and generally may not be suitable for inclusion in a feed.
// Perhaps Content should have a getDescriptiveHtml method and/or a getSourceText method.
- // Compare also FeedUtils::formatDiffRow.
+ // Compare also MediaWiki\Feed\FeedUtils::formatDiffRow.
$html = '';
}
diff --git a/includes/api/ApiFeedRecentChanges.php b/includes/api/ApiFeedRecentChanges.php
index f8f3b2c17acc..10c75802412d 100644
--- a/includes/api/ApiFeedRecentChanges.php
+++ b/includes/api/ApiFeedRecentChanges.php
@@ -19,6 +19,7 @@
* @since 1.23
*/
+use MediaWiki\Feed\ChannelFeed;
use MediaWiki\MainConfigNames;
use MediaWiki\SpecialPage\SpecialPageFactory;
use Wikimedia\ParamValidator\ParamValidator;
@@ -113,7 +114,7 @@ class ApiFeedRecentChanges extends ApiBase {
}
/**
- * Return a ChannelFeed object.
+ * Return a MediaWiki\Feed\ChannelFeed object.
*
* @param string $feedFormat Feed's format (either 'rss' or 'atom')
* @param string $specialPageName Relevant special page name (either 'Recentchanges' or
diff --git a/includes/api/ApiFeedWatchlist.php b/includes/api/ApiFeedWatchlist.php
index f7b32687a7c4..e4dfb83d1b21 100644
--- a/includes/api/ApiFeedWatchlist.php
+++ b/includes/api/ApiFeedWatchlist.php
@@ -20,6 +20,7 @@
* @file
*/
+use MediaWiki\Feed\FeedItem;
use MediaWiki\MainConfigNames;
use Wikimedia\ParamValidator\ParamValidator;
use Wikimedia\ParamValidator\TypeDef\IntegerDef;
diff --git a/includes/api/ApiFormatFeedWrapper.php b/includes/api/ApiFormatFeedWrapper.php
index 00e997dcc5ee..83c9ef02dafd 100644
--- a/includes/api/ApiFormatFeedWrapper.php
+++ b/includes/api/ApiFormatFeedWrapper.php
@@ -20,6 +20,9 @@
* @file
*/
+use MediaWiki\Feed\ChannelFeed;
+use MediaWiki\Feed\FeedItem;
+
/**
* This printer is used to wrap an instance of the Feed class
* @ingroup API
@@ -56,7 +59,7 @@ class ApiFormatFeedWrapper extends ApiFormatBase {
}
/**
- * ChannelFeed doesn't give us a method to print errors in a friendly
+ * MediaWiki\Feed\ChannelFeed doesn't give us a method to print errors in a friendly
* manner, so just punt errors to the default printer.
* @return bool
*/
@@ -67,7 +70,7 @@ class ApiFormatFeedWrapper extends ApiFormatBase {
/**
* This class expects the result data to be in a custom format set by self::setResult()
* $result['_feed'] - an instance of one of the $wgFeedClasses classes
- * $result['_feeditems'] - an array of FeedItem instances
+ * $result['_feeditems'] - an array of MediaWiki\Feed\FeedItem instances
* @param bool $unused
*/
public function initPrinter( $unused = false ) {
@@ -91,7 +94,7 @@ class ApiFormatFeedWrapper extends ApiFormatBase {
/**
* This class expects the result data to be in a custom format set by self::setResult()
* $result['_feed'] - an instance of one of the $wgFeedClasses classes
- * $result['_feeditems'] - an array of FeedItem instances
+ * $result['_feeditems'] - an array of MediaWiki\Feed\FeedItem instances
*/
public function execute() {
$data = $this->getResult()->getResultData();
diff --git a/includes/api/Hook/ApiFeedContributions__feedItemHook.php b/includes/api/Hook/ApiFeedContributions__feedItemHook.php
index 5c274e28861b..b398c0b89c65 100644
--- a/includes/api/Hook/ApiFeedContributions__feedItemHook.php
+++ b/includes/api/Hook/ApiFeedContributions__feedItemHook.php
@@ -3,7 +3,6 @@
namespace MediaWiki\Api\Hook;
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
-use FeedItem;
use IContextSource;
use stdClass;
@@ -16,20 +15,20 @@ use stdClass;
*/
interface ApiFeedContributions__feedItemHook {
/**
- * Use this hook to convert the result of ContribsPager into a FeedItem instance
+ * Use this hook to convert the result of ContribsPager into a MediaWiki\Feed\FeedItem instance
* that ApiFeedContributions can consume. Implementors of this hook may cancel
* the hook to signal that the item is not viewable in the provided context.
*
- * @since 1.35
- *
* @param stdClass $row A row of data from ContribsPager. The set of data returned by
* ContribsPager can be adjusted by handling the ContribsPager::reallyDoQuery
* hook.
* @param IContextSource $context
- * @param FeedItem|null &$feedItem Set this to a FeedItem instance if the callback can handle the
+ * @param \MediaWiki\Feed\FeedItem|null &$feedItem Set this to a FeedItem instance if the callback can handle the
* provided row. This is provided to the hook as a null, if it is non-null then
* another callback has already handled the hook.
* @return bool|void True or no return value to continue or false to abort
+ * @since 1.35
+ *
*/
public function onApiFeedContributions__feedItem( $row, $context, &$feedItem );
}
diff --git a/includes/changes/ChangesFeed.php b/includes/changes/ChangesFeed.php
index f7387800760e..dfdf72ac9cde 100644
--- a/includes/changes/ChangesFeed.php
+++ b/includes/changes/ChangesFeed.php
@@ -20,6 +20,9 @@
* @file
*/
+use MediaWiki\Feed\ChannelFeed;
+use MediaWiki\Feed\FeedItem;
+use MediaWiki\Feed\FeedUtils;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;
@@ -41,12 +44,12 @@ class ChangesFeed {
}
/**
- * Get a ChannelFeed subclass object to use
+ * Get a MediaWiki\Feed\ChannelFeed subclass object to use
*
* @param string $title Feed's title
* @param string $description Feed's description
* @param string $url Url of origin page
- * @return ChannelFeed|bool ChannelFeed subclass or false on failure
+ * @return ChannelFeed|bool MediaWiki\Feed\ChannelFeed subclass or false on failure
*/
public function getFeedObject( $title, $description, $url ) {
$mainConfig = MediaWikiServices::getInstance()->getMainConfig();
diff --git a/includes/config-schema.php b/includes/config-schema.php
index 1fd22236ab09..edbaddeb113b 100644
--- a/includes/config-schema.php
+++ b/includes/config-schema.php
@@ -1913,8 +1913,8 @@ return [
'OverrideSiteFeed' => [
],
'FeedClasses' => [
- 'rss' => 'RSSFeed',
- 'atom' => 'AtomFeed',
+ 'rss' => 'MediaWiki\\Feed\\RSSFeed',
+ 'atom' => 'MediaWiki\\Feed\\AtomFeed',
],
'AdvertisedFeedTypes' => [
0 => 'atom',
diff --git a/includes/specials/SpecialNewpages.php b/includes/specials/SpecialNewpages.php
index 0c641720105b..59687e226524 100644
--- a/includes/specials/SpecialNewpages.php
+++ b/includes/specials/SpecialNewpages.php
@@ -23,6 +23,7 @@
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\Content\IContentHandlerFactory;
+use MediaWiki\Feed\FeedItem;
use MediaWiki\MainConfigNames;
use MediaWiki\Permissions\GroupPermissionsLookup;
use MediaWiki\Revision\MutableRevisionRecord;
diff --git a/tests/phpunit/unit/includes/FeedUtilsTest.php b/tests/phpunit/unit/includes/Feed/FeedUtilsTest.php
index 56d79301d2c6..f74030929f0a 100644
--- a/tests/phpunit/unit/includes/FeedUtilsTest.php
+++ b/tests/phpunit/unit/includes/Feed/FeedUtilsTest.php
@@ -1,7 +1,9 @@
<?php
+use MediaWiki\Feed\FeedUtils;
+
/**
- * @covers \FeedUtils
+ * @covers \MediaWiki\Feed\FeedUtils
*/
class FeedUtilsTest extends MediaWikiUnitTestCase {