Setup.php: allow loading config schema from MainConfigSchema.
Loading the config schema from MainConfigSchema using reflection is slow, so we don't want to do it when serving traffic. But when re-generating DefaultSettings.php or config-schema.php, we want to load the schema from the canonical source. That way, these scripts can still be used if DefaultSettings.php and config-schema.php are broken. Change-Id: Idc0d8ca0f4a700b771e6182d53ef4a0efab7110c
This commit is contained in:
parent
7a4f38ae83
commit
cd774c99bc
3 changed files with 16 additions and 1 deletions
|
|
@ -54,12 +54,14 @@
|
|||
use MediaWiki\HeaderCallback;
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\MainConfigSchema;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Settings\Config\GlobalConfigBuilder;
|
||||
use MediaWiki\Settings\Config\PhpIniSink;
|
||||
use MediaWiki\Settings\LocalSettingsLoader;
|
||||
use MediaWiki\Settings\SettingsBuilder;
|
||||
use MediaWiki\Settings\Source\PhpSettingsSource;
|
||||
use MediaWiki\Settings\Source\ReflectionSchemaSource;
|
||||
use MediaWiki\Settings\WikiFarmSettingsLoader;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Wikimedia\RequestTimeout\RequestTimeout;
|
||||
|
|
@ -143,7 +145,12 @@ $wgSettings = new SettingsBuilder(
|
|||
new PhpIniSink()
|
||||
);
|
||||
|
||||
if ( getenv( 'MW_USE_LEGACY_DEFAULT_SETTINGS' ) || defined( 'MW_USE_LEGACY_DEFAULT_SETTINGS' ) ) {
|
||||
if ( defined( 'MW_USE_CONFIG_SCHEMA_CLASS' ) ) {
|
||||
// Load config schema from MainConfigSchema. Useful for running scripts that
|
||||
// generate other representations of the config schema. This is slow, so it
|
||||
// should not be used for serving web traffic.
|
||||
$wgSettings->load( new ReflectionSchemaSource( MainConfigSchema::class ) );
|
||||
} elseif ( getenv( 'MW_USE_LEGACY_DEFAULT_SETTINGS' ) || defined( 'MW_USE_LEGACY_DEFAULT_SETTINGS' ) ) {
|
||||
// Load the old DefaultSettings.php file. Should be removed in 1.39. See T300129.
|
||||
require_once "$IP/includes/DefaultSettings.php";
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ use Wikimedia\StaticArrayWriter;
|
|||
require_once __DIR__ . '/Maintenance.php';
|
||||
require_once __DIR__ . '/includes/ConfigSchemaDerivativeTrait.php';
|
||||
|
||||
// Tell Setup.php to load the config schema from MainConfigSchema rather than
|
||||
// any generated file, so we can use this script to re-generate a broken schema file.
|
||||
define( 'MW_USE_CONFIG_SCHEMA_CLASS', 1 );
|
||||
|
||||
/**
|
||||
* Maintenance script that generates a DefaultSettings.php file,
|
||||
* for backwards compatibility and as documentation stub.
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ use Wikimedia\StaticArrayWriter;
|
|||
require_once __DIR__ . '/Maintenance.php';
|
||||
require_once __DIR__ . '/includes/ConfigSchemaDerivativeTrait.php';
|
||||
|
||||
// Tell Setup.php to load the config schema from MainConfigSchema rather than
|
||||
// any generated file, so we can use this script to re-generate a broken schema file.
|
||||
define( 'MW_USE_CONFIG_SCHEMA_CLASS', 1 );
|
||||
|
||||
/**
|
||||
* Maintenance script that generates the PHP representation of the config-schema.yaml file.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue