From 7dcfbf2a6263278a7385f380778584d084a79a92 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 25 Jan 2023 16:11:10 +0100 Subject: Allow some maintenance scripts to be called without a LocalSettings Subclasses of Maintenance that can function without database access can now override canExecuteWithoutLocalSettings to return true. This is useful for scripts that need to be able to run before or without installing MediaWiki. When no config file is present, the storage backend will be disabled. Any attempt to access the database will result in an error. NOTE: This makes MediaWikiServices::disableBackendServices() more comprehensive, to avoid premature failures during service construction. This change makes it necessary to adjust how the installer manages service overrides. The CLI installer is covered by CI, I tested the web installer manually. Change-Id: Ie84010c80f32cbdfd34aff9dde1bfde1ed531793 --- includes/objectcache/ObjectCache.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'includes/objectcache/ObjectCache.php') diff --git a/includes/objectcache/ObjectCache.php b/includes/objectcache/ObjectCache.php index b9beeb54f959..b6505ee7088f 100644 --- a/includes/objectcache/ObjectCache.php +++ b/includes/objectcache/ObjectCache.php @@ -246,9 +246,14 @@ class ObjectCache { } } - if ( MediaWikiServices::getInstance()->isServiceDisabled( 'DBLoadBalancer' ) ) { - // The LoadBalancer is disabled, probably because - // MediaWikiServices::disableStorageBackend was called. + $services = MediaWikiServices::getInstance(); + + if ( $services->isServiceDisabled( 'DBLoadBalancer' ) ) { + // The DBLoadBalancer service is disabled, so we can't use the database! + $candidate = CACHE_NONE; + } elseif ( $services->isStorageDisabled() ) { + // Storage services are disabled because MediaWikiServices::disableStorage() + // was called. This is typically the case during installation. $candidate = CACHE_NONE; } else { $candidate = CACHE_DB; -- cgit v1.2.3