From 172efaabd779e7b671db6bd7a30185bd0268a68e Mon Sep 17 00:00:00 2001 From: rMalie Date: Tue, 11 Oct 2011 11:28:31 +0000 Subject: [PATCH] [-] MO: fix blocktopmenu install --- cache/class_index.php | 2 +- classes/Module.php | 4 ++-- classes/db/Db.php | 7 ++++++- modules/blocktopmenu/blocktopmenu.php | 26 +++++++++++++------------- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/cache/class_index.php b/cache/class_index.php index 03a8f2a0a..e0ad94d1c 100644 --- a/cache/class_index.php +++ b/cache/class_index.php @@ -235,7 +235,7 @@ 'CacheCore' => 'classes/cache/Cache.php', 'Cache' => 'override/classes/cache/Cache.php', 'CacheApcCore' => 'classes/cache/CacheApc.php', - 'CacheApc' => '', + 'CacheApc' => 'override/classes/cache/CacheApc.php', 'CacheFsCore' => 'classes/cache/CacheFs.php', 'CacheFs' => 'override/classes/cache/CacheFs.php', 'CacheMemcacheCore' => 'classes/cache/CacheMemcache.php', diff --git a/classes/Module.php b/classes/Module.php index 774c03dc7..22cfeb4d1 100644 --- a/classes/Module.php +++ b/classes/Module.php @@ -156,7 +156,7 @@ abstract class ModuleCore SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name` = \''.pSQL($this->name).'\''); - if ($result) + if (0&&$result) return false; $result = Db::getInstance()->AutoExecute(_DB_PREFIX_.$this->table, array('name' => $this->name, 'active' => 1), 'INSERT'); @@ -658,7 +658,7 @@ abstract class ModuleCore else $errors[] = sprintf(Tools::displayError('%1$s (parse error in %2$s)'), $module, substr($filepath, strlen(_PS_ROOT_DIR_))); } - + if (class_exists($module,false)) { $moduleList[$moduleListCursor++] = new $module; diff --git a/classes/db/Db.php b/classes/db/Db.php index 1c12719bf..78e2a865d 100644 --- a/classes/db/Db.php +++ b/classes/db/Db.php @@ -180,7 +180,7 @@ abstract class DbCore public static function getClass() { $class = 'MySQL'; - if (class_exists('mysqli', false)) + if (0&&class_exists('mysqli', false)) $class = 'DbMySQLi'; return $class; } @@ -361,6 +361,11 @@ abstract class DbCore public function executeS($sql, $array = true, $use_cache = 1) { $sql = (string)$sql; + + // This methode must be used only with queries which display results + if (!preg_match('#^\s*(select|show|explain)\s#i', $sql)) + throw new PrestashopDatabaseException('Db->executeS() must be used only with select, show or explain queries'); + $this->result = false; $this->last_query = $sql; if ($use_cache && _PS_CACHE_ENABLED_ && $array && ($result = Cache::getInstance()->get(md5($sql)))) diff --git a/modules/blocktopmenu/blocktopmenu.php b/modules/blocktopmenu/blocktopmenu.php index ace615760..2a73fa2f0 100644 --- a/modules/blocktopmenu/blocktopmenu.php +++ b/modules/blocktopmenu/blocktopmenu.php @@ -17,10 +17,10 @@ class blocktopmenu extends Module public function install() { - if(!parent::install() || - !$this->registerHook('top') || - !Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', 'CAT1,CMS1,CMS2,PRD1') || - !Configuration::updateValue('MOD_BLOCKTOPMENU_SEARCH', '1') || + if(!parent::install() || + !$this->registerHook('top') || + !Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', 'CAT1,CMS1,CMS2,PRD1') || + !Configuration::updateValue('MOD_BLOCKTOPMENU_SEARCH', '1') || !$this->installDB()) return false; return true; @@ -28,13 +28,13 @@ class blocktopmenu extends Module public function installDb() { - Db::getInstance()->executeS(' + Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'linksmenutop` ( `id_link` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , `new_window` TINYINT( 1 ) NOT NULL, `link` VARCHAR( 128 ) NOT NULL ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;'); - Db::getInstance()->executeS(' + Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'linksmenutop_lang` ( `id_link` INT NOT NULL , `id_lang` INT NOT NULL , @@ -46,9 +46,9 @@ class blocktopmenu extends Module public function uninstall() { - if(!parent::uninstall() || - !Configuration::deleteByName('MOD_BLOCKTOPMENU_ITEMS') || - !Configuration::deleteByName('MOD_BLOCKTOPMENU_SEARCH') || + if(!parent::uninstall() || + !Configuration::deleteByName('MOD_BLOCKTOPMENU_ITEMS') || + !Configuration::deleteByName('MOD_BLOCKTOPMENU_SEARCH') || !$this->uninstallDB()) return false; return true; @@ -56,8 +56,8 @@ class blocktopmenu extends Module private function uninstallDb() { - Db::getInstance()->executeS('DROP TABLE `'._DB_PREFIX_.'linksmenutop`'); - Db::getInstance()->executeS('DROP TABLE `'._DB_PREFIX_.'linksmenutop_lang`'); + Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'linksmenutop`'); + Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'linksmenutop_lang`'); return true; } @@ -156,7 +156,7 @@ class blocktopmenu extends Module // END Menu Top Links $this->_html .= '

- << '.$this->l('Add').' + << '.$this->l('Add').' @@ -247,7 +247,7 @@ class blocktopmenu extends Module


'; - + $this->_html .= '
'.$this->l('List Menu Top Link').'