* @return string
*/
public static function diff( $oldText, $newText ) {
- /** @var $slotDiffRenderer TextSlotDiffRenderer */
+ /** @var TextSlotDiffRenderer $slotDiffRenderer */
$slotDiffRenderer = ContentHandler::getForModelID( CONTENT_MODEL_TEXT )
->getSlotDiffRenderer( RequestContext::getMain() );
return $slotDiffRenderer->getTextDiff( $oldText, $newText );
public function setLanguage( Language $language ) {
$this->language = $language;
}
+
/**
* @param int $cutoff
* @see $wgWikiDiff2MovedParagraphDetectionCutoff
/** @inheritDoc */
public function getDiff( Content $oldContent = null, Content $newContent = null ) {
- if ( !$oldContent && !$newContent ) {
- throw new InvalidArgumentException( '$oldContent and $newContent cannot both be null' );
- } elseif ( $oldContent && !( $oldContent instanceof TextContent ) ) {
- throw new InvalidArgumentException( __CLASS__ . ' does not handle ' . get_class( $oldContent ) );
- } elseif ( $newContent && !( $newContent instanceof TextContent ) ) {
- throw new InvalidArgumentException( __CLASS__ . ' does not handle ' . get_class( $newContent ) );
- }
-
- if ( !$oldContent ) {
- $oldContent = $newContent->getContentHandler()->makeEmptyContent();
- } elseif ( !$newContent ) {
- $newContent = $oldContent->getContentHandler()->makeEmptyContent();
- }
+ $this->normalizeContents( $oldContent, $newContent, TextContent::class );
$oldText = $oldContent->serialize();
$newText = $newContent->serialize();
$newText,
2
);
-
- // Log a warning in case the configuration value is set to not silently ignore it
- if ( $this->wikiDiff2MovedParagraphDetectionCutoff > 0 ) {
- wfLogWarning( '$wgWikiDiff2MovedParagraphDetectionCutoff is set but has no
- effect since the used version of WikiDiff2 does not support it.' );
- }
}
return $text;