76 public static function formatDiff( $row, $formattedComment =
null ) {
77 $titleObj = Title::makeTitle( $row->rc_namespace, $row->rc_title );
78 $timestamp =
wfTimestamp( TS_MW, $row->rc_timestamp );
80 if ( $row->rc_type ==
RC_LOG ) {
82 $actiontext = LogFormatter::newFromRow( $rcRow )->getActionText();
84 if ( $row->rc_deleted & RevisionRecord::DELETED_COMMENT ) {
85 $formattedComment =
wfMessage(
'rev-deleted-comment' )->escaped();
86 } elseif ( $formattedComment ===
null ) {
88 CommentStore::getStore()->getComment(
'rc_comment', $row )->text );
91 $row->rc_last_oldid, $row->rc_this_oldid,
112 $comment, $actiontext =
''
114 $formattedComment = MediaWikiServices::getInstance()->getCommentFormatter()
115 ->format( $comment );
117 $formattedComment, $actiontext );
133 $formattedComment, $actiontext =
''
135 $feedDiffCutoff = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::FeedDiffCutoff );
138 $unwrappedText = implode(
140 array_filter( [ $actiontext, $formattedComment ] )
142 $completeText = Html::rawElement(
'p', [], $unwrappedText ) .
"\n";
148 $services = MediaWikiServices::getInstance();
149 $permManager = $services->getPermissionManager();
150 $accErrors = $permManager->getPermissionErrors(
158 if (
$title->getNamespace() < 0 || $accErrors || !$newid ) {
159 return $completeText;
162 $revLookup = $services->getRevisionLookup();
163 $contentHandlerFactory = $services->getContentHandlerFactory();
167 if ( $feedDiffCutoff > 0 ) {
168 $revRecord = $revLookup->getRevisionById( $oldid );
173 $mainContext = RequestContext::getMain();
174 $context = clone RequestContext::getMain();
175 $context->setTitle(
$title );
177 $model = $revRecord->getSlot(
181 $contentHandler = $contentHandlerFactory->getContentHandler( $model );
182 $de = $contentHandler->createDifferenceEngine( $context, $oldid, $newid );
183 $lang = $mainContext->getLanguage();
184 $user = $mainContext->getUser();
185 $diffText = $de->getDiff(
186 $mainContext->msg(
'previousrevision' )->text(),
187 $mainContext->msg(
'revisionasof',
188 $lang->userTimeAndDate( $timestamp, $user ),
189 $lang->userDate( $timestamp, $user ),
190 $lang->userTime( $timestamp, $user ) )->text() );
194 if ( $feedDiffCutoff <= 0 || ( strlen( $diffText ) > $feedDiffCutoff ) ) {
197 } elseif ( $diffText ===
false ) {
199 $diffText = Html::rawElement(
202 "Can't load revision $newid"
206 $diffText = UtfNormal\Validator::cleanUp( $diffText );
210 $revRecord = $revLookup->getRevisionById( $newid );
211 if ( $feedDiffCutoff <= 0 || $revRecord ===
null ) {
212 $newContent = $contentHandlerFactory
213 ->getContentHandler(
$title->getContentModel() )
214 ->makeEmptyContent();
216 $newContent = $revRecord->getContent( SlotRecord::MAIN );
221 $text = $newContent->getText();
223 if ( $feedDiffCutoff <= 0 || strlen( $text ) > $feedDiffCutoff ) {
226 $html = nl2br( htmlspecialchars( $text ) );
236 if ( $html ===
null ) {
241 $diffText = Html::rawElement(
244 Html::rawElement(
'b', [],
wfMessage(
'newpage' )->text() )
246 $diffText .= Html::rawElement(
'div', [], $html );
249 $completeText .= $diffText;
251 return $completeText;