*/
protected $basedir;
+ /**
+ * Location of the repository
+ */
+ protected $repoDir;
+
/**
* Path to JSON cache file for pre-computed git information.
*/
* @see precomputeValues
*/
public function __construct( $repoDir, $usePrecomputed = true ) {
+ $this->repoDir = $repoDir;
$this->cacheFile = self::getCacheFilePath( $repoDir );
wfDebugLog( 'gitinfo',
"Computed cacheFile={$this->cacheFile} for {$repoDir}"
'--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 ) {
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'];
}
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'];
}
$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 );
return true;
}
- return self::checkStructuredFilterUiEnabled(
+ return static::checkStructuredFilterUiEnabled(
$this->getConfig(),
$this->getUser()
);
$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 [
}
}
- return $number;
+ return (string)$number;
}
/**
* @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:
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.
controller.initialize(
mw.config.get( 'wgStructuredChangeFilters' ),
namespaces,
- mw.config.get( 'wgRCFiltersChangeTags' )
+ mw.config.get( 'wgRCFiltersChangeTags' ),
+ conditionalViews
);
// eslint-disable-next-line no-new
/**
* @dataProvider provideTestInsertProtectNullRevision
- * @covers WikiPge::insertProtectNullRevision
- * @covers WikiPge::protectDescription
+ * @covers WikiPage::insertProtectNullRevision
+ * @covers WikiPage::protectDescription
*
* @param string $revCommentMsg
* @param array $limit
];
}
+ /**
+ * @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
*/