aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Storage
diff options
context:
space:
mode:
authorTimo Tijhof <krinkle@fastmail.com>2023-12-13 06:07:02 +0000
committerTim Starling <tstarling@wikimedia.org>2024-01-11 15:12:24 +1100
commit937847b26a4c136cc3cff8c293fa868da6b4588a (patch)
tree1ccdc11946f4f91d4bb2ef3c2be0972d07cb3edf /includes/Storage
parentbd2031e0f436f88503641dc5f358ba952144c438 (diff)
downloadmediawikicore-937847b26a4c136cc3cff8c293fa868da6b4588a.tar.gz
mediawikicore-937847b26a4c136cc3cff8c293fa868da6b4588a.zip
Replace various magic numbers with easy-to-verify expressions
Follows-up I8518e0488 (9c02258a04). Instead of documenting how to compute the number to manually verify it, use the expression directly. This should make it significantly easier to understand, verify, and modify. Noteworthy: * Language.php, I kept 31_556_952 as-is because the calculation would otherwise involve a float. It also has the benefit of allowing the long durations to build upon that as a given number. * SqlBlobStore.php, remove this irrelevant default value as it is unreachable. The only call to new SqlBlobStore is BlobStoreFactory, which always calls setCacheExpiry. For back-compat and to keep tests as-is, move to re-used constant between class and config. Change-Id: I86b034883bd7efdf93b8365b43178af826f1c703
Diffstat (limited to 'includes/Storage')
-rw-r--r--includes/Storage/SqlBlobStore.php13
1 files changed, 8 insertions, 5 deletions
diff --git a/includes/Storage/SqlBlobStore.php b/includes/Storage/SqlBlobStore.php
index 944aa08e1285..892eaa3f48b9 100644
--- a/includes/Storage/SqlBlobStore.php
+++ b/includes/Storage/SqlBlobStore.php
@@ -53,6 +53,9 @@ class SqlBlobStore implements IDBAccessObject, BlobStore {
// Note: the name has been taken unchanged from the old Revision class.
public const TEXT_CACHE_GROUP = 'revisiontext:10';
+ /** @internal */
+ public const DEFAULT_TTL = 7 * 24 * 3600; // 7 days
+
/**
* @var ILoadBalancer
*/
@@ -76,7 +79,7 @@ class SqlBlobStore implements IDBAccessObject, BlobStore {
/**
* @var int
*/
- private $cacheExpiry = 604_800; // 7 days
+ private $cacheExpiry = self::DEFAULT_TTL;
/**
* @var bool
@@ -117,28 +120,28 @@ class SqlBlobStore implements IDBAccessObject, BlobStore {
}
/**
- * @return int time for which blobs can be cached, in seconds
+ * @return int Time for which blobs can be cached, in seconds
*/
public function getCacheExpiry() {
return $this->cacheExpiry;
}
/**
- * @param int $cacheExpiry time for which blobs can be cached, in seconds
+ * @param int $cacheExpiry Time for which blobs can be cached, in seconds
*/
public function setCacheExpiry( int $cacheExpiry ) {
$this->cacheExpiry = $cacheExpiry;
}
/**
- * @return bool whether blobs should be compressed for storage
+ * @return bool Whether blobs should be compressed for storage
*/
public function getCompressBlobs() {
return $this->compressBlobs;
}
/**
- * @param bool $compressBlobs whether blobs should be compressed for storage
+ * @param bool $compressBlobs Whether blobs should be compressed for storage
*/
public function setCompressBlobs( $compressBlobs ) {
$this->compressBlobs = $compressBlobs;