Index: trunk/phase3/includes/DifferenceEngine.php |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | $this->mTitle = $titleObj; |
46 | 46 | wfDebug("DifferenceEngine old '$old' new '$new' rcid '$rcid'\n"); |
47 | 47 | |
48 | | - if ( 'prev' == $new ) { |
| 48 | + if ( 'prev' === $new ) { |
49 | 49 | # Show diff between revision $old and the previous one. |
50 | 50 | # Get previous one from DB. |
51 | 51 | # |
— | — | @@ -52,7 +52,7 @@ |
53 | 53 | |
54 | 54 | $this->mOldid = $this->mTitle->getPreviousRevisionID( $this->mNewid ); |
55 | 55 | |
56 | | - } elseif ( 'next' == $new ) { |
| 56 | + } elseif ( 'next' === $new ) { |
57 | 57 | # Show diff between revision $old and the previous one. |
58 | 58 | # Get previous one from DB. |
59 | 59 | # |
— | — | @@ -316,8 +316,10 @@ |
317 | 317 | * Returns false on error |
318 | 318 | */ |
319 | 319 | function getDiffBody() { |
320 | | - global $wgUseExternalDiffEngine, $wgContLang, $wgMemc, $wgDBname; |
321 | | - |
| 320 | + global $wgExternalDiffEngine, $wgContLang, $wgMemc, $wgDBname; |
| 321 | + $fname = 'DifferenceEngine::getDiffBody'; |
| 322 | + wfProfileIn( $fname ); |
| 323 | + |
322 | 324 | // Cacheable? |
323 | 325 | $key = false; |
324 | 326 | if ( $this->mOldid && $this->mNewid ) { |
— | — | @@ -328,17 +330,19 @@ |
329 | 331 | wfIncrStats( 'diff_cache_hit' ); |
330 | 332 | $difftext = $this->localiseLineNumbers( $difftext ); |
331 | 333 | $difftext .= "\n<!-- diff cache key $key -->\n"; |
| 334 | + wfProfileOut( $fname ); |
332 | 335 | return $difftext; |
333 | 336 | } |
334 | 337 | } |
335 | 338 | |
336 | 339 | if ( !$this->loadText() ) { |
| 340 | + wfProfileOut( $fname ); |
337 | 341 | return false; |
338 | 342 | } |
339 | 343 | |
340 | 344 | $otext = $wgContLang->segmentForDiff($this->mOldtext); |
341 | 345 | $ntext = $wgContLang->segmentForDiff($this->mNewtext); |
342 | | - if ( $wgUseExternalDiffEngine ) { |
| 346 | + if ( $wgExternalDiffEngine == 'wikidiff' ) { |
343 | 347 | # For historical reasons, external diff engine expects |
344 | 348 | # input text to be HTML-escaped already |
345 | 349 | $otext = str_replace( "\r\n", "\n", htmlspecialchars ( $otext ) ); |
— | — | @@ -347,6 +351,43 @@ |
348 | 352 | dl('php_wikidiff.so'); |
349 | 353 | } |
350 | 354 | $difftext = wikidiff_do_diff( $otext, $ntext, 2 ); |
| 355 | + } elseif ( $wgExternalDiffEngine == 'wikidiff2' ) { |
| 356 | + # Better external diff engine, the 2 may some day be dropped |
| 357 | + # This one does the escaping itself |
| 358 | + $otext = str_replace( "\r\n", "\n", $otext ); |
| 359 | + $ntext = str_replace( "\r\n", "\n", $ntext ); |
| 360 | + if ( !function_exists( 'wikidiff2_do_diff' ) ) { |
| 361 | + dl('php_wikidiff2.so'); |
| 362 | + } |
| 363 | + $difftext = wikidiff2_do_diff( $otext, $ntext, 2 ); |
| 364 | + } elseif ( $wgExternalDiffEngine !== false ) { |
| 365 | + # Diff via the shell |
| 366 | + global $wgTmpDirectory; |
| 367 | + $otext = str_replace( "\r\n", "\n", $otext ); |
| 368 | + $ntext = str_replace( "\r\n", "\n", $ntext ); |
| 369 | + $tempName1 = tempnam( $wgTmpDirectory, 'diff_' ); |
| 370 | + $tempName2 = tempnam( $wgTmpDirectory, 'diff_' ); |
| 371 | + |
| 372 | + $tempFile1 = fopen( $tempName1, "w" ); |
| 373 | + if ( !$tempFile1 ) { |
| 374 | + wfProfileOut( $fname ); |
| 375 | + return false; |
| 376 | + } |
| 377 | + $tempFile2 = fopen( $tempName2, "w" ); |
| 378 | + if ( !$tempFile2 ) { |
| 379 | + wfProfileOut( $fname ); |
| 380 | + return false; |
| 381 | + } |
| 382 | + fwrite( $tempFile1, $otext ); |
| 383 | + fwrite( $tempFile2, $ntext ); |
| 384 | + fclose( $tempFile1 ); |
| 385 | + fclose( $tempFile2 ); |
| 386 | + $cmd = wfEscapeShellArg( $wgExternalDiffEngine, $tempName1, $tempName2 ); |
| 387 | + wfProfileIn( "$fname-shellexec" ); |
| 388 | + $difftext = wfShellExec( $cmd ); |
| 389 | + wfProfileOut( "$fname-shellexec" ); |
| 390 | + unlink( $tempName1 ); |
| 391 | + unlink( $tempName2 ); |
351 | 392 | } else { |
352 | 393 | $ota = explode( "\n", str_replace( "\r\n", "\n", $otext ) ); |
353 | 394 | $nta = explode( "\n", str_replace( "\r\n", "\n", $ntext ) ); |
— | — | @@ -365,6 +406,7 @@ |
366 | 407 | } |
367 | 408 | // Replace line numbers with the text in the user's language |
368 | 409 | $difftext = $this->localiseLineNumbers( $difftext ); |
| 410 | + wfProfileOut( $fname ); |
369 | 411 | return $difftext; |
370 | 412 | } |
371 | 413 | |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -1474,8 +1474,8 @@ |
1475 | 1475 | /** Maximum indent level of toc. */ |
1476 | 1476 | $wgMaxTocLevel = 999; |
1477 | 1477 | |
1478 | | -/** Use external C++ diff engine (module wikidiff from the extensions package) */ |
1479 | | -$wgUseExternalDiffEngine = false; |
| 1478 | +/** Name of the external diff engine to use */ |
| 1479 | +$wgExternalDiffEngine = false; |
1480 | 1480 | |
1481 | 1481 | /** Use RC Patrolling to check for vandalism */ |
1482 | 1482 | $wgUseRCPatrol = true; |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -232,6 +232,7 @@ |
233 | 233 | * (bug 4267) Switch dv sd ug ks arc languages to RTL |
234 | 234 | * Default main page content improved per bug 4690 |
235 | 235 | * (bug 4615) Update for Portuguese language (pt) |
| 236 | +* Separated MessagesSl.php as the other languages. |
236 | 237 | |
237 | 238 | Parser: |
238 | 239 | * (bug 2522) {{CURRENTDAY2}} now shows the current day number with two digits |
— | — | @@ -606,7 +607,7 @@ |
607 | 608 | * (bug 4147) Added cleanupWatchlist.php to clear out bogus watchlist entries |
608 | 609 | * (partial bug 3456) Disable auto redirect to Main Page after account creation |
609 | 610 | * (bug 4824) Separate out IE7 CSS compat hacks, fix for RTL pages |
610 | | -* Separated MessagesSl.php as the other languages. |
| 611 | +* Added support for wikidiff2 and similar external diff engines. |
611 | 612 | |
612 | 613 | |
613 | 614 | === Caveats === |