Merge "Fix "Save current filter settings" menu and legend overlap"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 7 Dec 2017 18:25:38 +0000 (18:25 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 7 Dec 2017 18:25:38 +0000 (18:25 +0000)
includes/GitInfo.php
includes/htmlform/fields/HTMLTextAreaField.php
includes/htmlform/fields/HTMLTextField.php
includes/installer/LocalSettingsGenerator.php
includes/specialpage/ChangesListSpecialPage.php
includes/specials/pagers/ImageListPager.php
languages/Language.php
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
resources/src/mediawiki.rcfilters/mw.rcfilters.init.js
tests/phpunit/includes/page/WikiPageDbTestBase.php
tests/phpunit/languages/LanguageTest.php

index f170a02..fb75c25 100644 (file)
@@ -37,6 +37,11 @@ class GitInfo {
         */
        protected $basedir;
 
+       /**
+        * Location of the repository
+        */
+       protected $repoDir;
+
        /**
         * Path to JSON cache file for pre-computed git information.
         */
@@ -58,6 +63,7 @@ class GitInfo {
         * @see precomputeValues
         */
        public function __construct( $repoDir, $usePrecomputed = true ) {
+               $this->repoDir = $repoDir;
                $this->cacheFile = self::getCacheFilePath( $repoDir );
                wfDebugLog( 'gitinfo',
                        "Computed cacheFile={$this->cacheFile} for {$repoDir}"
@@ -230,10 +236,11 @@ class GitInfo {
                                        '--format=format:%ct',
                                        'HEAD',
                                ];
+                               $gitDir = realpath( $this->basedir );
                                $result = Shell::command( $cmd )
-                                       ->environment( [ 'GIT_DIR' => $this->basedir ] )
+                                       ->environment( [ 'GIT_DIR' => $gitDir ] )
                                        ->restrict( Shell::RESTRICT_DEFAULT | Shell::NO_NETWORK )
-                                       ->whitelistPaths( [ $this->basedir ] )
+                                       ->whitelistPaths( [ $gitDir, $this->repoDir ] )
                                        ->execute();
 
                                if ( $result->getExitCode() === 0 ) {
index e6963d5..466a251 100644 (file)
@@ -16,7 +16,7 @@ class HTMLTextAreaField extends HTMLFormField {
                parent::__construct( $params );
 
                if ( isset( $params['placeholder-message'] ) ) {
-                       $this->mPlaceholder = $this->getMessage( $params['placeholder-message'] )->parse();
+                       $this->mPlaceholder = $this->getMessage( $params['placeholder-message'] )->text();
                } elseif ( isset( $params['placeholder'] ) ) {
                        $this->mPlaceholder = $params['placeholder'];
                }
index 1c5a43d..b2e4f2a 100644 (file)
@@ -31,7 +31,7 @@ class HTMLTextField extends HTMLFormField {
                parent::__construct( $params );
 
                if ( isset( $params['placeholder-message'] ) ) {
-                       $this->mPlaceholder = $this->getMessage( $params['placeholder-message'] )->parse();
+                       $this->mPlaceholder = $this->getMessage( $params['placeholder-message'] )->text();
                } elseif ( isset( $params['placeholder'] ) ) {
                        $this->mPlaceholder = $params['placeholder'];
                }
index bdaeaca..b4ef49d 100644 (file)
@@ -185,7 +185,7 @@ class LocalSettingsGenerator {
                        $jsonFile = 'skin.json';
                        $function = 'wfLoadSkin';
                } else {
-                       throw new InvalidArgumentException( '$dir was not "extensions" or "skins' );
+                       throw new InvalidArgumentException( '$dir was not "extensions" or "skins"' );
                }
 
                $encName = self::escapePhpString( $name );
index 6cb56d4..b6d1028 100644 (file)
@@ -1778,7 +1778,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                        return true;
                }
 
-               return self::checkStructuredFilterUiEnabled(
+               return static::checkStructuredFilterUiEnabled(
                        $this->getConfig(),
                        $this->getUser()
                );
index 1c46f4c..008573b 100644 (file)
@@ -288,7 +288,7 @@ class ImageListPager extends TablePager {
 
                        $columnlist = preg_grep( '/^img/', array_keys( $this->getFieldNames() ) );
                        $options = [ 'GROUP BY' => array_merge( [ 'img_user' ], $columnlist ) ];
-                       $join_conds = [ 'oldimage' => [ 'LEFT JOIN', 'oi_name = img_name' ] ];
+                       $join_conds['oldimage'] = [ 'LEFT JOIN', 'oi_name = img_name' ];
                }
 
                return [
index 81564ab..8d3984d 100644 (file)
@@ -3268,7 +3268,7 @@ class Language {
                        }
                }
 
-               return $number;
+               return (string)$number;
        }
 
        /**
index eec4f4b..7b5e115 100644 (file)
         * @param {Array} filterStructure Filter definition and structure for the model
         * @param {Object} [namespaceStructure] Namespace definition
         * @param {Object} [tagList] Tag definition
+        * @param {Object} [conditionalViews] Conditional view definition
         */
-       mw.rcfilters.Controller.prototype.initialize = function ( filterStructure, namespaceStructure, tagList ) {
+       mw.rcfilters.Controller.prototype.initialize = function ( filterStructure, namespaceStructure, tagList, conditionalViews ) {
                var parsedSavedQueries, pieces,
                        displayConfig = mw.config.get( 'StructuredChangeFiltersDisplayConfig' ),
                        defaultSavedQueryExists = mw.config.get( 'wgStructuredChangeFiltersDefaultSavedQueryExists' ),
                        controller = this,
-                       views = {},
+                       views = $.extend( true, {}, conditionalViews ),
                        items = [],
                        uri = new mw.Uri();
 
                        ]
                };
 
-               views.recentChangesLinked = {
-                       groups: [
-                               {
-                                       name: 'page',
-                                       type: 'any_value',
-                                       title: '',
-                                       hidden: true,
-                                       sticky: true,
-                                       filters: [
-                                               {
-                                                       name: 'target',
-                                                       'default': ''
-                                               }
-                                       ]
-                               },
-                               {
-                                       name: 'toOrFrom',
-                                       type: 'boolean',
-                                       title: '',
-                                       hidden: true,
-                                       sticky: true,
-                                       filters: [
-                                               {
-                                                       name: 'showlinkedto',
-                                                       'default': false
-                                               }
-                                       ]
-                               }
-                       ]
-               };
-
                // Before we do anything, we need to see if we require additional items in the
                // groups that have 'AllowArbitrary'. For the moment, those are only single_option
                // groups; if we ever expand it, this might need further generalization:
index 2744b8b..40b8bd2 100644 (file)
@@ -12,6 +12,7 @@
                                topSection,
                                $watchlistDetails,
                                namespaces,
+                               conditionalViews = {},
                                savedQueriesPreferenceName = mw.config.get( 'wgStructuredChangeFiltersSavedQueriesPreferenceName' ),
                                daysPreferenceName = mw.config.get( 'wgStructuredChangeFiltersDaysPreferenceName' ),
                                limitPreferenceName = mw.config.get( 'wgStructuredChangeFiltersLimitPreferenceName' ),
                                        '.mw-changeslist-notargetpage'
                                ].join( ', ' ) );
 
+                       if ( specialPage === 'Recentchangeslinked' ) {
+                               conditionalViews.recentChangesLinked = {
+                                       groups: [
+                                               {
+                                                       name: 'page',
+                                                       type: 'any_value',
+                                                       title: '',
+                                                       hidden: true,
+                                                       isSticky: false,
+                                                       filters: [
+                                                               {
+                                                                       name: 'target',
+                                                                       'default': ''
+                                                               }
+                                                       ]
+                                               },
+                                               {
+                                                       name: 'toOrFrom',
+                                                       type: 'boolean',
+                                                       title: '',
+                                                       hidden: true,
+                                                       isSticky: false,
+                                                       filters: [
+                                                               {
+                                                                       name: 'showlinkedto',
+                                                                       'default': false
+                                                               }
+                                                       ]
+                                               }
+                                       ]
+                               };
+
+                       }
+
                        // TODO: The changesListWrapperWidget should be able to initialize
                        // after the model is ready.
 
@@ -60,7 +95,8 @@
                        controller.initialize(
                                mw.config.get( 'wgStructuredChangeFilters' ),
                                namespaces,
-                               mw.config.get( 'wgRCFiltersChangeTags' )
+                               mw.config.get( 'wgRCFiltersChangeTags' ),
+                               conditionalViews
                        );
 
                        // eslint-disable-next-line no-new
index c4ec4dd..b8480dd 100644 (file)
@@ -1447,8 +1447,8 @@ more stuff
 
        /**
         * @dataProvider provideTestInsertProtectNullRevision
-        * @covers WikiPge::insertProtectNullRevision
-        * @covers WikiPge::protectDescription
+        * @covers WikiPage::insertProtectNullRevision
+        * @covers WikiPage::protectDescription
         *
         * @param string $revCommentMsg
         * @param array $limit
index cd52366..e39f57e 100644 (file)
@@ -1629,6 +1629,33 @@ class LanguageTest extends LanguageClassesTestCase {
                ];
        }
 
+       /**
+        * @dataProvider testFormatNumProvider
+        * @covers Language::formatNum
+        */
+       public function testFormatNum(
+               $translateNumerals, $langCode, $number, $nocommafy, $expected
+       ) {
+               $this->setMwGlobals( [ 'wgTranslateNumerals' => $translateNumerals ] );
+               $lang = Language::factory( $langCode );
+               $formattedNum = $lang->formatNum( $number, $nocommafy );
+               $this->assertType( 'string', $formattedNum );
+               $this->assertEquals( $expected, $formattedNum );
+       }
+
+       public function testFormatNumProvider() {
+               return [
+                       [ true, 'en', 100, false, '100' ],
+                       [ true, 'en', 101, true, '101' ],
+                       [ false, 'en', 103, false, '103' ],
+                       [ false, 'en', 104, true, '104' ],
+                       [ true, 'en', '105', false, '105' ],
+                       [ true, 'en', '106', true, '106' ],
+                       [ false, 'en', '107', false, '107' ],
+                       [ false, 'en', '108', true, '108' ],
+               ];
+       }
+
        /**
         * @dataProvider parseFormattedNumberProvider
         */