Merge "registration: Allow to require environment abilities"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 13 Apr 2019 19:54:04 +0000 (19:54 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 13 Apr 2019 19:54:04 +0000 (19:54 +0000)
includes/DefaultSettings.php
includes/OutputPage.php
includes/installer/DatabaseInstaller.php
includes/resourceloader/ResourceLoader.php

index 828af49..4547009 100644 (file)
@@ -8996,7 +8996,7 @@ $wgEnableBlockNoticeStats = false;
 /**
  * Origin Trials tokens.
  *
- * @since 1.34
+ * @since 1.33
  * @var array
  */
 $wgOriginTrials = [];
@@ -9006,7 +9006,7 @@ $wgOriginTrials = [];
  *
  * @warning EXPERIMENTAL!
  *
- * @since 1.34
+ * @since 1.33
  * @var bool
  */
 $wgPriorityHints = false;
@@ -9016,11 +9016,42 @@ $wgPriorityHints = false;
  *
  * @warning EXPERIMENTAL!
  *
- * @since 1.34
+ * @since 1.33
  * @var bool
  */
 $wgElementTiming = false;
 
+/**
+ * Expiry of the endpoint definition for the Reporting API.
+ *
+ * @warning EXPERIMENTAL!
+ *
+ * @since 1.34
+ * @var int
+ */
+$wgReportToExpiry = 86400;
+
+/**
+ * List of endpoints for the Reporting API.
+ *
+ * @warning EXPERIMENTAL!
+ *
+ * @since 1.34
+ * @var array
+ */
+$wgReportToEndpoints = [];
+
+/**
+ * List of Feature Policy Reporting types to enable.
+ * Each entry is turned into a Feature-Policy-Report-Only header.
+ *
+ * @warning EXPERIMENTAL!
+ *
+ * @since 1.34
+ * @var array
+ */
+$wgFeaturePolicyReportOnly = [];
+
 /**
  * For really cool vim folding this needs to be at the end:
  * vim: foldmarker=@{,@} foldmethod=marker
index 1da8ac8..859593b 100644 (file)
@@ -2527,6 +2527,37 @@ class OutputPage extends ContextSource {
                return $config->get( 'OriginTrials' );
        }
 
+       private function getReportTo() {
+               $config = $this->getConfig();
+
+               $expiry = $config->get( 'ReportToExpiry' );
+
+               if ( !$expiry ) {
+                       return false;
+               }
+
+               $endpoints = $config->get( 'ReportToEndpoints' );
+
+               if ( !$endpoints ) {
+                       return false;
+               }
+
+               $output = [ 'max_age' => $expiry, 'endpoints' => [] ];
+
+               foreach ( $endpoints as $endpoint ) {
+                       $output['endpoints'][] = [ 'url' => $endpoint ];
+               }
+
+               return json_encode( $output, JSON_UNESCAPED_SLASHES );
+       }
+
+       private function getFeaturePolicyReportOnly() {
+               $config = $this->getConfig();
+
+               $features = $config->get( 'FeaturePolicyReportOnly' );
+               return implode( ';', $features );
+       }
+
        /**
         * Send cache control HTTP headers
         */
@@ -2694,6 +2725,16 @@ class OutputPage extends ContextSource {
                        $response->header( "Origin-Trial: $originTrial", false );
                }
 
+               $reportTo = $this->getReportTo();
+               if ( $reportTo ) {
+                       $response->header( "Report-To: $reportTo" );
+               }
+
+               $featurePolicyReportOnly = $this->getFeaturePolicyReportOnly();
+               if ( $featurePolicyReportOnly ) {
+                       $response->header( "Feature-Policy-Report-Only: $featurePolicyReportOnly" );
+               }
+
                ContentSecurityPolicy::sendHeaders( $this );
 
                if ( $this->mArticleBodyOnly ) {
index 6315de4..a219452 100644 (file)
@@ -37,8 +37,6 @@ abstract class DatabaseInstaller {
        /**
         * The Installer object.
         *
-        * @todo Naming this parent is confusing, 'installer' would be clearer.
-        *
         * @var WebInstaller
         */
        public $parent;
index 7fb2df2..8d60e0f 100644 (file)
@@ -1119,6 +1119,10 @@ MESSAGE;
 
                                if ( !$context->getDebug() ) {
                                        $strContent = self::filter( $filter, $strContent );
+                               } else {
+                                       // In debug mode, separate each response by a new line.
+                                       // For example, between 'mw.loader.implement();' statements.
+                                       $strContent = $this->ensureNewline( $strContent );
                                }
 
                                if ( $context->getOnly() === 'scripts' ) {