From 937847b26a4c136cc3cff8c293fa868da6b4588a Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Wed, 13 Dec 2023 06:07:02 +0000 Subject: 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 --- includes/Storage/SqlBlobStore.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'includes/Storage') 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; -- cgit v1.2.3