Merge "$wgHttpsPort should only be used in very special cases"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 24 Jul 2018 01:13:32 +0000 (01:13 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 24 Jul 2018 01:13:32 +0000 (01:13 +0000)
1  2 
includes/DefaultSettings.php
includes/GlobalFunctions.php

@@@ -377,13 -377,7 +377,13 @@@ $wgActionPaths = []
   */
  
  /**
 - * Uploads have to be specially set up to be secure
 + * Allow users to upload files.
 + *
 + * Use $wgLocalFileRepo to control how and where uploads are stored.
 + * Disabled by default as for security reasons.
 + * See <https://www.mediawiki.org/wiki/Manual:Configuring_file_uploads>.
 + *
 + * @since 1.5
   */
  $wgEnableUploads = false;
  
@@@ -497,8 -491,8 +497,8 @@@ $wgImgAuthUrlPathMap = []
   *   - scriptDirUrl      URL of the MediaWiki installation, equivalent to $wgScriptPath, e.g.
   *                       https://en.wikipedia.org/w
   *   - articleUrl        Equivalent to $wgArticlePath, e.g. https://en.wikipedia.org/wiki/$1
 - *   - fetchDescription  Fetch the text of the remote file description page. Equivalent to
 - *                       $wgFetchCommonsDescriptions.
 + *   - fetchDescription  Fetch the text of the remote file description page and display them
 + *                       on the local wiki.
   *   - abbrvThreshold    File names over this size will use the short form of thumbnail names.
   *                       Short thumbnail names only have the width, parameters, and the extension.
   *
   *   - dbType, dbServer, dbUser, dbPassword, dbName, dbFlags
   *                       equivalent to the corresponding member of $wgDBservers
   *   - tablePrefix       Table prefix, the foreign wiki's $wgDBprefix
 - *   - hasSharedCache    True if the wiki's shared cache is accessible via the local $wgMemc
 + *   - hasSharedCache    Set to true if the foreign wiki's $wgMainCacheType is identical to,
 + *                       and accesible from, this wiki.
   *
   * ForeignAPIRepo:
   *   - apibase              Use for the foreign API's URL
  $wgLocalFileRepo = false;
  
  /**
 + * Enable the use of files from one or more other wikis.
 + *
 + * If you operate multiple wikis, you can declare a shared upload path here.
 + * Uploads to the local wiki will NOT be stored here - See $wgLocalFileRepo
 + * and $wgUploadDirectory for that.
 + *
 + * The wiki will only consider the foreign repository if no file of the given name
 + * is found in the local repository (e.g. via `[[File:..]]` syntax).
 + *
 + * @since 1.11
   * @see $wgLocalFileRepo
   */
  $wgForeignFileRepos = [];
  
  /**
 - * Use Commons as a remote file repository. Essentially a wrapper, when this
 - * is enabled $wgForeignFileRepos will point at Commons with a set of default
 - * settings
 + * Use Wikimedia Commons as a foreign file repository.
 + *
 + * This is a shortcut for adding an entry to to $wgForeignFileRepos
 + * for https://commons.wikimedia.org, using ForeignAPIRepo with the
 + * default settings.
 + *
 + * @since 1.16
   */
  $wgUseInstantCommons = false;
  
 +/**
 + * Shortcut for adding an entry to $wgForeignFileRepos.
 + *
 + * Uses the folowing variables:
 + *
 + * - directory: $wgSharedUploadDirectory.
 + * - url: $wgSharedUploadPath.
 + * - hashLevels: Based on $wgHashedSharedUploadDirectory.
 + * - thumbScriptUrl: $wgSharedThumbnailScriptPath.
 + * - transformVia404: Based on $wgGenerateThumbnailOnParse.
 + * - descBaseUrl: $wgRepositoryBaseUrl.
 + * - fetchDescription: $wgFetchCommonsDescriptions.
 + *
 + * If $wgSharedUploadDBname is set, it uses the ForeignDBRepo
 + * class, with also the following variables:
 + *
 + * - dbName: $wgSharedUploadDBname.
 + * - dbType: $wgDBtype.
 + * - dbServer: $wgDBserver.
 + * - dbUser: $wgDBuser.
 + * - dbPassword: $wgDBpassword.
 + * - dbFlags: Based on $wgDebugDumpSql.
 + * - tablePrefix: $wgSharedUploadDBprefix,
 + * - hasSharedCache: $wgCacheSharedUploads.
 + *
 + * @var bool
 + * @since 1.3
 + */
 +$wgUseSharedUploads = false;
 +
 +/**
 + * Shortcut for the 'directory' setting of $wgForeignFileRepos.
 + * Only used if $wgUseSharedUploads is enabled.
 + *
 + * @var string
 + * @since 1.3
 + */
 +$wgSharedUploadDirectory = null;
 +
 +/**
 + * Shortcut for the 'url' setting of $wgForeignFileRepos.
 + * Only used if $wgUseSharedUploads is enabled.
 + *
 + * @var string
 + * @since 1.3
 + */
 +$wgSharedUploadPath = null;
 +
 +/**
 + * Shortcut for the 'hashLevels' setting of $wgForeignFileRepos.
 + * Only used if $wgUseSharedUploads is enabled.
 + *
 + * @var bool
 + * @since 1.3
 + */
 +$wgHashedSharedUploadDirectory = true;
 +
 +/**
 + * Shortcut for the 'descBaseUrl' setting of $wgForeignFileRepos.
 + * Only used if $wgUseSharedUploads is enabled.
 + *
 + * @since 1.5
 + */
 +$wgRepositoryBaseUrl = 'https://commons.wikimedia.org/wiki/File:';
 +
 +/**
 + * Shortcut for the 'fetchDescription' setting of $wgForeignFileRepos.
 + * Only used if $wgUseSharedUploads is enabled.
 + *
 + * @var bool
 + * @since 1.5
 + */
 +$wgFetchCommonsDescriptions = false;
 +
 +/**
 + * Shortcut for the ForeignDBRepo 'dbName' setting in $wgForeignFileRepos.
 + * Set this to false if the uploads do not come from a wiki.
 + * Only used if $wgUseSharedUploads is enabled.
 + *
 + * @var bool|string
 + * @since 1.4
 + */
 +$wgSharedUploadDBname = false;
 +
 +/**
 + * Shortcut for the ForeignDBRepo 'tablePrefix' setting in $wgForeignFileRepos.
 + * Only used if $wgUseSharedUploads is enabled.
 + *
 + * @var string
 + * @since 1.5
 + */
 +$wgSharedUploadDBprefix = '';
 +
 +/**
 + * Shortcut for the ForeignDBRepo 'hasSharedCache' setting in $wgForeignFileRepos.
 + * Only used if $wgUseSharedUploads is enabled.
 + *
 + * @var bool
 + * @since 1.5
 + */
 +$wgCacheSharedUploads = true;
 +
  /**
   * Array of foreign file repo names (set in $wgForeignFileRepos above) that
   * are allowable upload targets. These wikis must have some method of
@@@ -799,6 -676,53 +799,6 @@@ $wgShowEXIF = function_exists( 'exif_re
   */
  $wgUpdateCompatibleMetadata = false;
  
 -/**
 - * If you operate multiple wikis, you can define a shared upload path here.
 - * Uploads to this wiki will NOT be put there - they will be put into
 - * $wgUploadDirectory.
 - * If $wgUseSharedUploads is set, the wiki will look in the shared repository if
 - * no file of the given name is found in the local repository (for [[File:..]],
 - * [[Media:..]] links). Thumbnails will also be looked for and generated in this
 - * directory.
 - *
 - * Note that these configuration settings can now be defined on a per-
 - * repository basis for an arbitrary number of file repositories, using the
 - * $wgForeignFileRepos variable.
 - */
 -$wgUseSharedUploads = false;
 -
 -/**
 - * Full path on the web server where shared uploads can be found
 - */
 -$wgSharedUploadPath = null;
 -
 -/**
 - * Fetch commons image description pages and display them on the local wiki?
 - */
 -$wgFetchCommonsDescriptions = false;
 -
 -/**
 - * Path on the file system where shared uploads can be found.
 - */
 -$wgSharedUploadDirectory = null;
 -
 -/**
 - * DB name with metadata about shared directory.
 - * Set this to false if the uploads do not come from a wiki.
 - */
 -$wgSharedUploadDBname = false;
 -
 -/**
 - * Optional table prefix used in database.
 - */
 -$wgSharedUploadDBprefix = '';
 -
 -/**
 - * Cache shared metadata in memcached.
 - * Don't do this if the commons wiki is in a different memcached domain
 - */
 -$wgCacheSharedUploads = true;
 -
  /**
   * Allow for upload to be copied from an URL.
   * The timeout for copy uploads is set by $wgCopyUploadTimeout.
@@@ -897,11 -821,7 +897,11 @@@ $wgUploadMissingFileUrl = false
  $wgThumbnailScriptPath = false;
  
  /**
 - * @see $wgThumbnailScriptPath
 + * Shortcut for the 'thumbScriptUrl' setting of $wgForeignFileRepos.
 + * Only used if $wgUseSharedUploads is enabled.
 + *
 + * @var string
 + * @since 1.3
   */
  $wgSharedThumbnailScriptPath = false;
  
   */
  $wgHashedUploadDirectory = true;
  
 -/**
 - * Set the following to false especially if you have a set of files that need to
 - * be accessible by all wikis, and you do not want to use the hash (path/a/aa/)
 - * directory layout.
 - */
 -$wgHashedSharedUploadDirectory = true;
 -
 -/**
 - * Base URL for a repository wiki. Leave this blank if uploads are just stored
 - * in a shared directory and not meant to be accessible through a separate wiki.
 - * Otherwise the image description pages on the local wiki will link to the
 - * image description page on this wiki.
 - *
 - * Please specify the namespace, as in the example below.
 - */
 -$wgRepositoryBaseUrl = "https://commons.wikimedia.org/wiki/File:";
 -
  /**
   * This is the list of preferred extensions for uploading files. Uploading files
   * with extensions not in this list will trigger a warning.
@@@ -7766,8 -7703,8 +7766,8 @@@ $wgLogRestrictions = 
   * hidden by default unless the link is clicked. Import logs will be shown by
   * default, and hidden when the link is clicked.
   *
 - * A message of the form log-show-hide-[type] should be added, and will be used
 - * for the link text.
 + * A message of the form logeventslist-[type]-log should be added, and will be
 + * used for the link text.
   */
  $wgFilterLogTypes = [
        'patrol' => true,
@@@ -8669,9 -8606,14 +8669,14 @@@ $wgSiteTypes = 
  $wgPagePropsHaveSortkey = true;
  
  /**
-  * Port where you have HTTPS running
-  * Supports HTTPS on non-standard ports
-  * @see T67184
+  * For installations where the canonical server is HTTP but HTTPS is optionally
+  * supported, you can specify a non-standard HTTPS port here. $wgServer should
+  * be a protocol-relative URL.
+  *
+  * If HTTPS is always used, just specify the port number in $wgServer.
+  *
+  * @see https://phabricator.wikimedia.org/T67184
+  *
   * @since 1.24
   */
  $wgHttpsPort = 443;
@@@ -8975,7 -8917,7 +8980,7 @@@ $wgCommentTableSchemaMigrationStage = M
   * @since 1.32
   * @var int An appropriate combination of SCHEMA_COMPAT_XXX flags.
   */
 -$wgMultiContentRevisionSchemaMigrationStage = MIGRATION_OLD;
 +$wgMultiContentRevisionSchemaMigrationStage = SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD;
  
  /**
   * Actor table schema migration stage.
@@@ -9007,18 -8949,6 +9012,18 @@@ $wgExpiryWidgetNoDatePicker = false
   */
  $wgChangeTagsSchemaMigrationStage = MIGRATION_OLD;
  
 +/**
 + * Temporarily flag to use change_tag_def table as backend of change tag statistics.
 + * For example in case of Special:Tags. If set to false, it will use change_tag table.
 + * Before setting it to true set $wgChangeTagsSchemaMigrationStage to MIGRATION_WRITE_BOTH and run
 + * PopulateChangeTagDef maintaince script.
 + * It's redundant when $wgChangeTagsSchemaMigrationStage is set to MIGRATION_NEW
 + *
 + * @since 1.32
 + * @var bool
 + */
 +$wgTagStatisticsNewTable = false;
 +
  /**
   * For really cool vim folding this needs to be at the end:
   * vim: foldmarker=@{,@} foldmethod=marker
@@@ -141,7 -141,7 +141,7 @@@ function wfArrayDiff2_cmp( $a, $b ) 
  }
  
  /**
 - * Like array_filter with ARRAY_FILTER_USE_BOTH, but works pre-5.6.
 + * @deprecated since 1.32, use array_filter() with ARRAY_FILTER_USE_BOTH directly
   *
   * @param array $arr
   * @param callable $callback Will be called with the array value and key (in that order) and
   * @return array
   */
  function wfArrayFilter( array $arr, callable $callback ) {
 -      if ( defined( 'ARRAY_FILTER_USE_BOTH' ) ) {
 -              return array_filter( $arr, $callback, ARRAY_FILTER_USE_BOTH );
 -      }
 -      $filteredKeys = array_filter( array_keys( $arr ), function ( $key ) use ( $arr, $callback ) {
 -              return call_user_func( $callback, $arr[$key], $key );
 -      } );
 -      return array_intersect_key( $arr, array_fill_keys( $filteredKeys, true ) );
 +      return array_filter( $arr, $callback, ARRAY_FILTER_USE_BOTH );
  }
  
  /**
 - * Like array_filter with ARRAY_FILTER_USE_KEY, but works pre-5.6.
 + * @deprecated since 1.32, use array_filter() with ARRAY_FILTER_USE_KEY directly
   *
   * @param array $arr
   * @param callable $callback Will be called with the array key and should return a bool which
   * @return array
   */
  function wfArrayFilterByKey( array $arr, callable $callback ) {
 -      return wfArrayFilter( $arr, function ( $val, $key ) use ( $callback ) {
 -              return call_user_func( $callback, $key );
 -      } );
 +      return array_filter( $arr, $callback, ARRAY_FILTER_USE_KEY );
  }
  
  /**
@@@ -548,17 -556,24 +548,24 @@@ function wfExpandUrl( $url, $defaultPro
        } elseif ( substr( $url, 0, 1 ) == '/' ) {
                // If $serverUrl is protocol-relative, prepend $defaultProtoWithoutSlashes,
                // otherwise leave it alone.
-               $url = ( $serverHasProto ? '' : $defaultProtoWithoutSlashes ) . $serverUrl . $url;
+               if ( $serverHasProto ) {
+                       $url = $serverUrl . $url;
+               } else {
+                       // If an HTTPS URL is synthesized from a protocol-relative $wgServer, allow the
+                       // user to override the port number (T67184)
+                       if ( $defaultProto === PROTO_HTTPS && $wgHttpsPort != 443 ) {
+                               if ( isset( $bits['port'] ) ) {
+                                       throw new Exception( 'A protocol-relative $wgServer may not contain a port number' );
+                               }
+                               $url = $defaultProtoWithoutSlashes . $serverUrl . ':' . $wgHttpsPort . $url;
+                       } else {
+                               $url = $defaultProtoWithoutSlashes . $serverUrl . $url;
+                       }
+               }
        }
  
        $bits = wfParseUrl( $url );
  
-       // ensure proper port for HTTPS arrives in URL
-       // https://phabricator.wikimedia.org/T67184
-       if ( $defaultProto === PROTO_HTTPS && $wgHttpsPort != 443 ) {
-               $bits['port'] = $wgHttpsPort;
-       }
        if ( $bits && isset( $bits['path'] ) ) {
                $bits['path'] = wfRemoveDotSegments( $bits['path'] );
                return wfAssembleUrl( $bits );
@@@ -866,13 -881,20 +873,13 @@@ function wfParseUrl( $url ) 
  function wfExpandIRI( $url ) {
        return preg_replace_callback(
                '/((?:%[89A-F][0-9A-F])+)/i',
 -              'wfExpandIRI_callback',
 +              function ( array $matches ) {
 +                      return urldecode( $matches[1] );
 +              },
                wfExpandUrl( $url )
        );
  }
  
 -/**
 - * Private callback for wfExpandIRI
 - * @param array $matches
 - * @return string
 - */
 -function wfExpandIRI_callback( $matches ) {
 -      return urldecode( $matches[1] );
 -}
 -
  /**
   * Make URL indexes, appropriate for the el_index field of externallinks.
   *
@@@ -1613,7 -1635,6 +1620,7 @@@ function wfClientAcceptsGzip( $force = 
   * As required by the callers, "<nowiki>" is not used.
   *
   * @param string $text Text to be escaped
 + * @param-taint $text escapes_html
   * @return string
   */
  function wfEscapeWikiText( $text ) {