r50310 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50309‎ | r50310 | r50311 >
Date:16:00, 7 May 2009
Author:demon
Status:ok (Comments)
Tags:
Comment:
(bug 16925) Diffs no longer silently fail when $wgExternalDiffEngine is set to 'wikidiff' or 'wikidiff2' but extension is not installed. Should now gracefully fall back to the PHP diff.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/diff/DifferenceEngine.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/diff/DifferenceEngine.php
@@ -618,6 +618,24 @@
619619 }
620620
621621 /**
 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+ /**
622640 * Generate a diff, no caching
623641 * $otext and $ntext must be already segmented
624642 */
@@ -627,33 +645,25 @@
628646 $otext = str_replace( "\r\n", "\n", $otext );
629647 $ntext = str_replace( "\r\n", "\n", $ntext );
630648
631 - if ( $wgExternalDiffEngine == 'wikidiff' ) {
 649+ $this->initDiffEngines();
 650+
 651+ if ( $wgExternalDiffEngine == 'wikidiff' && function_exists( 'wikidiff_do_diff' ) ) {
632652 # For historical reasons, external diff engine expects
633653 # input text to be HTML-escaped already
634654 $otext = htmlspecialchars ( $wgContLang->segmentForDiff( $otext ) );
635655 $ntext = htmlspecialchars ( $wgContLang->segmentForDiff( $ntext ) );
636 - if( !function_exists( 'wikidiff_do_diff' ) ) {
637 - dl('php_wikidiff.so');
638 - }
639656 return $wgContLang->unsegementForDiff( wikidiff_do_diff( $otext, $ntext, 2 ) ) .
640657 $this->debug( 'wikidiff1' );
641658 }
642659
643 - if ( $wgExternalDiffEngine == 'wikidiff2' ) {
 660+ if ( $wgExternalDiffEngine == 'wikidiff2' && function_exists( 'wikidiff2_do_diff' ) ) {
644661 # Better external diff engine, the 2 may some day be dropped
645662 # 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;
658668 }
659669 if ( $wgExternalDiffEngine != 'wikidiff3' && $wgExternalDiffEngine !== false ) {
660670 # Diff via the shell
Index: trunk/phase3/RELEASE-NOTES
@@ -111,6 +111,8 @@
112112 * (bug 18677) Give proper error message when viewing &action=protect without
113113 sufficient rights
114114 * (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
115117
116118
117119 == API changes in 1.16 ==

Follow-up revisions

RevisionCommit summaryAuthorDate
r50315fix E_PARSE from r50310ialex16:51, 7 May 2009
r50777Cleanup to r50310 & 50313: Don't use @ on chmod() and dl(), use wfSuppressWar...demon16:34, 19 May 2009

Comments

#Comment by Tim Starling (talk | contribs)   16:24, 19 May 2009

This code should also stop using error suppression, especially since dl() is slated for removal in PHP 6.

Status & tagging log