Merge "resourceloader: Include lessVars in FileModule definition summary"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 27 Jul 2017 14:42:09 +0000 (14:42 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 27 Jul 2017 14:42:09 +0000 (14:42 +0000)
includes/DefaultSettings.php
includes/diff/DifferenceEngine.php
includes/libs/CSSMin.php
includes/libs/filebackend/FileBackendStore.php
includes/libs/mime/MimeAnalyzer.php
includes/logging/BlockLogFormatter.php
includes/specials/SpecialRecentchanges.php
includes/specials/SpecialWatchlist.php
includes/specials/pagers/UsersPager.php

index f35715e..74d5fa4 100644 (file)
@@ -1304,7 +1304,7 @@ $wgMimeInfoFile = 'includes/mime.info';
  * Sets an external MIME detector program. The command must print only
  * the MIME type to standard output.
  * The name of the file to process will be appended to the command given here.
- * If not set or NULL, PHP's fileinfo extension will be used if available.
+ * If not set or NULL, PHP's mime_content_type function will be used.
  *
  * @par Example:
  * @code
index d4bee29..7f9af60 100644 (file)
@@ -1174,17 +1174,17 @@ class DifferenceEngine extends ContextSource {
 
                if ( !$diff && !$otitle ) {
                        $header .= "
-                       <tr style='vertical-align: top;' lang='{$userLang}'>
-                       <td class='diff-ntitle'>{$ntitle}</td>
+                       <tr style=\"vertical-align: top;\" lang=\"{$userLang}\">
+                       <td class=\"diff-ntitle\">{$ntitle}</td>
                        </tr>";
                        $multiColspan = 1;
                } else {
                        if ( $diff ) { // Safari/Chrome show broken output if cols not used
                                $header .= "
-                               <col class='diff-marker' />
-                               <col class='diff-content' />
-                               <col class='diff-marker' />
-                               <col class='diff-content' />";
+                               <col class=\"diff-marker\" />
+                               <col class=\"diff-content\" />
+                               <col class=\"diff-marker\" />
+                               <col class=\"diff-content\" />";
                                $colspan = 2;
                                $multiColspan = 4;
                        } else {
@@ -1193,20 +1193,20 @@ class DifferenceEngine extends ContextSource {
                        }
                        if ( $otitle || $ntitle ) {
                                $header .= "
-                               <tr style='vertical-align: top;' lang='{$userLang}'>
-                               <td colspan='$colspan' class='diff-otitle'>{$otitle}</td>
-                               <td colspan='$colspan' class='diff-ntitle'>{$ntitle}</td>
+                               <tr style=\"vertical-align: top;\" lang=\"{$userLang}\">
+                               <td colspan=\"$colspan\" class=\"diff-otitle\">{$otitle}</td>
+                               <td colspan=\"$colspan\" class=\"diff-ntitle\">{$ntitle}</td>
                                </tr>";
                        }
                }
 
                if ( $multi != '' ) {
-                       $header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;' " .
-                               "class='diff-multi' lang='{$userLang}'>{$multi}</td></tr>";
+                       $header .= "<tr><td colspan=\"{$multiColspan}\" style=\"text-align: center;\" " .
+                               "class=\"diff-multi\" lang=\"{$userLang}\">{$multi}</td></tr>";
                }
                if ( $notice != '' ) {
-                       $header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;' " .
-                               "lang='{$userLang}'>{$notice}</td></tr>";
+                       $header .= "<tr><td colspan=\"{$multiColspan}\" style=\"text-align: center;\" " .
+                               "lang=\"{$userLang}\">{$notice}</td></tr>";
                }
 
                return $header . $diff . "</table>";
index 9e060cd..4c672f4 100644 (file)
@@ -188,17 +188,7 @@ class CSSMin {
                        return self::$mimeTypes[$ext];
                }
 
-               $realpath = realpath( $file );
-               if (
-                       $realpath
-                       && function_exists( 'finfo_file' )
-                       && function_exists( 'finfo_open' )
-                       && defined( 'FILEINFO_MIME_TYPE' )
-               ) {
-                       return finfo_file( finfo_open( FILEINFO_MIME_TYPE ), $realpath );
-               }
-
-               return false;
+               return mime_content_type( realpath( $file ) );
        }
 
        /**
index 9bfdbe8..77473d1 100644 (file)
@@ -1840,14 +1840,8 @@ abstract class FileBackendStore extends FileBackend {
                        return call_user_func_array( $this->mimeCallback, func_get_args() );
                }
 
-               $mime = null;
-               if ( $fsPath !== null && function_exists( 'finfo_file' ) ) {
-                       $finfo = finfo_open( FILEINFO_MIME_TYPE );
-                       $mime = finfo_file( $finfo, $fsPath );
-                       finfo_close( $finfo );
-               }
-
-               return is_string( $mime ) ? $mime : 'unknown/unknown';
+               $mime = ( $fsPath !== null ) ? mime_content_type( $fsPath ) : false;
+               return $mime ?: 'unknown/unknown';
        }
 }
 
index 631bb17..4d860bb 100644 (file)
@@ -988,18 +988,8 @@ EOT;
                $m = null;
                if ( $callback ) {
                        $m = $callback( $file );
-               } elseif ( function_exists( "finfo_open" ) && function_exists( "finfo_file" ) ) {
-                       $mime_magic_resource = finfo_open( FILEINFO_MIME );
-
-                       if ( $mime_magic_resource ) {
-                               $m = finfo_file( $mime_magic_resource, $file );
-                               finfo_close( $mime_magic_resource );
-                       } else {
-                               $this->logger->info( __METHOD__ .
-                                       ": finfo_open failed on " . FILEINFO_MIME . "!\n" );
-                       }
                } else {
-                       $this->logger->info( __METHOD__ . ": no magic mime detector found!\n" );
+                       $m = mime_content_type( $file );
                }
 
                if ( $m ) {
index a0bfb59..1ed18cd 100644 (file)
@@ -60,7 +60,7 @@ class BlockLogFormatter extends LogFormatter {
                        // is shown on the correct side of the tooltip text.
                        $durationTooltip = '&lrm;' . htmlspecialchars( $params[4] );
                        $params[4] = Message::rawParam(
-                               "<span class='blockExpiry' title='$durationTooltip'>" .
+                               "<span class=\"blockExpiry\" title=\"$durationTooltip\">" .
                                $this->context->getLanguage()->translateBlockExpiry(
                                        $params[4],
                                        $this->context->getUser(),
index 1248007..f0c2bc4 100644 (file)
@@ -373,6 +373,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
 
        public function validateOptions( FormOptions $opts ) {
                $opts->validateIntBounds( 'limit', 0, 5000 );
+               $opts->validateBounds( 'days', 0, $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
                parent::validateOptions( $opts );
        }
 
@@ -387,7 +388,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        $query_options, $join_conds, $opts );
 
                // Calculate cutoff
-               $cutoff_unixtime = time() - ( $opts['days'] * 86400 );
+               $cutoff_unixtime = time() - $opts['days'] * 3600 * 24;
                $cutoff = $dbr->timestamp( $cutoff_unixtime );
 
                $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
index 65131ec..549362f 100644 (file)
@@ -34,6 +34,8 @@ use Wikimedia\Rdbms\IDatabase;
 class SpecialWatchlist extends ChangesListSpecialPage {
        public function __construct( $page = 'Watchlist', $restriction = 'viewmywatchlist' ) {
                parent::__construct( $page, $restriction );
+
+               $this->maxDays = $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 );
        }
 
        public function doesWrites() {
@@ -173,6 +175,11 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                return $opts;
        }
 
+       public function validateOptions( FormOptions $opts ) {
+               $opts->validateBounds( 'days', 0, $this->maxDays );
+               parent::validateOptions( $opts );
+       }
+
        /**
         * Get all custom filters
         *
@@ -255,7 +262,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                // Calculate cutoff
                if ( $opts['days'] > 0 ) {
                        $conds[] = 'rc_timestamp > ' .
-                               $dbr->addQuotes( $dbr->timestamp( time() - intval( $opts['days'] * 86400 ) ) );
+                               $dbr->addQuotes( $dbr->timestamp( time() - $opts['days'] * 3600 * 24 ) );
                }
        }
 
@@ -499,7 +506,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                if ( $opts['days'] > 0 ) {
                        $days = $opts['days'];
                } else {
-                       $days = $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 );
+                       $days = $this->maxDays;
                }
                $timestamp = wfTimestampNow();
                $wlInfo = $this->msg( 'wlnote' )->numParams( $numRows, round( $days * 24 ) )->params(
@@ -599,7 +606,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        $days[] = $userWatchlistOption;
                }
 
-               $maxDays = (string)( $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
+               $maxDays = (string)$this->maxDays;
                // add the maximum possible value, if it isn't available already
                if ( !in_array( $maxDays, $days ) ) {
                        $days[] = $maxDays;
index 10baadf..142b128 100644 (file)
@@ -283,7 +283,7 @@ class UsersPager extends AlphabeticPager {
                                'value' => $this->requestedUser,
                        ],
                        'dropdown' => [
-                               'label' => $this->msg( 'group' ),
+                               'label' => $this->msg( 'group' )->text(),
                                'name' => 'group',
                                'value' => $this->requestedGroup,
                                'class' => 'HTMLSelectField',