From b7ce7aacb0fb6803d9135f465e9cf6b48912883e Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Tue, 3 Sep 2019 09:55:00 +1000 Subject: Add MW_REST_API and MW_ENTRY_POINT Define the global constant MW_REST_API in rest.php, by analogy with MW_API. Also generalize this by adding MW_ENTRY_POINT, which contains the entry script name, "cli" or "unknown". This allows tests such as if ( MW_ENTRY_POINT !== 'index' ) which is probably what is really intended by defined('MW_API') in many cases. Change-Id: I24099f4cdd170de17afd6e1bbad67c9b204071fc --- includes/Setup.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'includes/Setup.php') diff --git a/includes/Setup.php b/includes/Setup.php index 1e65f52a952f..7cf223b94233 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -52,6 +52,17 @@ if ( ini_get( 'mbstring.func_overload' ) ) { die( 'MediaWiki does not support installations where mbstring.func_overload is non-zero.' ); } +// Define MW_ENTRY_POINT if it's not already, so that config code can check the +// value without using defined() +if ( !defined( 'MW_ENTRY_POINT' ) ) { + /** + * The entry point, which may be either the script filename without the + * file extension, or "cli" for maintenance scripts, or "unknown" for any + * entry point that does not set the constant. + */ + define( 'MW_ENTRY_POINT', 'unknown' ); +} + // Start the autoloader, so that extensions can derive classes from core files require_once "$IP/includes/AutoLoader.php"; -- cgit v1.2.3