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();
$wikidiff2Version = phpversion( 'wikidiff2' );
if (
$wikidiff2Version !== false &&
- version_compare( $wikidiff2Version, '1.5.0', '>=' )
+ version_compare( $wikidiff2Version, '1.5.0', '>=' ) &&
+ version_compare( $wikidiff2Version, '1.8.0', '<' )
) {
$text = wikidiff2_do_diff(
$oldText,
$this->wikiDiff2MovedParagraphDetectionCutoff
);
} else {
- // Don't pass the 4th parameter for compatibility with older versions of wikidiff2
+ // Don't pass the 4th parameter introduced in version 1.5.0 and removed in version 1.8.0
$text = wikidiff2_do_diff(
$oldText,
$newText,