66 public static function formatDiff( $row, $formattedComment =
null ) {
68 $timestamp =
wfTimestamp( TS::MW, $row->rc_timestamp );
70 if ( $row->rc_source === RecentChange::SRC_LOG ) {
73 ->newFromRow( $rcRow )->getActionText();
75 if ( $row->rc_deleted & RevisionRecord::DELETED_COMMENT ) {
76 $formattedComment =
wfMessage(
'rev-deleted-comment' )->escaped();
77 } elseif ( $formattedComment ===
null ) {
79 $formattedComment = $services->getCommentFormatter()->format(
80 $services->getCommentStore()->getComment(
'rc_comment', $row )->text );
82 return self::formatDiffRow2( $titleObj,
83 $row->rc_last_oldid, $row->rc_this_oldid,
103 $comment, $actiontext =
''
106 ->format( $comment );
107 return self::formatDiffRow2( $title, $oldid, $newid, $timestamp,
108 $formattedComment, $actiontext );
124 $title, $oldid, $newid, $timestamp, $formattedComment, $actiontext =
''
129 $unwrappedText = implode(
131 array_filter( [ $actiontext, $formattedComment ] )
133 $completeText = Html::rawElement(
'p', [], $unwrappedText ) .
"\n";
139 $anon = $services->getUserFactory()->newAnonymous();
140 $permManager = $services->getPermissionManager();
141 $userCan = $permManager->userCan(
149 if ( $title->getNamespace() < 0 || !$userCan || !$newid ) {
150 return $completeText;
153 $revLookup = $services->getRevisionLookup();
154 $contentHandlerFactory = $services->getContentHandlerFactory();
158 if ( $feedDiffCutoff > 0 ) {
159 $revRecord = $revLookup->getRevisionById( $oldid );
165 $context->setTitle( $title );
167 $model = $revRecord->getSlot(
171 $contentHandler = $contentHandlerFactory->getContentHandler( $model );
172 $de = $contentHandler->createDifferenceEngine( $context, $oldid, $newid );
173 $lang = $context->getLanguage();
174 $user = $context->getUser();
175 $diffText = $de->getDiff(
176 $context->msg(
'previousrevision' )->text(),
177 $context->msg(
'revisionasof',
178 $lang->userTimeAndDate( $timestamp, $user ),
179 $lang->userDate( $timestamp, $user ),
180 $lang->userTime( $timestamp, $user ) )->text() );
184 if ( $feedDiffCutoff <= 0 || ( strlen( $diffText ) > $feedDiffCutoff ) ) {
186 $diffText = self::getDiffLink( $title, $newid, $oldid );
187 } elseif ( $diffText ===
false ) {
192 "Can't load revision $newid"
196 $diffText = UtfNormal\Validator::cleanUp( $diffText );
197 $diffText = self::applyDiffStyle( $diffText );
200 $revRecord = $revLookup->getRevisionById( $newid );
201 if ( $feedDiffCutoff <= 0 || $revRecord ===
null ) {
202 $newContent = $contentHandlerFactory
203 ->getContentHandler( $title->getContentModel() )
204 ->makeEmptyContent();
206 $newContent = $revRecord->getContent( SlotRecord::MAIN );
211 $text = $newContent->getText();
213 if ( $feedDiffCutoff <= 0 || strlen( $text ) > $feedDiffCutoff ) {
216 $html = nl2br( htmlspecialchars( $text ) );
226 if ( $html ===
null ) {
229 $diffText = self::getDiffLink( $title, $newid );
231 $diffText = Html::rawElement(
236 $diffText .= Html::rawElement(
'div', [], $html );
239 $completeText .= $diffText;
241 return $completeText;