X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FFeedUtils.php;h=82c6e4a0ea6fc72a4fc6f6f7859ab9c2c204538a;hb=b85839a5493c6391032d6bb0829ab66fbf235970;hp=11b2675d87ab1d0daa4562ffb6f787ef17034d6d;hpb=ddfce8feb06afe46bfa778be27c5b5b369861f5e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/FeedUtils.php b/includes/FeedUtils.php index 11b2675d87..82c6e4a0ea 100644 --- a/includes/FeedUtils.php +++ b/includes/FeedUtils.php @@ -87,7 +87,7 @@ class FeedUtils { ($row->rc_deleted & Revision::DELETED_COMMENT) ? wfMessage('rev-deleted-comment')->escaped() : $row->rc_comment, - $actiontext + $actiontext ); } @@ -138,13 +138,23 @@ class FeedUtils { $diffText = ''; // Don't bother generating the diff if we won't be able to show it if ( $wgFeedDiffCutoff > 0 ) { - $de = new DifferenceEngine( $title, $oldid, $newid ); - $diffText = $de->getDiff( - wfMessage( 'previousrevision' )->text(), // hack - wfMessage( 'revisionasof', - $wgLang->timeanddate( $timestamp ), - $wgLang->date( $timestamp ), - $wgLang->time( $timestamp ) )->text() ); + $rev = Revision::newFromId( $oldid ); + + if ( !$rev ) { + $diffText = false; + } else { + $context = clone RequestContext::getMain(); + $context->setTitle( $title ); + + $contentHandler = $rev->getContentHandler(); + $de = $contentHandler->createDifferenceEngine( $context, $oldid, $newid ); + $diffText = $de->getDiff( + wfMessage( 'previousrevision' )->text(), // hack + wfMessage( 'revisionasof', + $wgLang->timeanddate( $timestamp ), + $wgLang->date( $timestamp ), + $wgLang->time( $timestamp ) )->text() ); + } } if ( $wgFeedDiffCutoff <= 0 || ( strlen( $diffText ) > $wgFeedDiffCutoff ) ) { @@ -162,16 +172,36 @@ class FeedUtils { } else { $rev = Revision::newFromId( $newid ); if( $wgFeedDiffCutoff <= 0 || is_null( $rev ) ) { - $newtext = ''; + $newContent = ContentHandler::getForTitle( $title )->makeEmptyContent(); + } else { + $newContent = $rev->getContent(); + } + + if ( $newContent instanceof TextContent ) { + // only textual content has a "source view". + $text = $newContent->getNativeData(); + + if ( $wgFeedDiffCutoff <= 0 || strlen( $text ) > $wgFeedDiffCutoff ) { + $html = null; + } else { + $html = nl2br( htmlspecialchars( $text ) ); + } } else { - $newtext = $rev->getText(); + //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 ApiFeedContributions::feedItemDesc + $html = null; } - if ( $wgFeedDiffCutoff <= 0 || strlen( $newtext ) > $wgFeedDiffCutoff ) { + + if ( $html === null ) { + // Omit large new page diffs, bug 29110 + // Also use diff link for non-textual content $diffText = self::getDiffLink( $title, $newid ); } else { $diffText = '

' . wfMessage( 'newpage' )->text() . '

' . - '
' . nl2br( htmlspecialchars( $newtext ) ) . '
'; + '
' . $html . '
'; } } $completeText .= $diffText;