aboutsummaryrefslogtreecommitdiffstats
path: root/includes/cache/FileCacheBase.php
diff options
context:
space:
mode:
authorAryeh Gregor <ayg@aryeh.name>2022-04-26 18:48:03 +0300
committerAryeh Gregor <ayg@aryeh.name>2022-04-26 19:03:37 +0300
commit7b791474a53943ecc7d185f529f46a8794383416 (patch)
tree04bcb69f7eebd41e1ebc71621fae401e4dd74304 /includes/cache/FileCacheBase.php
parentd9200a22c2f77817bcddc510b33d329a4718ddd8 (diff)
downloadmediawikicore-7b791474a53943ecc7d185f529f46a8794383416.tar.gz
mediawikicore-7b791474a53943ecc7d185f529f46a8794383416.zip
Use MainConfigNames instead of string literals, #4
Now largely automated: VARS=$(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | \ tr "\n" '|' | sed "s/|$/\n/;s/'//g") sed -i -E "s/'($VARS)'/MainConfigNames::\1/g" \ $(grep -ERIl "'($VARS)'" includes/) Then git add -p with lots of error-prone manual checking. Then semi-manually add all the necessary "use" lines: vim $(grep -L 'use MediaWiki\\MainConfigNames;' \ $(git diff --cached --name-only --diff-filter=M HEAD^)) I didn't bother fixing lines that were over 100 characters unless they were over 120 and triggered phpcs. Bug: T305805 Change-Id: I74e0ab511abecb276717ad4276a124760a268147
Diffstat (limited to 'includes/cache/FileCacheBase.php')
-rw-r--r--includes/cache/FileCacheBase.php19
1 files changed, 10 insertions, 9 deletions
diff --git a/includes/cache/FileCacheBase.php b/includes/cache/FileCacheBase.php
index 8fe986a0abfe..ce9ca3249675 100644
--- a/includes/cache/FileCacheBase.php
+++ b/includes/cache/FileCacheBase.php
@@ -22,6 +22,7 @@
*/
use MediaWiki\Config\ServiceOptions;
+use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use Wikimedia\AtEase\AtEase;
use Wikimedia\IPUtils;
@@ -34,11 +35,11 @@ use Wikimedia\IPUtils;
abstract class FileCacheBase {
/** @var string[] */
private const CONSTRUCTOR_OPTIONS = [
- 'CacheEpoch',
- 'FileCacheDepth',
- 'FileCacheDirectory',
- 'MimeType',
- 'UseGzip',
+ MainConfigNames::CacheEpoch,
+ MainConfigNames::FileCacheDepth,
+ MainConfigNames::FileCacheDirectory,
+ MainConfigNames::MimeType,
+ MainConfigNames::UseGzip,
];
protected $mKey;
@@ -60,7 +61,7 @@ abstract class FileCacheBase {
self::CONSTRUCTOR_OPTIONS,
MediaWikiServices::getInstance()->getMainConfig()
);
- $this->mUseGzip = (bool)$this->options->get( 'UseGzip' );
+ $this->mUseGzip = (bool)$this->options->get( MainConfigNames::UseGzip );
}
/**
@@ -68,7 +69,7 @@ abstract class FileCacheBase {
* @return string
*/
final protected function baseCacheDirectory() {
- return $this->options->get( 'FileCacheDirectory' );
+ return $this->options->get( MainConfigNames::FileCacheDirectory );
}
/**
@@ -131,7 +132,7 @@ abstract class FileCacheBase {
* @return bool
*/
public function isCacheGood( $timestamp = '' ) {
- $cacheEpoch = $this->options->get( 'CacheEpoch' );
+ $cacheEpoch = $this->options->get( MainConfigNames::CacheEpoch );
if ( !$this->isCached() ) {
return false;
@@ -226,7 +227,7 @@ abstract class FileCacheBase {
* @return string
*/
protected function hashSubdirectory() {
- $fileCacheDepth = $this->options->get( 'FileCacheDepth' );
+ $fileCacheDepth = $this->options->get( MainConfigNames::FileCacheDepth );
$subdir = '';
if ( $fileCacheDepth > 0 ) {