Merge "Setup.php: Ensure that defaults for 'rcdays' and 'watchlistdays' are not invalid"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 6 Jan 2016 22:24:20 +0000 (22:24 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 6 Jan 2016 22:24:20 +0000 (22:24 +0000)
1  2 
includes/Setup.php

diff --combined includes/Setup.php
@@@ -264,6 -264,7 +264,7 @@@ foreach ( $wgForeignFileRepos as &$rep
  }
  unset( $repo ); // no global pollution; destroy reference
  
+ $rcMaxAgeDays = $wgRCMaxAge / ( 3600 * 24 );
  if ( $wgRCFilterByAge ) {
        // Trim down $wgRCLinkDays so that it only lists links which are valid
        // as determined by $wgRCMaxAge.
        // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
        for ( $i = 0; $i < count( $wgRCLinkDays ); $i++ ) {
                // @codingStandardsIgnoreEnd
-               if ( $wgRCLinkDays[$i] >= $wgRCMaxAge / ( 3600 * 24 ) ) {
+               if ( $wgRCLinkDays[$i] >= $rcMaxAgeDays ) {
                        $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i + 1, false );
                        break;
                }
        }
  }
+ // Ensure that default user options are not invalid, since that breaks Special:Preferences
+ $wgDefaultUserOptions['rcdays'] = min(
+       $wgDefaultUserOptions['rcdays'],
+       ceil( $rcMaxAgeDays )
+ );
+ $wgDefaultUserOptions['watchlistdays'] = min(
+       $wgDefaultUserOptions['watchlistdays'],
+       ceil( $rcMaxAgeDays )
+ );
+ unset( $rcMaxAgeDays );
  
  if ( $wgSkipSkin ) {
        $wgSkipSkins[] = $wgSkipSkin;
@@@ -606,13 -617,15 +617,13 @@@ if ( !$wgDBerrorLogTZ ) 
        $wgDBerrorLogTZ = $wgLocaltimezone;
  }
  
 +// initialize the request object in $wgRequest
 +$wgRequest = RequestContext::getMain()->getRequest(); // BackCompat
 +
  // Useful debug output
  if ( $wgCommandLineMode ) {
 -      $wgRequest = new FauxRequest( array() );
 -
        wfDebug( "\n\nStart command line script $self\n" );
  } else {
 -      // Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
 -      $wgRequest = new WebRequest;
 -
        $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
  
        if ( $wgDebugPrintHttpHeaders ) {