Merge "Add release notes for protect log changes"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 28 Sep 2015 19:52:28 +0000 (19:52 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 28 Sep 2015 19:52:28 +0000 (19:52 +0000)
12 files changed:
RELEASE-NOTES-1.26
includes/actions/InfoAction.php
includes/installer/WebInstallerOutput.php
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderEditToolbarModule.php
includes/resourceloader/ResourceLoaderFileModule.php
includes/resourceloader/ResourceLoaderModule.php
includes/specials/SpecialMergeHistory.php
package.json
resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.less
tests/phpunit/LessFileCompilationTest.php
tests/phpunit/structure/ResourcesTest.php

index 9ae5ddb..efca318 100644 (file)
@@ -238,6 +238,10 @@ changes to languages because of Phabricator reports.
   by &nbsp; and HTML entity encodings of &nbsp, <, and >.
 * DatabaseBase::resultObject() is now protected (use outside Database classes
   not necessary since 1.11).
+* Calling ResourceLoaderFileModule::readStyleFiles() without a
+  ResourceLoaderContext instance is deprecated.
+* ResourceLoader::getLessCompiler() now takes an optional parameter of
+  additional LESS variables to set for the compiler.
 
 == Compatibility ==
 
index f3670a8..d9324e7 100644 (file)
@@ -555,9 +555,11 @@ class InfoAction extends FormlessAction {
                );
 
                // Total number of distinct authors
-               $pageInfo['header-edits'][] = array(
-                       $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] )
-               );
+               if ( $pageCounts['authors'] > 0 ) {
+                       $pageInfo['header-edits'][] = array(
+                               $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] )
+                       );
+               }
 
                // Recent number of edits (within past 30 days)
                $pageInfo['header-edits'][] = array(
@@ -718,20 +720,23 @@ class InfoAction extends FormlessAction {
                // Total number of edits
                $edits = (int)$dbr->selectField(
                        'revision',
-                       'COUNT(rev_page)',
+                       'COUNT(*)',
                        array( 'rev_page' => $id ),
                        __METHOD__
                );
                $result['edits'] = $edits;
 
                // Total number of distinct authors
-               $authors = (int)$dbr->selectField(
-                       'revision',
-                       'COUNT(DISTINCT rev_user_text)',
-                       array( 'rev_page' => $id ),
-                       __METHOD__
-               );
-               $result['authors'] = $authors;
+               if ( $config->get( 'MiserMode' ) ) {
+                       $result['authors'] = 0;
+               } else {
+                       $result['authors'] = (int)$dbr->selectField(
+                               'revision',
+                               'COUNT(DISTINCT rev_user_text)',
+                               array( 'rev_page' => $id ),
+                               __METHOD__
+                       );
+               }
 
                // "Recent" threshold defined by RCMaxAge setting
                $threshold = $dbr->timestamp( time() - $config->get( 'RCMaxAge' ) );
@@ -749,7 +754,7 @@ class InfoAction extends FormlessAction {
                $result['recent_edits'] = $edits;
 
                // Recent number of distinct authors
-               $authors = (int)$dbr->selectField(
+               $result['recent_authors'] = (int)$dbr->selectField(
                        'revision',
                        'COUNT(DISTINCT rev_user_text)',
                        array(
@@ -758,7 +763,6 @@ class InfoAction extends FormlessAction {
                        ),
                        __METHOD__
                );
-               $result['recent_authors'] = $authors;
 
                // Subpages (if enabled)
                if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {
index 0ccdb11..211bad1 100644 (file)
@@ -170,7 +170,8 @@ class WebInstallerOutput {
                        $styles = array_merge( $styles, ResourceLoader::makeCombinedStyles(
                                $module->readStyleFiles(
                                        $module->getStyleFiles( $rlContext ),
-                                       $module->getFlip( $rlContext )
+                                       $module->getFlip( $rlContext ),
+                                       $rlContext
                        ) ) );
                }
 
index c20d386..dacf013 100644 (file)
@@ -956,8 +956,8 @@ class ResourceLoader implements LoggerAwareInterface {
         * Generate code for a response.
         *
         * @param ResourceLoaderContext $context Context in which to generate a response
-        * @param array $modules List of module objects keyed by module name
-        * @param array $missing List of requested module names that are unregistered (optional)
+        * @param ResourceLoaderModule[] $modules List of module objects keyed by module name
+        * @param string[] $missing List of requested module names that are unregistered (optional)
         * @return string Response data
         */
        public function makeModuleResponse( ResourceLoaderContext $context,
@@ -1246,7 +1246,7 @@ MESSAGE;
        }
 
        private static function isEmptyObject( stdClass $obj ) {
-               foreach ( $obj as $key => &$value ) {
+               foreach ( $obj as $key => $value ) {
                        return false;
                }
                return true;
@@ -1611,12 +1611,15 @@ MESSAGE;
        /**
         * Returns LESS compiler set up for use with MediaWiki
         *
+        * @since 1.22
+        * @since 1.26 added $extraVars parameter
         * @param Config $config
+        * @param array $extraVars Associative array of extra (i.e., other than the
+        *   globally-configured ones) that should be used for compilation.
         * @throws MWException
-        * @since 1.22
         * @return Less_Parser
         */
-       public static function getLessCompiler( Config $config ) {
+       public static function getLessCompiler( Config $config, $extraVars = array() ) {
                // When called from the installer, it is possible that a required PHP extension
                // is missing (at least for now; see bug 47564). If this is the case, throw an
                // exception (caught by the installer) to prevent a fatal error later on.
@@ -1625,7 +1628,7 @@ MESSAGE;
                }
 
                $parser = new Less_Parser;
-               $parser->ModifyVars( self::getLessVars( $config ) );
+               $parser->ModifyVars( array_merge( self::getLessVars( $config ), $extraVars ) );
                $parser->SetImportDirs( array_fill_keys( $config->get( 'ResourceLoaderLESSImportPaths' ), '' ) );
                $parser->SetOption( 'relativeUrls', false );
                $parser->SetCacheDir( $config->get( 'CacheDirectory' ) ?: wfTempDir() );
@@ -1644,8 +1647,6 @@ MESSAGE;
                if ( !self::$lessVars ) {
                        $lessVars = $config->get( 'ResourceLoaderLESSVars' );
                        Hooks::run( 'ResourceLoaderGetLessVars', array( &$lessVars ) );
-                       // Sort by key to ensure consistent hashing for cache lookups.
-                       ksort( $lessVars );
                        self::$lessVars = $lessVars;
                }
                return self::$lessVars;
index ef51e0c..fca7961 100644 (file)
  * @since 1.24
  */
 class ResourceLoaderEditToolbarModule extends ResourceLoaderFileModule {
-
        /**
         * Get language-specific LESS variables for this module.
         *
+        * @since 1.26
+        * @param ResourceLoaderContext $context
         * @return array
         */
-       private function getLessVars( ResourceLoaderContext $context ) {
+       protected function getLessVars( ResourceLoaderContext $context ) {
+               $vars = parent::getLessVars( $context );
                $language = Language::factory( $context->getLanguage() );
-
-               // This is very conveniently formatted and we can pass it right through
-               $vars = $language->getImageFiles();
-
-               // less.php tries to be helpful and parse our variables as LESS source code
-               foreach ( $vars as $key => &$value ) {
-                       $value = CSSMin::serializeStringValue( $value );
+               foreach ( $language->getImageFiles() as $key => $value ) {
+                       $vars[ $key ] = CSSMin::serializeStringValue( $value );
                }
-
                return $vars;
        }
-
-       /**
-        * @return bool
-        */
-       public function enableModuleContentVersion() {
-               return true;
-       }
-
-       /**
-        * Get a LESS compiler instance for this module.
-        *
-        * Set our variables in it.
-        *
-        * @throws MWException
-        * @param ResourceLoaderContext $context
-        * @return Less_Parser
-        */
-       protected function getLessCompiler( ResourceLoaderContext $context = null ) {
-               $parser = parent::getLessCompiler();
-               $parser->ModifyVars( $this->getLessVars( $context ) );
-               return $parser;
-       }
 }
index ca10ab7..0df2892 100644 (file)
@@ -854,13 +854,21 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         * @param array $styles List of media type/list of file paths pairs, to read, remap and
         * concetenate
         * @param bool $flip
-        * @param ResourceLoaderContext $context (optional)
+        * @param ResourceLoaderContext $context
         *
         * @throws MWException
         * @return array List of concatenated and remapped CSS data from $styles,
         *     keyed by media type
+        *
+        * @since 1.26 Calling this method without a ResourceLoaderContext instance
+        *   is deprecated.
         */
        public function readStyleFiles( array $styles, $flip, $context = null ) {
+               if ( $context === null ) {
+                       wfDeprecated( __METHOD__ . ' without a ResourceLoader context', '1.26' );
+                       $context = ResourceLoaderContext::newDummyContext();
+               }
+
                if ( empty( $styles ) ) {
                        return array();
                }
@@ -882,12 +890,12 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         *
         * @param string $path File path of style file to read
         * @param bool $flip
-        * @param ResourceLoaderContext $context (optional)
+        * @param ResourceLoaderContext $context
         *
         * @return string CSS data in script file
         * @throws MWException If the file doesn't exist
         */
-       protected function readStyleFile( $path, $flip, $context = null ) {
+       protected function readStyleFile( $path, $flip, $context ) {
                $localPath = $this->getLocalPath( $path );
                $remotePath = $this->getRemotePath( $path );
                if ( !file_exists( $localPath ) ) {
@@ -897,8 +905,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                }
 
                if ( $this->getStyleSheetLang( $localPath ) === 'less' ) {
-                       $compiler = $this->getLessCompiler( $context );
-                       $style = $this->compileLessFile( $localPath, $compiler );
+                       $style = $this->compileLessFile( $localPath, $context );
                        $this->hasGeneratedStyles = true;
                } else {
                        $style = file_get_contents( $localPath );
@@ -947,12 +954,13 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         * Keeps track of all used files and adds them to localFileRefs.
         *
         * @since 1.22
+        * @since 1.26 Added $context paramter.
         * @throws Exception If less.php encounters a parse error
         * @param string $fileName File path of LESS source
-        * @param Less_Parser $parser Compiler to use, if not default
+        * @param ResourceLoaderContext $context Context in which to generate script
         * @return string CSS source
         */
-       protected function compileLessFile( $fileName, $compiler = null ) {
+       protected function compileLessFile( $fileName, ResourceLoaderContext $context ) {
                static $cache;
 
                if ( !$cache ) {
@@ -961,7 +969,9 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
 
                // Construct a cache key from the LESS file name and a hash digest
                // of the LESS variables used for compilation.
-               $varsHash = hash( 'md4', serialize( ResourceLoader::getLessVars( $this->getConfig() ) ) );
+               $vars = $this->getLessVars( $context );
+               ksort( $vars );
+               $varsHash = hash( 'md4', serialize( $vars ) );
                $cacheKey = wfGlobalCacheKey( 'LESS', $fileName, $varsHash );
                $cachedCompile = $cache->get( $cacheKey );
 
@@ -976,10 +986,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                        }
                }
 
-               if ( !$compiler ) {
-                       $compiler = $this->getLessCompiler();
-               }
-
+               $compiler = ResourceLoader::getLessCompiler( $this->getConfig(), $vars );
                $css = $compiler->parseFile( $fileName )->getCss();
                $files = $compiler->AllParsedFiles();
                $this->localFileRefs = array_merge( $this->localFileRefs, $files );
@@ -993,20 +1000,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                return $css;
        }
 
-       /**
-        * Get a LESS compiler instance for this module in given context.
-        *
-        * Just calls ResourceLoader::getLessCompiler() by default to get a global compiler.
-        *
-        * @param ResourceLoaderContext $context
-        * @throws MWException
-        * @since 1.24
-        * @return Less_Parser
-        */
-       protected function getLessCompiler( ResourceLoaderContext $context = null ) {
-               return ResourceLoader::getLessCompiler( $this->getConfig() );
-       }
-
        /**
         * Takes named templates by the module and returns an array mapping.
         * @return array of templates mapping template alias to content
index 80c8220..1551ae3 100644 (file)
@@ -485,6 +485,17 @@ abstract class ResourceLoaderModule {
                $this->msgBlobMtime[$lang] = $mtime;
        }
 
+       /**
+        * Get module-specific LESS variables, if any.
+        *
+        * @since 1.26
+        * @param ResourceLoaderContext $context
+        * @return array Module-specific LESS variables.
+        */
+       protected function getLessVars( ResourceLoaderContext $context ) {
+               return array();
+       }
+
        /**
         * Get an array of this module's resources. Ready for serving to the web.
         *
index 7edf961..145a12a 100644 (file)
@@ -61,6 +61,9 @@ class SpecialMergeHistory extends SpecialPage {
        /** @var Title */
        protected $mDestObj;
 
+       /** @var int[] */
+       public $prevId;
+
        public function __construct() {
                parent::__construct( 'MergeHistory', 'mergehistory' );
        }
@@ -94,18 +97,6 @@ class SpecialMergeHistory extends SpecialPage {
                        $this->mTargetObj = null;
                        $this->mDestObj = null;
                }
-               $this->preCacheMessages();
-       }
-
-       /**
-        * As we use the same small set of messages in various methods and that
-        * they are called often, we call them once and save them in $this->message
-        */
-       function preCacheMessages() {
-               // Precache various messages
-               if ( !isset( $this->message ) ) {
-                       $this->message['last'] = $this->msg( 'last' )->escaped();
-               }
        }
 
        public function execute( $par ) {
@@ -283,7 +274,7 @@ class SpecialMergeHistory extends SpecialPage {
                $rev = new Revision( $row );
 
                $stxt = '';
-               $last = $this->message['last'];
+               $last = $this->msg( 'last' )->escaped();
 
                $ts = wfTimestamp( TS_MW, $row->rev_timestamp );
                $checkBox = Xml::radio( 'mergepoint', $ts, ( $this->mTimestamp === $ts ) );
@@ -302,11 +293,11 @@ class SpecialMergeHistory extends SpecialPage {
 
                # Last link
                if ( !$rev->userCan( Revision::DELETED_TEXT, $user ) ) {
-                       $last = $this->message['last'];
+                       $last = $this->msg( 'last' )->escaped();
                } elseif ( isset( $this->prevId[$row->rev_id] ) ) {
                        $last = Linker::linkKnown(
                                $rev->getTitle(),
-                               $this->message['last'],
+                               $this->msg( 'last' )->escaped(),
                                array(),
                                array(
                                        'diff' => $row->rev_id,
@@ -501,13 +492,13 @@ class SpecialMergeHistory extends SpecialPage {
 }
 
 class MergeHistoryPager extends ReverseChronologicalPager {
-       /** @var IContextSource */
+       /** @var SpecialMergeHistory */
        public $mForm;
 
        /** @var array */
        public $mConds;
 
-       function __construct( $form, $conds, $source, $dest ) {
+       function __construct( SpecialMergeHistory $form, $conds, Title $source, Title $dest ) {
                $this->mForm = $form;
                $this->mConds = $conds;
                $this->title = $source;
index c00dbed..dbc8190 100644 (file)
@@ -1,6 +1,5 @@
 {
-  "name": "mediawiki",
-  "version": "0.0.0",
+  "private": true,
   "scripts": {
     "test": "grunt test",
     "doc": "jsduck",
index 21a9019..702eb80 100644 (file)
 /* Theme-specific */
 .mw-widget-calendarWidget-day {
        color: #444;
+       border-radius: 0.1em;
 }
 
 .mw-widget-calendarWidget-day-heading {
 
 .mw-widget-calendarWidget-day-today {
        box-shadow: inset 0 0 0 1px #3787fb;
-       border-radius: ((@calendarHeight / 7) / 2);
 }
 
 .mw-widget-calendarWidget-item-selected {
        background-color: #d8e6fe;
        color: #3787fb;
-
-       &.mw-widget-calendarWidget-day,
-       &.mw-widget-calendarWidget-day-heading {
-               border-radius: ((@calendarHeight / 7) / 2);
-       }
-
-       &.mw-widget-calendarWidget-month {
-               border-radius: ((@calendarHeight / 6) / 2);
-       }
-
-       &.mw-widget-calendarWidget-year {
-               border-radius: ((@calendarHeight / 4) / 2);
-       }
 }
 
 .mw-widget-calendarWidget-item:hover {
        background-color: #eee;
-
-       &.mw-widget-calendarWidget-day,
-       &.mw-widget-calendarWidget-day-heading {
-               border-radius: ((@calendarHeight / 7) / 4);
-               // Hide the border from .mw-widget-calendarWidget-day-today
-               box-shadow: none;
-       }
-
-       &.mw-widget-calendarWidget-month {
-               border-radius: ((@calendarHeight / 6) / 4);
-       }
-
-       &.mw-widget-calendarWidget-year {
-               border-radius: ((@calendarHeight / 4) / 4);
-       }
 }
index eec02ed..5e1f1a9 100644 (file)
@@ -41,11 +41,9 @@ class LessFileCompilationTest extends ResourceLoaderTestCase {
                $rlContext = $this->getResourceLoaderContext();
 
                // Bleh
-               $method = new ReflectionMethod( $this->module, 'getLessCompiler' );
+               $method = new ReflectionMethod( $this->module, 'compileLessFile' );
                $method->setAccessible( true );
-               $compiler = $method->invoke( $this->module, $rlContext );
-
-               $this->assertNotNull( $compiler->parseFile( $this->file )->getCss() );
+               $this->assertNotNull( $method->invoke( $this->module, $this->file, $rlContext ) );
        }
 
        public function toString() {
index eefc926..23afabd 100644 (file)
@@ -198,7 +198,7 @@ class ResourcesTest extends MediaWikiTestCase {
                                                        $media,
                                                        $file,
                                                        // XXX: Wrapped in an object to keep it out of PHPUnit output
-                                                       (object)array( 'cssText' => $readStyleFile->invoke( $module, $file, $flip ) ),
+                                                       (object)array( 'cssText' => $readStyleFile->invoke( $module, $file, $flip, $data['context'] ) ),
                                                );
                                        }
                                }