From 4d74c8bf74f0a7bdb65ecc8802726c8408e583f8 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Thu, 4 Oct 2018 16:34:28 -0400 Subject: [PATCH] Fix Setup.php file-scope test Way back in r8196, a test was added to assert that Setup.php is being included at file scope.[1] That test was broken when I633a6ff23 moved the inclusion of DefaultSettings.php into Setup.php itself. This fixes the test by having it directly set a variable and see if that variable is a global. Yes, there's several ways to bypass it, but we're just trying to avoid accidents here rather than trying to be foolproof. [1]: Or really, in the same scope as DefaultSettings.php. But it intended to be checking for file scope. Change-Id: I9b5f15bf01c2903e8d44d85c54465d90c047cb51 --- includes/Setup.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/includes/Setup.php b/includes/Setup.php index 43bc2d8de3..bdfce62293 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -35,6 +35,14 @@ if ( !defined( 'MEDIAWIKI' ) ) { exit( 1 ); } +// Check to see if we are at the file scope +$wgScopeTest = 'MediaWiki Setup.php scope test'; +if ( !isset( $GLOBALS['wgScopeTest'] ) || $GLOBALS['wgScopeTest'] !== $wgScopeTest ) { + echo "Error, Setup.php must be included from the file scope.\n"; + die( 1 ); +} +unset( $wgScopeTest ); + /** * Pre-config setup: Before loading LocalSettings.php */ @@ -118,12 +126,6 @@ ExtensionRegistry::getInstance()->loadFromQueue(); // Don't let any other extensions load ExtensionRegistry::getInstance()->finish(); -// Check to see if we are at the file scope -if ( !isset( $wgVersion ) ) { - echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n"; - die( 1 ); -} - mb_internal_encoding( 'UTF-8' ); // Set the configured locale on all requests for consisteny -- 2.20.1