diff --git a/admin-dev/tabs/AdminPerformance.php b/admin-dev/tabs/AdminPerformance.php
index 7e260a497..5ae311970 100644
--- a/admin-dev/tabs/AdminPerformance.php
+++ b/admin-dev/tabs/AdminPerformance.php
@@ -42,19 +42,19 @@ class AdminPerformance extends AdminTab
$this->_errors[] = Tools::displayError('Caching system is missing');
else
$settings = preg_replace('/define\(\'_PS_CACHING_SYSTEM_\', \'([a-z0-9=\/+-_]+)\'\);/Ui', 'define(\'_PS_CACHING_SYSTEM_\', \''.$caching_system.'\');', $settings);
- if ($cache_active AND $caching_system == 'MCached' AND !extension_loaded('memcache'))
+ if ($cache_active AND $caching_system == 'CacheMemcache' AND !extension_loaded('memcache'))
$this->_errors[] = Tools::displayError('To use Memcached, you must install the Memcache PECL extension on your server.').' http://www.php.net/manual/en/memcache.installation.php';
- elseif ($cache_active AND $caching_system == 'CacheFS' AND !is_writable(_PS_CACHEFS_DIRECTORY_))
+ elseif ($cache_active AND $caching_system == 'CacheFs' AND !is_writable(_PS_CACHEFS_DIRECTORY_))
$this->_errors[] = Tools::displayError('To use CacheFS the directory').' '.realpath(_PS_CACHEFS_DIRECTORY_).' '.Tools::displayError('must be writable');
- if ($caching_system == 'CacheFS')
+ if ($caching_system == 'CacheFs')
{
if (!($depth = Tools::getValue('ps_cache_fs_directory_depth')))
$this->_errors[] = Tools::displayError('Please set a directory depth');
if (!sizeof($this->_errors))
{
- CacheFS::deleteCacheDirectory();
- CacheFS::createCacheDirectories((int)$depth);
+ CacheFs::deleteCacheDirectory();
+ CacheFs::createCacheDirectories((int)$depth);
Configuration::updateValue('PS_CACHEFS_DIRECTORY_DEPTH', (int)$depth);
}
}
@@ -82,7 +82,7 @@ class AdminPerformance extends AdminTab
$this->_errors[] = Tools::displayError('Memcached weight is missing');
if (!sizeof($this->_errors))
{
- if (MCached::addServer(pSQL(Tools::getValue('memcachedIp')), (int)Tools::getValue('memcachedPort'), (int)Tools::getValue('memcachedWeight')))
+ if (CacheMemcache::addServer(pSQL(Tools::getValue('memcachedIp')), (int)Tools::getValue('memcachedPort'), (int)Tools::getValue('memcachedWeight')))
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
else
$this->_errors[] = Tools::displayError('Cannot add Memcached server');
@@ -95,7 +95,7 @@ class AdminPerformance extends AdminTab
{
if ($this->tabAccess['add'] === '1')
{
- if (MCached::deleteServer((int)Tools::getValue('deleteMemcachedServer')))
+ if (CacheMemcache::deleteServer((int)Tools::getValue('deleteMemcachedServer')))
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
else
$this->_errors[] = Tools::displayError('Error in deleting Memcached server');
@@ -441,8 +441,8 @@ class AdminPerformance extends AdminTab
@@ -479,7 +479,7 @@ class AdminPerformance extends AdminTab
';
- $servers = MCached::getMemcachedServers();
+ $servers = CacheMemcache::getMemcachedServers();
if ($servers)
{
echo '
diff --git a/cache/class_index.php b/cache/class_index.php
index b31f65617..eb77f747a 100644
--- a/cache/class_index.php
+++ b/cache/class_index.php
@@ -26,10 +26,6 @@
'CMS' => 'override/classes/CMS.php',
'CMSCategoryCore' => 'classes/CMSCategory.php',
'CMSCategory' => 'override/classes/CMSCategory.php',
- 'CacheCore' => 'classes/Cache.php',
- 'Cache' => 'override/classes/Cache.php',
- 'CacheFSCore' => 'classes/CacheFS.php',
- 'CacheFS' => 'override/classes/CacheFS.php',
'CarrierCore' => 'classes/Carrier.php',
'Carrier' => 'override/classes/Carrier.php',
'CarrierModuleCore' => 'classes/CarrierModule.php',
@@ -126,8 +122,6 @@
'LocalizationPack' => 'override/classes/LocalizationPack.php',
'LoggerCore' => 'classes/Logger.php',
'Logger' => 'override/classes/Logger.php',
- 'MCachedCore' => 'classes/MCached.php',
- 'MCached' => 'override/classes/MCached.php',
'MailCore' => 'classes/Mail.php',
'Mail' => 'override/classes/Mail.php',
'ManufacturerCore' => 'classes/Manufacturer.php',
@@ -210,7 +204,7 @@
'SpecificPrice' => 'override/classes/SpecificPrice.php',
'StateCore' => 'classes/State.php',
'State' => 'override/classes/State.php',
- 'StockCore' => 'classes/Stock.php',
+ 'StockCore' => 'classes/stock/Stock.php',
'Stock' => 'override/classes/Stock.php',
'StockMvtCore' => 'classes/StockMvt.php',
'StockMvt' => 'override/classes/StockMvt.php',
@@ -238,6 +232,12 @@
'Validate' => 'override/classes/Validate.php',
'ZoneCore' => 'classes/Zone.php',
'Zone' => 'override/classes/Zone.php',
+ 'CacheCore' => 'classes/cache/Cache.php',
+ 'Cache' => 'override/classes/cache/Cache.php',
+ 'CacheFsCore' => 'classes/cache/CacheFs.php',
+ 'CacheFs' => 'override/classes/cache/CacheFs.php',
+ 'CacheMemcacheCore' => 'classes/cache/CacheMemcache.php',
+ 'CacheMemcache' => 'override/classes/cache/CacheMemcache.php',
'DbCore' => 'classes/db/Db.php',
'Db' => 'override/classes/db/Db.php',
'DbMySQLiCore' => 'classes/db/DbMySQLi.php',
@@ -262,6 +262,10 @@
'Shop' => 'override/classes/shop/Shop.php',
'ShopUrlCore' => 'classes/shop/ShopUrl.php',
'ShopUrl' => 'override/classes/shop/ShopUrl.php',
+ 'StockManagerFactoryCore' => 'classes/stock/StockManagerFactory.php',
+ 'StockManagerFactory' => '',
+ 'StockManagerInterface' => 'classes/stock/StockManagerInterface.php',
+ 'StockManagerModule' => 'classes/stock/StockManagerModule.php',
'TaxCore' => 'classes/tax/Tax.php',
'Tax' => 'override/classes/tax/Tax.php',
'TaxCalculatorCore' => 'classes/tax/TaxCalculator.php',
diff --git a/classes/Cache.php b/classes/Cache.php
deleted file mode 100755
index c1da488b7..000000000
--- a/classes/Cache.php
+++ /dev/null
@@ -1,80 +0,0 @@
-
-* @copyright 2007-2011 PrestaShop SA
-* @version Release: $Revision: 6844 $
-* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-abstract class CacheCore
-{
- /** @var Cache */
- protected static $_instance;
- protected $_keysCached = array();
- protected $_tablesCached = array();
- protected $_blackList = array('cart',
- 'cart_discount',
- 'cart_product',
- 'connections',
- 'connections_source',
- 'connections_page',
- 'customer',
- 'customer_group',
- 'customized_data',
- 'guest',
- 'pagenotfound',
- 'page_viewed');
-
- /**
- * @return Cache
- */
- public static function getInstance()
- {
- if(!isset(self::$_instance))
- {
- $caching_system = _PS_CACHING_SYSTEM_;
- self::$_instance = new $caching_system();
-
- }
- return self::$_instance;
- }
-
- protected function __construct()
- {
- }
-
- protected function isBlacklist($query)
- {
- foreach ($this->_blackList AS $find)
- if (strpos($query, $find))
- return true;
- return false;
- }
-
- abstract public function get($key);
- abstract public function delete($key, $timeout = 0);
- abstract public function set($key, $value, $expire = 0);
- abstract public function flush();
- abstract public function setQuery($query, $result);
- abstract public function deleteQuery($query);
-
-}
diff --git a/classes/CacheFS.php b/classes/CacheFS.php
deleted file mode 100755
index 79cf66001..000000000
--- a/classes/CacheFS.php
+++ /dev/null
@@ -1,181 +0,0 @@
-
-* @copyright 2007-2011 PrestaShop SA
-* @version Release: $Revision: 6844 $
-* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-class CacheFSCore extends Cache {
-
- protected $_depth;
-
- protected function __construct()
- {
- parent::__construct();
- $this->_init();
- }
-
- protected function _init()
- {
- $this->_depth = Db::getInstance()->getValue('SELECT value FROM '._DB_PREFIX_.'configuration WHERE name=\'PS_CACHEFS_DIRECTORY_DEPTH\'', false);
- return $this->_setKeys();
- }
-
- public function set($key, $value, $expire = 0)
- {
- $path = $this->getPath();
- for ($i = 0; $i < $this->_depth; $i++)
- $path .= $key[$i].'/';
- if (@file_put_contents($path.$key, serialize($value)))
- {
- $this->_keysCached[$key] = true;
- return $key;
- }
- return false;
- }
-
- public function setNumRows($key, $value, $expire = 0)
- {
- return $this->set($key.'_nrows', $value, $expire);
- }
-
- public function getNumRows($key)
- {
- return $this->get($key.'_nrows');
- }
-
- public function get($key)
- {
- if (!isset($this->_keysCached[$key]))
- return false;
- $path = $this->getPath();
- for ($i = 0; $i < $this->_depth; $i++)
- $path .= $key[$i].'/';
- if (!file_exists($path.$key))
- {
- unset($this->_keysCached[$key]);
- return false;
- }
- $file = file_get_contents($path.$key);
- return unserialize($file);
- }
-
- protected function _setKeys()
- {
- if (file_exists($this->getPath().'keysCached'))
- {
- $file = file_get_contents($this->getPath().'keysCached');
- $this->_keysCached = unserialize($file);
- }
- if (file_exists($this->getPath().'tablesCached'))
- {
- $file = file_get_contents($this->getPath().'tablesCached');
- $this->_tablesCached = unserialize($file);
- }
- return true;
- }
-
- public function setQuery($query, $result)
- {
- $md5_query = md5($query);
- if ($this->isBlacklist($query))
- return true;
- $this->_setKeys();
- if (isset($this->_keysCached[$md5_query]))
- return true;
- $key = $this->set($md5_query, $result);
- if (preg_match_all('/('._DB_PREFIX_.'[a-z_-]*)`?.*/i', $query, $res))
- foreach($res[1] AS $table)
- if(!isset($this->_tablesCached[$table][$key]))
- $this->_tablesCached[$table][$key] = true;
- $this->_writeKeys();
- }
-
- public function delete($key, $timeout = 0)
- {
- $path = $this->getPath();
- if (!isset($this->_keysCached[$key]))
- return;
- for ($i = 0; $i < $this->_depth; $i++)
- $path.=$key[$i].'/';
- if (!file_exists($path.$key))
- return true;
- if (!unlink($path.$key))
- return false;
- unset($this->_keysCached[$key]);
- return true;
- }
-
- public function deleteQuery($query)
- {
- $this->_setKeys();
- if (preg_match_all('/('._DB_PREFIX_.'[a-z_-]*)`?.*/i', $query, $res))
- foreach ($res[1] AS $table)
- if (isset($this->_tablesCached[$table]))
- {
- foreach (array_keys($this->_tablesCached[$table]) AS $fsKey)
- {
- $this->delete($fsKey);
- $this->delete($fsKey.'_nrows');
- }
- unset($this->_tablesCached[$table]);
- }
- $this->_writeKeys();
- }
-
- public function flush()
- {
- }
-
- private function _writeKeys()
- {
-
- @file_put_contents($this->getPath().'keysCached', serialize($this->_keysCached));
- @file_put_contents($this->getPath().'tablesCached', serialize($this->_tablesCached));
- }
-
- public static function deleteCacheDirectory()
- {
- Tools::deleteDirectory($this->getPath(), false);
- }
-
- public static function createCacheDirectories($level_depth, $directory = false)
- {
- if (!$directory)
- $directory = $this->getPath();
- $chars = '0123456789abcdefghijklmnopqrstuvwxyz';
- for ($i = 0; $i < strlen($chars); $i++)
- {
- $new_dir = $directory.$chars[$i].'/';
- if (mkdir($new_dir))
- if (chmod($new_dir, 0777))
- if ($level_depth - 1 > 0)
- self::createCacheDirectories($level_depth - 1, $new_dir);
- }
- }
-
- protected function getPath()
- {
- return (defined('_PS_CACHEFS_DIRECTORY_') ? _PS_CACHEFS_DIRECTORY_ : dirname(__FILE__).'/../cache/cachefs/');
- }
-}
diff --git a/classes/MCached.php b/classes/MCached.php
deleted file mode 100755
index 8219163d1..000000000
--- a/classes/MCached.php
+++ /dev/null
@@ -1,174 +0,0 @@
-
-* @copyright 2007-2011 PrestaShop SA
-* @version Release: $Revision: 6844 $
-* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-class MCachedCore extends Cache
-{
- protected $_memcacheObj;
- protected $_isConnected = false;
-
- protected function __construct()
- {
- parent::__construct();
- $this->connect();
- }
-
- public function connect()
- {
- $this->_memcacheObj = new Memcache();
- $servers = self::getMemcachedServers();
- if (!$servers)
- return false;
- foreach ($servers AS $server)
- $this->_memcacheObj->addServer($server['ip'], $server['port'], $server['weight']);
-
- $this->_isConnected = true;
- return $this->_setKeys();
- }
-
- public function set($key, $value, $expire = 0)
- {
- if (!$this->_isConnected)
- return false;
- if ($this->_memcacheObj->set($key, $value, 0, $expire))
- {
- $this->_keysCached[$key] = true;
- return $key;
- }
- }
-
- public function setNumRows($key, $value, $expire = 0)
- {
- return $this->set($key.'_nrows', $value, $expire);
- }
-
- public function getNumRows($key)
- {
- return $this->get($key.'_nrows');
- }
-
- public function get($key)
- {
- if (!isset($this->_keysCached[$key]))
- return false;
- return $this->_memcacheObj->get($key);
- }
-
- protected function _setKeys()
- {
- if (!$this->_isConnected)
- return false;
- $this->_keysCached = $this->_memcacheObj->get('keysCached');
- $this->_tablesCached = $this->_memcacheObj->get('tablesCached');
-
- return true;
- }
-
- public function setQuery($query, $result)
- {
- if (!$this->_isConnected)
- return false;
- if ($this->isBlacklist($query))
- return true;
- $md5_query = md5($query);
- $this->_setKeys();
- if (isset($this->_keysCached[$md5_query]))
- return true;
- $key = $this->set($md5_query, $result);
- if(preg_match_all('/('._DB_PREFIX_.'[a-z_-]*)`?.*/i', $query, $res))
- foreach($res[1] AS $table)
- if(!isset($this->_tablesCached[$table][$key]))
- $this->_tablesCached[$table][$key] = true;
- $this->_writeKeys();
- }
-
- public function delete($key, $timeout = 0)
- {
- if (!$this->_isConnected)
- return false;
- if (!empty($key) AND $this->_memcacheObj->delete($key, $timeout))
- unset($this->_keysCached[$key]);
- }
-
- public function deleteQuery($query)
- {
- if (!$this->_isConnected)
- return false;
- $this->_setKeys();
- if (preg_match_all('/('._DB_PREFIX_.'[a-z_-]*)`?.*/i', $query, $res))
- foreach ($res[1] AS $table)
- if (isset($this->_tablesCached[$table]))
- {
- foreach ($this->_tablesCached[$table] AS $memcachedKey => $foo)
- {
- $this->delete($memcachedKey);
- $this->delete($memcachedKey.'_nrows');
- }
- unset($this->_tablesCached[$table]);
- }
- $this->_writeKeys();
- }
-
- protected function close()
- {
- if (!$this->_isConnected)
- return false;
- return $this->_memcacheObj->close();
- }
-
- public function flush()
- {
- if(!$this->_isConnected)
- return false;
- if ($this->_memcacheObj->flush())
- return $this->_setKeys();
- return false;
- }
-
- private function _writeKeys()
- {
- if (!$this->_isConnected)
- return false;
- $this->_memcacheObj->set('keysCached', $this->_keysCached, 0, 0);
- $this->_memcacheObj->set('tablesCached', $this->_tablesCached, 0, 0);
- $this->close();
- }
-
- public static function addServer($ip, $port, $weight)
- {
- return Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'memcached_servers (ip, port, weight) VALUES(\''.pSQL($ip).'\', '.(int)$port.', '.(int)$weight.')', false);
- }
-
- public static function getMemcachedServers()
- {
- return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT * FROM '._DB_PREFIX_.'memcached_servers', true, false);
- }
-
- public static function deleteServer($id_server)
- {
- return Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'memcached_servers WHERE id_memcached_server='.(int)$id_server);
- }
-}
diff --git a/classes/cache/CacheFs.php b/classes/cache/CacheFs.php
index 79cf66001..fcb182c9e 100755
--- a/classes/cache/CacheFs.php
+++ b/classes/cache/CacheFs.php
@@ -25,7 +25,7 @@
* International Registered Trademark & Property of PrestaShop SA
*/
-class CacheFSCore extends Cache {
+class CacheFsCore extends Cache {
protected $_depth;
diff --git a/install-dev/xml/createDB.php b/install-dev/xml/createDB.php
index db6f2938c..7f2012048 100644
--- a/install-dev/xml/createDB.php
+++ b/install-dev/xml/createDB.php
@@ -66,7 +66,7 @@ $datas = array(
array('_DB_PASSWD_', trim($_GET['password'])),
array('_DB_PREFIX_', trim($_GET['tablePrefix'])),
array('_MYSQL_ENGINE_', trim($_GET['engine'])),
- array('_PS_CACHING_SYSTEM_', 'MCached'),
+ array('_PS_CACHING_SYSTEM_', 'CacheMemcache'),
array('_PS_CACHE_ENABLED_', '0'),
array('_MEDIA_SERVER_1_', ''),
array('_MEDIA_SERVER_2_', ''),
diff --git a/install-dev/xml/doUpgrade.php b/install-dev/xml/doUpgrade.php
index 37c566f57..4531ab0ca 100644
--- a/install-dev/xml/doUpgrade.php
+++ b/install-dev/xml/doUpgrade.php
@@ -256,7 +256,7 @@ $datas = array(
array('_DB_PASSWD_', _DB_PASSWD_),
array('_DB_PREFIX_', _DB_PREFIX_),
array('_MYSQL_ENGINE_', $mysqlEngine),
- array('_PS_CACHING_SYSTEM_', (defined('_PS_CACHING_SYSTEM_') AND _PS_CACHING_SYSTEM_ != 'MemCached') ? _PS_CACHING_SYSTEM_ : 'MCached'),
+ array('_PS_CACHING_SYSTEM_', (defined('_PS_CACHING_SYSTEM_') AND _PS_CACHING_SYSTEM_ != 'CacheMemcache') ? _PS_CACHING_SYSTEM_ : 'CacheMemcache'),
array('_PS_CACHE_ENABLED_', defined('_PS_CACHE_ENABLED_') ? _PS_CACHE_ENABLED_ : '0'),
array('_MEDIA_SERVER_1_', defined('_MEDIA_SERVER_1_') ? _MEDIA_SERVER_1_ : ''),
array('_MEDIA_SERVER_2_', defined('_MEDIA_SERVER_2_') ? _MEDIA_SERVER_2_ : ''),
@@ -335,8 +335,8 @@ foreach ($arrayToClean as $dir)
$depth = Configuration::get('PS_CACHEFS_DIRECTORY_DEPTH');
if($depth)
{
- CacheFS::deleteCacheDirectory();
- CacheFS::createCacheDirectories((int)$depth);
+ CacheFs::deleteCacheDirectory();
+ CacheFs::createCacheDirectories((int)$depth);
}
//sql file execution
diff --git a/override/classes/CacheFS.php b/override/classes/CacheFS.php
deleted file mode 100644
index a48f8ee33..000000000
--- a/override/classes/CacheFS.php
+++ /dev/null
@@ -1,7 +0,0 @@
-