From 80ee4cdfd8001e3f662b146e9334a3cbac8d45fc Mon Sep 17 00:00:00 2001 From: rMalie Date: Mon, 4 Jun 2012 12:58:52 +0000 Subject: [PATCH] // Some performance improvement #PSCFV-2658 --- classes/shop/Shop.php | 37 +++++++++++++++++-------------------- config/config.inc.php | 1 - 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php index 11d6cc131..cecb47794 100644 --- a/classes/shop/Shop.php +++ b/classes/shop/Shop.php @@ -274,14 +274,6 @@ class ShopCore extends ObjectModel */ public static function initialize() { - // Get list of excluded uri - $dirname = dirname(__FILE__); - $directories = scandir($dirname.'/../'); - $excluded_uris = array(); - foreach ($directories as $directory) - if (is_dir($dirname.'/../'.$directory) && (!preg_match ('/^\./', $directory))) - $excluded_uris[] = $directory; - // Find current shop from URL if (!($id_shop = Tools::getValue('id_shop')) || defined('_PS_ADMIN_DIR_')) { @@ -339,24 +331,29 @@ class ShopCore extends ObjectModel $shop = new Shop(Configuration::get('PS_SHOP_DEFAULT')); $shop->physical_uri = preg_replace('#/+#', '/', str_replace('\\', '/', dirname(dirname($_SERVER['SCRIPT_NAME']))).'/'); $shop->virtual_uri = ''; - return $shop; } - - $shop = new Shop($id_shop); - if (!Validate::isLoadedObject($shop) || !$shop->active || !$id_shop) + else { - // No shop found ... too bad, let's redirect to default shop - $default_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT')); + $shop = new Shop($id_shop); + if (!Validate::isLoadedObject($shop) || !$shop->active || !$id_shop) + { + // No shop found ... too bad, let's redirect to default shop + $default_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT')); - // Hmm there is something really bad in your Prestashop ! - if (!Validate::isLoadedObject($default_shop)) - throw new PrestaShopException('Shop not found'); + // Hmm there is something really bad in your Prestashop ! + if (!Validate::isLoadedObject($default_shop)) + throw new PrestaShopException('Shop not found'); - $url = 'http://'.$default_shop->domain.$default_shop->getBaseURI().'index.php?'.$_SERVER['QUERY_STRING']; - header('location: '.$url); - exit; + $url = 'http://'.$default_shop->domain.$default_shop->getBaseURI().'index.php?'.$_SERVER['QUERY_STRING']; + header('location: '.$url); + exit; + } } + self::$context_id_shop = $shop->id; + self::$context_id_shop_group = $shop->id_shop_group; + self::$context = self::CONTEXT_SHOP; + return $shop; } diff --git a/config/config.inc.php b/config/config.inc.php index a1a5a392b..90e39c33f 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -87,7 +87,6 @@ if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST'])) /* Initialize the current Shop */ Context::getContext()->shop = Shop::initialize(); -Shop::setContext(Shop::CONTEXT_SHOP, Context::getContext()->shop->id); define('_THEME_NAME_', Context::getContext()->shop->getTheme()); define('__PS_BASE_URI__', Context::getContext()->shop->getBaseURI());