From 38a45d325fbd9e71f9c274bd1bee70a3bc6a2eea Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 2 Jan 2015 00:01:17 +0100 Subject: [PATCH] See issue 1218: generate $argv and $argc from $_SERVER if it wasn't defined. --- boot.php | 8 ++++++++ include/dbupdate.php | 3 +-- testargs.php | 10 ++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/boot.php b/boot.php index 34836a97aa..fa4f8b072e 100644 --- a/boot.php +++ b/boot.php @@ -2388,3 +2388,11 @@ if(!function_exists('exif_imagetype')) { return($size[2]); } } + +// See https://github.com/friendica/friendica/issues/1218 +// Try to get the values for $argv and $argc via the $_SERVER array +if (!isset($argv) && array_key_exists('argv', $_SERVER)) + $argv = $_SERVER['argv']; + +if (!isset($argc) && array_key_exists('argc', $_SERVER)) + $argv = $_SERVER['argc']; diff --git a/include/dbupdate.php b/include/dbupdate.php index eb2eda48da..3fcd6b7f05 100644 --- a/include/dbupdate.php +++ b/include/dbupdate.php @@ -8,7 +8,7 @@ function dbupdate_run(&$argv, &$argc) { if(is_null($a)){ $a = new App; } - + if(is_null($db)) { @include(".htconfig.php"); require_once("include/dba.php"); @@ -26,4 +26,3 @@ if (array_search(__file__,get_included_files())===0){ dbupdate_run($argv,$argc); killme(); } - diff --git a/testargs.php b/testargs.php index 4c9bce4e93..8c6da430e9 100644 --- a/testargs.php +++ b/testargs.php @@ -8,14 +8,16 @@ * During installation we need to check if register_argc_argv is * enabled for the command line PHP processor, because otherwise * deliveries will fail. So we will do a shell exec of php and - * execute this file with a command line argument, and see if it - * echoes the argument back to us. Otherwise notify the person + * execute this file with a command line argument, and see if it + * echoes the argument back to us. Otherwise notify the person * that their installation doesn't meet the system requirements. * - */ + */ + - if(($argc > 1) && isset($argv[1])) echo $argv[1]; +elseif(($_SERVER["argc"] > 1) && isset($_SERVER["argv"][1])) + echo $_SERVER["argv"][1]; else echo '';