Index: trunk/phase3/includes/diff/DifferenceEngine.php |
— | — | @@ -618,6 +618,24 @@ |
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
| 622 | + * Make sure the proper modules are loaded before we try to |
| 623 | + * make the diff |
| 624 | + */ |
| 625 | + private function initDiffEngines() { |
| 626 | + global $wgExternalDiffEngine; |
| 627 | + if ( $wgExternalDiffEngine == 'wikidiff' && !function_exists( 'wikidiff_do_diff' ) { |
| 628 | + wfProfileIn( __METHOD__ . '-php_wikidiff.so' ); |
| 629 | + @dl( 'php_wikidiff.so' ); |
| 630 | + wfProfileOut( __METHOD__ . '-php_wikidiff.so' ); |
| 631 | + } |
| 632 | + else if ( $wgExternalDiffEngine == 'wikidiff2' && !function_exists( 'wikidiff2_do_diff' ) ) { |
| 633 | + wfProfileIn( __METHOD__ . '-php_wikidiff2.so' ); |
| 634 | + @dl( 'php_wikidiff2.so' ); |
| 635 | + wfProfileOut( __METHOD__ . '-php_wikidiff2.so' ); |
| 636 | + } |
| 637 | + } |
| 638 | + |
| 639 | + /** |
622 | 640 | * Generate a diff, no caching |
623 | 641 | * $otext and $ntext must be already segmented |
624 | 642 | */ |
— | — | @@ -627,33 +645,25 @@ |
628 | 646 | $otext = str_replace( "\r\n", "\n", $otext ); |
629 | 647 | $ntext = str_replace( "\r\n", "\n", $ntext ); |
630 | 648 | |
631 | | - if ( $wgExternalDiffEngine == 'wikidiff' ) { |
| 649 | + $this->initDiffEngines(); |
| 650 | + |
| 651 | + if ( $wgExternalDiffEngine == 'wikidiff' && function_exists( 'wikidiff_do_diff' ) ) { |
632 | 652 | # For historical reasons, external diff engine expects |
633 | 653 | # input text to be HTML-escaped already |
634 | 654 | $otext = htmlspecialchars ( $wgContLang->segmentForDiff( $otext ) ); |
635 | 655 | $ntext = htmlspecialchars ( $wgContLang->segmentForDiff( $ntext ) ); |
636 | | - if( !function_exists( 'wikidiff_do_diff' ) ) { |
637 | | - dl('php_wikidiff.so'); |
638 | | - } |
639 | 656 | return $wgContLang->unsegementForDiff( wikidiff_do_diff( $otext, $ntext, 2 ) ) . |
640 | 657 | $this->debug( 'wikidiff1' ); |
641 | 658 | } |
642 | 659 | |
643 | | - if ( $wgExternalDiffEngine == 'wikidiff2' ) { |
| 660 | + if ( $wgExternalDiffEngine == 'wikidiff2' && function_exists( 'wikidiff2_do_diff' ) ) { |
644 | 661 | # Better external diff engine, the 2 may some day be dropped |
645 | 662 | # This one does the escaping and segmenting itself |
646 | | - if ( !function_exists( 'wikidiff2_do_diff' ) ) { |
647 | | - wfProfileIn( __METHOD__ . "-dl" ); |
648 | | - @dl('php_wikidiff2.so'); |
649 | | - wfProfileOut( __METHOD__ . "-dl" ); |
650 | | - } |
651 | | - if ( function_exists( 'wikidiff2_do_diff' ) ) { |
652 | | - wfProfileIn( 'wikidiff2_do_diff' ); |
653 | | - $text = wikidiff2_do_diff( $otext, $ntext, 2 ); |
654 | | - $text .= $this->debug( 'wikidiff2' ); |
655 | | - wfProfileOut( 'wikidiff2_do_diff' ); |
656 | | - return $text; |
657 | | - } |
| 663 | + wfProfileIn( 'wikidiff2_do_diff' ); |
| 664 | + $text = wikidiff2_do_diff( $otext, $ntext, 2 ); |
| 665 | + $text .= $this->debug( 'wikidiff2' ); |
| 666 | + wfProfileOut( 'wikidiff2_do_diff' ); |
| 667 | + return $text; |
658 | 668 | } |
659 | 669 | if ( $wgExternalDiffEngine != 'wikidiff3' && $wgExternalDiffEngine !== false ) { |
660 | 670 | # Diff via the shell |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -111,6 +111,8 @@ |
112 | 112 | * (bug 18677) Give proper error message when viewing &action=protect without |
113 | 113 | sufficient rights |
114 | 114 | * (bug 6802) profileinfo.php now also work on other database servers than MySQL |
| 115 | +* (bug 16925) Diffs no longer fail when $wgExternalDiffEngine is set to 'wikidiff' |
| 116 | + or 'wikidiff2' but extension is not installed |
115 | 117 | |
116 | 118 | |
117 | 119 | == API changes in 1.16 == |