72 public static function formatDiff( $row, $formattedComment =
null ) {
74 $timestamp =
wfTimestamp( TS::MW, $row->rc_timestamp );
76 if ( $row->rc_source === RecentChange::SRC_LOG ) {
79 ->newFromRow( $rcRow )->getActionText();
81 if ( $row->rc_deleted & RevisionRecord::DELETED_COMMENT ) {
82 $formattedComment =
wfMessage(
'rev-deleted-comment' )->escaped();
83 } elseif ( $formattedComment ===
null ) {
85 $formattedComment = $services->getCommentFormatter()->format(
86 $services->getCommentStore()->getComment(
'rc_comment', $row )->text );
89 $row->rc_last_oldid, $row->rc_this_oldid,
109 $comment, $actiontext =
''
112 ->format( $comment );
114 $formattedComment, $actiontext );
130 $title, $oldid, $newid, $timestamp, $formattedComment, $actiontext =
''
135 $unwrappedText = implode(
137 array_filter( [ $actiontext, $formattedComment ] )
139 $completeText = Html::rawElement(
'p', [], $unwrappedText ) .
"\n";
145 $anon = $services->getUserFactory()->newAnonymous();
146 $permManager = $services->getPermissionManager();
147 $userCan = $permManager->userCan(
155 if ( $title->getNamespace() < 0 || !$userCan || !$newid ) {
156 return $completeText;
159 $revLookup = $services->getRevisionLookup();
160 $contentHandlerFactory = $services->getContentHandlerFactory();
164 if ( $feedDiffCutoff > 0 ) {
165 $revRecord = $revLookup->getRevisionById( $oldid );
171 $context->setTitle( $title );
173 $model = $revRecord->getSlot(
177 $contentHandler = $contentHandlerFactory->getContentHandler( $model );
178 $de = $contentHandler->createDifferenceEngine( $context, $oldid, $newid );
179 $lang = $context->getLanguage();
180 $user = $context->getUser();
181 $diffText = $de->getDiff(
182 $context->msg(
'previousrevision' )->text(),
183 $context->msg(
'revisionasof',
184 $lang->userTimeAndDate( $timestamp, $user ),
185 $lang->userDate( $timestamp, $user ),
186 $lang->userTime( $timestamp, $user ) )->text() );
190 if ( $feedDiffCutoff <= 0 || ( strlen( $diffText ) > $feedDiffCutoff ) ) {
193 } elseif ( $diffText ===
false ) {
198 "Can't load revision $newid"
202 $diffText = UtfNormal\Validator::cleanUp( $diffText );
206 $revRecord = $revLookup->getRevisionById( $newid );
207 if ( $feedDiffCutoff <= 0 || $revRecord ===
null ) {
208 $newContent = $contentHandlerFactory
209 ->getContentHandler( $title->getContentModel() )
210 ->makeEmptyContent();
212 $newContent = $revRecord->getContent( SlotRecord::MAIN );
217 $text = $newContent->getText();
219 if ( $feedDiffCutoff <= 0 || strlen( $text ) > $feedDiffCutoff ) {
222 $html = nl2br( htmlspecialchars( $text ) );
232 if ( $html ===
null ) {
237 $diffText = Html::rawElement(
242 $diffText .= Html::rawElement(
'div', [], $html );
245 $completeText .= $diffText;
247 return $completeText;