Merge "Introduce config var for moved-paragraph-detection threshold"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 18 Jul 2017 14:20:00 +0000 (14:20 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 18 Jul 2017 14:20:00 +0000 (14:20 +0000)
1  2 
includes/DefaultSettings.php
includes/diff/DifferenceEngine.php

@@@ -1439,20 -1439,24 +1439,20 @@@ $wgUploadThumbnailRenderHttpCustomDomai
  $wgUseTinyRGBForJPGThumbnails = false;
  
  /**
 - * Default parameters for the "<gallery>" tag
 - */
 -$wgGalleryOptions = [
 -      // Default number of images per-row in the gallery. 0 -> Adapt to screensize
 -      'imagesPerRow' => 0,
 -      // Width of the cells containing images in galleries (in "px")
 -      'imageWidth' => 120,
 -      // Height of the cells containing images in galleries (in "px")
 -      'imageHeight' => 120,
 -      // Length to truncate filename to in caption when using "showfilename".
 -      // A value of 'true' will truncate the filename to one line using CSS
 -      // and will be the behaviour after deprecation.
 -      // @deprecated since 1.28
 -      'captionLength' => true,
 -      // Show the filesize in bytes in categories
 -      'showBytes' => true,
 -      'mode' => 'traditional',
 -];
 + * Parameters for the "<gallery>" tag.
 + * Fields are:
 + *   - imagesPerRow:   Default number of images per-row in the gallery. 0 -> Adapt to screensize
 + *   - imageWidth:     Width of the cells containing images in galleries (in "px")
 + *   - imageHeight:    Height of the cells containing images in galleries (in "px")
 + *   - captionLength:  Length to truncate filename to in caption when using "showfilename".
 + *                     A value of 'true' will truncate the filename to one line using CSS
 + *                     and will be the behaviour after deprecation.
 + *                     @deprecated since 1.28
 + *   - showBytes:      Show the filesize in bytes in categories
 + *   - showDimensions: Show the dimensions (width x height) in categories
 + *   - mode:           Gallery mode
 + */
 +$wgGalleryOptions = [];
  
  /**
   * Adjust width of upright images when parameter 'upright' is used
@@@ -3052,12 -3056,6 +3052,12 @@@ $wgDisableTitleConversion = false
   */
  $wgDefaultLanguageVariant = false;
  
 +/**
 + * Whether to enable the pig latin variant of English (en-x-piglatin),
 + * used to ease variant development work.
 + */
 +$wgUsePigLatinVariant = false;
 +
  /**
   * Disabled variants array of language variant conversion.
   *
@@@ -5027,9 -5025,6 +5027,9 @@@ $wgBlockDisablesLogin = false
   * @note Also that this will only protect _pages in the wiki_. Uploaded files
   * will remain readable. You can use img_auth.php to protect uploaded files,
   * see https://www.mediawiki.org/wiki/Manual:Image_Authorization
 + *
 + * @note Extensions should not modify this, but use the TitleReadWhitelist
 + * hook instead.
   */
  $wgWhitelistRead = false;
  
@@@ -6121,10 -6116,7 +6121,10 @@@ $wgTrxProfilerLimits = 
        'PostSend' => [
                'readQueryTime' => 5,
                'writeQueryTime' => 1,
 -              'maxAffected' => 1000
 +              'maxAffected' => 1000,
 +              // Log master queries under the post-send entry point as they are discouraged
 +              'masterConns' => 0,
 +              'writes' => 0,
        ],
        // Background job runner
        'JobRunner' => [
@@@ -6336,16 -6328,15 +6336,16 @@@ $wgSiteStatsAsyncFactor = false
   * Parser test suite files to be run by parserTests.php when no specific
   * filename is passed to it.
   *
 - * Extensions may add their own tests to this array, or site-local tests
 - * may be added via LocalSettings.php
 + * Extensions using extension.json will have any *.txt file in a
 + * tests/parser/ directory automatically run.
 + *
 + * Core tests can be added to ParserTestRunner::$coreTestFiles.
   *
   * Use full paths.
 + *
 + * @deprecated since 1.30
   */
 -$wgParserTestFiles = [
 -      "$IP/tests/parser/parserTests.txt",
 -      "$IP/tests/parser/extraParserTests.txt"
 -];
 +$wgParserTestFiles = [];
  
  /**
   * Allow running of javascript test suites via [[Special:JavaScriptTest]] (such as QUnit).
@@@ -6776,17 -6767,6 +6776,17 @@@ $wgUseRCPatrol = true
   */
  $wgStructuredChangeFiltersEnableSaving = true;
  
 +/**
 + * Whether to show the new experimental views (like namespaces, tags, and users) in
 + * RecentChanges filters
 + */
 +$wgStructuredChangeFiltersEnableExperimentalViews = false;
 +
 +/**
 + * Whether to allow users to use the experimental live update feature in the new RecentChanges UI
 + */
 +$wgStructuredChangeFiltersEnableLiveUpdate = false;
 +
  /**
   * Use new page patrolling to check new pages on Special:Newpages
   */
@@@ -8301,6 -8281,20 +8301,20 @@@ $wgUpdateRowsPerQuery = 100
   */
  $wgExternalDiffEngine = false;
  
+ /**
+  * wikidiff2 supports detection of changes in moved paragraphs.
+  * This setting controls the maximum number of paragraphs to compare before it bails out.
+  * Supported values:
+  * * 0: detection of moved paragraphs is disabled
+  * * int > 0: maximum number of paragraphs to compare
+  * Note: number of paragraph comparisons is in O(n^2).
+  * This setting is only effective if the wikidiff2 PHP/HHVM module is used as diffengine.
+  * See $wgExternalDiffEngine.
+  *
+  * @since 1.30
+  */
+ $wgWikiDiff2MovedParagraphDetectionCutoff = 0;
  /**
   * Disable redirects to special pages and interwiki redirects, which use a 302
   * and have no "redirected from" link.
@@@ -8579,15 -8573,6 +8593,15 @@@ $wgPopularPasswordFile = __DIR__ . '/..
   */
  $wgMaxUserDBWriteDuration = false;
  
 +/*
 + * Max time (in seconds) a job-generated transaction can spend in writes.
 + * If exceeded, the transaction is rolled back with an error instead of being committed.
 + *
 + * @var int|bool Disabled if false
 + * @since 1.30
 + */
 +$wgMaxJobDBWriteDuration = false;
 +
  /**
   * Mapping of event channels (or channel categories) to EventRelayer configuration.
   *
@@@ -847,7 -847,7 +847,7 @@@ class DifferenceEngine extends ContextS
         * @return bool|string
         */
        public function generateTextDiffBody( $otext, $ntext ) {
 -              $diff = function() use ( $otext, $ntext ) {
 +              $diff = function () use ( $otext, $ntext ) {
                        $time = microtime( true );
  
                        $result = $this->textDiff( $otext, $ntext );
                 * @param Status $status
                 * @throws FatalError
                 */
 -              $error = function( $status ) {
 +              $error = function ( $status ) {
                        throw new FatalError( $status->getWikiText() );
                };
  
                        $wgExternalDiffEngine = false;
                }
  
+               // Better external diff engine, the 2 may some day be dropped
+               // This one does the escaping and segmenting itself
                if ( function_exists( 'wikidiff2_do_diff' ) && $wgExternalDiffEngine === false ) {
-                       # Better external diff engine, the 2 may some day be dropped
-                       # This one does the escaping and segmenting itself
-                       $text = wikidiff2_do_diff( $otext, $ntext, 2 );
+                       $wikidiff2Version = phpversion( 'wikidiff2' );
+                       if (
+                               $wikidiff2Version !== false &&
+                               version_compare( $wikidiff2Version, '0.3.0', '>=' )
+                       ) {
+                               $text = wikidiff2_do_diff(
+                                       $otext,
+                                       $ntext,
+                                       2,
+                                       $this->getConfig()->get( 'WikiDiff2MovedParagraphDetectionCutoff' )
+                               );
+                       } else {
+                               // Don't pass the 4th parameter for compatibility with older versions of wikidiff2
+                               $text = wikidiff2_do_diff(
+                                       $otext,
+                                       $ntext,
+                                       2
+                               );
+                               // Log a warning in case the configuration value is set to not silently ignore it
+                               if ( $this->getConfig()->get( 'WikiDiff2MovedParagraphDetectionCutoff' ) > 0 ) {
+                                       wfLogWarning( '$wgWikiDiff2MovedParagraphDetectionCutoff is set but has no
+                                               effect since the used version of WikiDiff2 does not support it.' );
+                               }
+                       }
                        $text .= $this->debug( 'wikidiff2' );
  
                        return $text;