Merge "Unbreak wfResetOutputBuffers"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 10 Sep 2015 00:03:45 +0000 (00:03 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 10 Sep 2015 00:03:45 +0000 (00:03 +0000)
1  2 
includes/GlobalFunctions.php

@@@ -404,15 -404,14 +404,15 @@@ function wfRandomString( $length = 32 
   * RFC 1738 says ~ is unsafe, however RFC 3986 considers it an unreserved
   * character which should not be encoded. More importantly, google chrome
   * always converts %7E back to ~, and converting it in this function can
 - * cause a redirect loop (T105265).
 + * cause a redirect loop (T105265). Similarly, encoding ' causes a
 + * redirect loop on Opera 12 (T106793).
   *
   * But + is not safe because it's used to indicate a space; &= are only safe in
 - * paths and not in queries (and we don't distinguish here); ' seems kind of
 - * scary; and urlencode() doesn't touch -_. to begin with.  Plus, although /
 + * paths and not in queries (and we don't distinguish here);
 + * and urlencode() doesn't touch -_. to begin with.  Plus, although /
   * is reserved, we don't care.  So the list we unescape is:
   *
 - * ;:@$!*(),/~
 + * ;:@$!*'(),/~
   *
   * However, IIS7 redirects fail when the url contains a colon (Bug 22709),
   * so no fancy : for IIS7.
@@@ -431,7 -430,7 +431,7 @@@ function wfUrlencode( $s ) 
        }
  
        if ( is_null( $needle ) ) {
 -              $needle = array( '%3B', '%40', '%24', '%21', '%2A', '%28', '%29', '%2C', '%2F', '%7E' );
 +              $needle = array( '%3B', '%40', '%24', '%21', '%2A', '%27', '%28', '%29', '%2C', '%2F', '%7E' );
                if ( !isset( $_SERVER['SERVER_SOFTWARE'] ) ||
                        ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7' ) === false )
                ) {
        $s = urlencode( $s );
        $s = str_ireplace(
                $needle,
 -              array( ';', '@', '$', '!', '*', '(', ')', ',', '/', '~', ':' ),
 +              array( ';', '@', '$', '!', '*', '\'', '(', ')', ',', '/', '~', ':' ),
                $s
        );
  
@@@ -2180,10 -2179,16 +2180,16 @@@ function wfResetOutputBuffers( $resetGz
                $wgDisableOutputCompression = true;
        }
        while ( $status = ob_get_status() ) {
-               if ( $status['type'] == 0 /* PHP_OUTPUT_HANDLER_INTERNAL */ ) {
-                       // Probably from zlib.output_compression or other
-                       // PHP-internal setting which can't be removed.
-                       //
+               if ( isset( $status['flags'] ) ) {
+                       $flags = PHP_OUTPUT_HANDLER_CLEANABLE | PHP_OUTPUT_HANDLER_REMOVABLE;
+                       $deleteable = ( $status['flags'] & $flags ) === $flags;
+               } elseif ( isset( $status['del'] ) ) {
+                       $deleteable = $status['del'];
+               } else {
+                       // Guess that any PHP-internal setting can't be removed.
+                       $deleteable = $status['type'] !== 0; /* PHP_OUTPUT_HANDLER_INTERNAL */
+               }
+               if ( !$deleteable ) {
                        // Give up, and hope the result doesn't break
                        // output behavior.
                        break;
@@@ -3462,10 -3467,10 +3468,10 @@@ function wfResetSessionID() 
   * @param bool $sessionId
   */
  function wfSetupSession( $sessionId = false ) {
 -      global $wgSessionsInMemcached, $wgSessionsInObjectCache, $wgSessionHandler;
 +      global $wgSessionsInObjectCache, $wgSessionHandler;
        global $wgCookiePath, $wgCookieDomain, $wgCookieSecure, $wgCookieHttpOnly;
  
 -      if ( $wgSessionsInObjectCache || $wgSessionsInMemcached ) {
 +      if ( $wgSessionsInObjectCache ) {
                ObjectCacheSessionHandler::install();
        } elseif ( $wgSessionHandler && $wgSessionHandler != ini_get( 'session.save_handler' ) ) {
                # Only set this if $wgSessionHandler isn't null and session.save_handler
        session_start();
        MediaWiki\restoreWarnings();
  
 -      if ( $wgSessionsInObjectCache || $wgSessionsInMemcached ) {
 +      if ( $wgSessionsInObjectCache ) {
                ObjectCacheSessionHandler::renewCurrentSession();
        }
  }
@@@ -3955,13 -3960,13 +3961,13 @@@ function wfBCP47( $code ) 
  }
  
  /**
 - * Get a cache object.
 + * Get a specific cache object.
   *
 - * @param int $inputType Cache type, one of the CACHE_* constants.
 + * @param int|string $cacheType A CACHE_* constants, or other key in $wgObjectCaches
   * @return BagOStuff
   */
 -function wfGetCache( $inputType ) {
 -      return ObjectCache::getInstance( $inputType );
 +function wfGetCache( $cacheType ) {
 +      return ObjectCache::getInstance( $cacheType );
  }
  
  /**
@@@ -4274,28 -4279,3 +4280,28 @@@ function wfThumbIsStandard( File $file
  
        return true;
  }
 +
 +/**
 + * Merges two (possibly) 2 dimensional arrays into the target array ($baseArray).
 + *
 + * Values that exist in both values will be combined with += (all values of the array
 + * of $newValues will be added to the values of the array of $baseArray, while values,
 + * that exists in both, the value of $baseArray will be used).
 + *
 + * @param array $baseArray The array where you want to add the values of $newValues to
 + * @param array $newValues An array with new values
 + * @return array The combined array
 + * @since 1.26
 + */
 +function wfArrayPlus2d( array $baseArray, array $newValues ) {
 +      // First merge items that are in both arrays
 +      foreach ( $baseArray as $name => &$groupVal ) {
 +              if ( isset( $newValues[$name] ) ) {
 +                      $groupVal += $newValues[$name];
 +              }
 +      }
 +      // Now add items that didn't exist yet
 +      $baseArray += $newValues;
 +
 +      return $baseArray;
 +}