[*] Core: you can now pass a query string with php-cli which will merged with for cronjobs and other things
This commit is contained in:
@@ -2198,6 +2198,27 @@ exit;
|
||||
return (PHP_INT_MAX == '9223372036854775807');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool true if php-cli is used
|
||||
*/
|
||||
public static function isPHPCLI()
|
||||
{
|
||||
return (defined('STDIN') || (Tools::strtolower(php_sapi_name()) == 'cli' && (!isset($_SERVER['REMOTE_ADDR']) || empty($_SERVER['REMOTE_ADDR']))));
|
||||
}
|
||||
|
||||
public static function argvToGET($argc, $argv)
|
||||
{
|
||||
if ($argc <= 1)
|
||||
return;
|
||||
|
||||
// get the first argument and parse it like a query string
|
||||
parse_str($argv[1], $args);
|
||||
if (!is_array($args) || !count($args))
|
||||
return;
|
||||
$_GET = array_merge($args, $_GET);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get max file upload size considering server settings and optional max value
|
||||
*
|
||||
|
||||
@@ -349,12 +349,16 @@ class ShopCore extends ObjectModel
|
||||
}
|
||||
}
|
||||
|
||||
if (!$id_shop && defined('_PS_ADMIN_DIR_'))
|
||||
if ((!$id_shop && defined('_PS_ADMIN_DIR_')) || Tools::isPHPCLI())
|
||||
{
|
||||
// If in admin, we can access to the shop without right URL
|
||||
$shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
|
||||
$shop = new Shop((int)Configuration::get('PS_SHOP_DEFAULT'));
|
||||
$shop->physical_uri = preg_replace('#/+#', '/', str_replace('\\', '/', dirname(dirname($_SERVER['SCRIPT_NAME']))).'/');
|
||||
$shop->virtual_uri = '';
|
||||
|
||||
// Define HTTP_HOST if PHP is launched with php-cli
|
||||
if (Tools::isPHPCLI() && !isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
|
||||
$_SERVER['HTTP_HOST'] = $shop->domain;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -53,6 +53,9 @@ require_once(dirname(__FILE__).'/settings.inc.php');
|
||||
|
||||
require_once(dirname(__FILE__).'/autoload.php');
|
||||
|
||||
if (Tools::isPHPCLI())
|
||||
Tools::argvToGET($argc, $argv);
|
||||
|
||||
if (_PS_DEBUG_PROFILING_)
|
||||
{
|
||||
include_once(_PS_TOOL_DIR_.'profiling/Controller.php');
|
||||
|
||||
Reference in New Issue
Block a user