From ee8da0499b6fbad53bdf1bdb44e0d0090aee810d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Wed, 15 May 2013 16:46:48 +0200 Subject: [PATCH] // also set query_string and server_name --- classes/Tools.php | 1 + classes/shop/Shop.php | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/classes/Tools.php b/classes/Tools.php index d0c8208a6..7fc55ca80 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -2217,6 +2217,7 @@ exit; if (!is_array($args) || !count($args)) return; $_GET = array_merge($args, $_GET); + $_SERVER['QUERY_STRING'] = $argv[1]; } /** diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php index 068b47101..da7a42e6c 100644 --- a/classes/shop/Shop.php +++ b/classes/shop/Shop.php @@ -356,12 +356,20 @@ class ShopCore extends ObjectModel $id_shop = (int)Configuration::get('PS_SHOP_DEFAULT'); $shop = new Shop((int)$id_shop); + if (!Validate::isLoadedObject($shop)) + $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; + // Define some $_SERVER variables like HTTP_HOST if PHP is launched with php-cli + if (Tools::isPHPCLI()) + { + if(!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST'])) + $_SERVER['HTTP_HOST'] = $shop->domain; + if(!isset($_SERVER['SERVER_NAME']) || empty($_SERVER['SERVER_NAME'])) + $_SERVER['SERVER_NAME'] = $shop->domain; + } } else {