From 9a5c21630b5b7e2e3adb2e0334defbd9515aa833 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 20 Feb 2022 16:35:32 +0300 Subject: [PATCH] update.php: better error reporting if invoked with PHP SAPI other than CLI --- update.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/update.php b/update.php index 90251c2f3..f33458c2e 100755 --- a/update.php +++ b/update.php @@ -10,6 +10,14 @@ require_once "autoload.php"; require_once "functions.php"; + + if (php_sapi_name() != "cli") { + header("Content-type: text/plain"); + printf("Please run this script using PHP CLI executable (you're using PHP SAPI: %s, PHP_EXECUTABLE is set to '%s')\n", + php_sapi_name(), Config::get(Config::PHP_EXECUTABLE)); + exit(1); + } + Config::sanity_check(); function make_stampfile(string $filename): bool { @@ -100,12 +108,6 @@ $options_map[$command . $data["suffix"]] = [ $data["arghelp"], $data["description"] ]; } - if (php_sapi_name() != "cli") { - header("Content-type: text/plain"); - print "Please run this script from the command line.\n"; - exit; - } - $options = getopt("", array_keys($options_map)); if ($options === false || count($options) == 0 || isset($options["help"]) ) {