X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiFeedContributions.php;h=2b2b32c1bedbb0987fc2762d5ff5f55aab440b66;hb=972a61ad4c81741d878c0e35f6bd8a2e7d62b62d;hp=61a9035895144f9f7adb8abbd84747dcead39339;hpb=f673cfd18a0fa8eb1c9ef0a34e2c1eb9c124a5e9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiFeedContributions.php b/includes/api/ApiFeedContributions.php index 61a9035895..2b2b32c1be 100644 --- a/includes/api/ApiFeedContributions.php +++ b/includes/api/ApiFeedContributions.php @@ -20,11 +20,20 @@ * @file */ +use MediaWiki\MediaWikiServices; +use MediaWiki\Storage\RevisionAccessException; +use MediaWiki\Storage\RevisionRecord; +use MediaWiki\Storage\RevisionStore; +use MediaWiki\Storage\SlotRecord; + /** * @ingroup API */ class ApiFeedContributions extends ApiBase { + /** @var RevisionStore */ + private $revisionStore; + /** * This module uses a custom feed wrapper printer. * @@ -35,6 +44,8 @@ class ApiFeedContributions extends ApiBase { } public function execute() { + $this->revisionStore = MediaWikiServices::getInstance()->getRevisionStore(); + $params = $this->extractRequestParams(); $config = $this->getConfig(); @@ -130,7 +141,7 @@ class ApiFeedContributions extends ApiBase { if ( $title && $title->userCan( 'read', $this->getUser() ) ) { $date = $row->rev_timestamp; $comments = $title->getTalkPage()->getFullURL(); - $revision = Revision::newFromRow( $row ); + $revision = $this->revisionStore->newRevisionFromRow( $row ); return new FeedItem( $title->getPrefixedText(), @@ -146,21 +157,28 @@ class ApiFeedContributions extends ApiBase { } /** - * @param Revision $revision + * @since 1.32, takes a RevisionRecord instead of a Revision + * @param RevisionRecord $revision * @return string */ - protected function feedItemAuthor( $revision ) { - return $revision->getUserText(); + protected function feedItemAuthor( RevisionRecord $revision ) { + $user = $revision->getUser(); + return $user ? $user->getName() : ''; } /** - * @param Revision $revision + * @since 1.32, takes a RevisionRecord instead of a Revision + * @param RevisionRecord $revision * @return string */ - protected function feedItemDesc( $revision ) { + protected function feedItemDesc( RevisionRecord $revision ) { if ( $revision ) { $msg = wfMessage( 'colon-separator' )->inContentLanguage()->text(); - $content = $revision->getContent(); + try { + $content = $revision->getContent( SlotRecord::MAIN ); + } catch ( RevisionAccessException $e ) { + $content = null; + } if ( $content instanceof TextContent ) { // only textual content has a "source view". @@ -173,8 +191,10 @@ class ApiFeedContributions extends ApiBase { $html = ''; } - return '

' . htmlspecialchars( $revision->getUserText() ) . $msg . - htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) . + $comment = $revision->getComment(); + + return '

' . htmlspecialchars( $this->feedItemAuthor( $revision ) ) . $msg . + htmlspecialchars( FeedItem::stripComment( $comment ? $comment->text : '' ) ) . "

\n
\n
" . $html . '
'; }