From 78cdb3c6b100bf9662fc0b5cb92fb2f9509995df Mon Sep 17 00:00:00 2001 From: mMarinetti Date: Tue, 24 Jan 2012 09:26:46 +0000 Subject: [PATCH] // upgrade fix relative to php scripts from 1.1.0.5 + generate_root_category_for_multishop --- install-new/upgrade/php/add_new_tab.php | 10 ++----- .../upgrade/php/convert_product_price.php | 8 +++-- .../generate_root_category_for_multishop.php | 10 ++++--- .../php/migrate_block_info_to_cms_block.php | 6 ++-- .../upgrade/php/set_payment_module_group.php | 2 +- .../upgrade/php/update_carrier_url.php | 4 +-- .../upgrade/php/update_for_13version.php | 2 +- .../upgrade/php/update_module_followup.php | 4 +-- .../upgrade/php/update_module_loyalty.php | 2 +- .../upgrade/php/update_order_canada.php | 4 +-- .../upgrade/php/update_order_details.php | 6 ++-- .../php/update_products_ecotax_v133.php | 4 +-- .../upgrade/php/updateproductcomments.php | 30 +++++++++---------- .../php/updatetabicon_from_11version.php | 12 ++++---- 14 files changed, 51 insertions(+), 53 deletions(-) diff --git a/install-new/upgrade/php/add_new_tab.php b/install-new/upgrade/php/add_new_tab.php index 25b3e666f..4fe2153db 100644 --- a/install-new/upgrade/php/add_new_tab.php +++ b/install-new/upgrade/php/add_new_tab.php @@ -25,7 +25,7 @@ * International Registered Trademark & Property of PrestaShop SA */ -function add_new_tab($className, $name, $id_parent, $returnId = false) +function add_new_tab($className, $name, $id_parent) { $array = array(); foreach (explode('|', $name) AS $item) @@ -57,10 +57,4 @@ function add_new_tab($className, $name, $id_parent, $returnId = false) FROM `'._DB_PREFIX_.'tab` WHERE `class_name` = \''.pSQL($className).'\' LIMIT 0,1 ), 1, 1, 1, 1 FROM `'._DB_PREFIX_.'profile` )'); - - if($returnId) { - return (int)Db::getInstance()->getValue('SELECT `id_tab` - FROM `'._DB_PREFIX_.'tab` - WHERE `class_name` = \''.pSQL($className).'\''); - } -} +} \ No newline at end of file diff --git a/install-new/upgrade/php/convert_product_price.php b/install-new/upgrade/php/convert_product_price.php index 183a9ded5..fba4b8918 100644 --- a/install-new/upgrade/php/convert_product_price.php +++ b/install-new/upgrade/php/convert_product_price.php @@ -32,9 +32,11 @@ function convert_product_price() $taxRates = array(); foreach ($taxes as $data) $taxRates[$data['id_tax']] = (float)($data['rate']) / 100; - $resource = DB::getInstance()->ExecuteS('SELECT `id_product`, `price`, `id_tax` FROM `'._DB_PREFIX_.'product`', false); + $resource = DB::getInstance()->executeS('SELECT `id_product`, `price`, `id_tax` + FROM `'._DB_PREFIX_.'product`', false); if (!$resource) - die(mysql_error()); + return array('error' => 1, 'msg' => Db::getInstance()->getMsgError()); // was previously die(mysql_error()) + while ($row = DB::getInstance()->nextRow($resource)) if ($row['id_tax']) { @@ -44,7 +46,7 @@ function convert_product_price() { $newPrice = (float)(number_format($price, 6, '.', '')); $newPrice = Tools::floorf($newPrice / (1 + $taxRates[$row['id_tax']]), 6); - DB::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'product` SET `price` = '.$newPrice.' WHERE `id_product` = '.(int)$row['id_product']); + DB::getInstance()->execute('UPDATE `'._DB_PREFIX_.'product` SET `price` = '.$newPrice.' WHERE `id_product` = '.(int)$row['id_product']); } } } diff --git a/install-new/upgrade/php/generate_root_category_for_multishop.php b/install-new/upgrade/php/generate_root_category_for_multishop.php index bec22ab7d..3fd98b2c5 100644 --- a/install-new/upgrade/php/generate_root_category_for_multishop.php +++ b/install-new/upgrade/php/generate_root_category_for_multishop.php @@ -1,5 +1,7 @@ execute(' @@ -10,7 +12,7 @@ function generate_root_category_for_multishop() INSERT INTO `'._DB_PREFIX_.'category` (`id_parent`, `level_depth`, `active`, `date_add`, `date_upd`, `is_root_category`) VALUES (0, 0, 1, NOW(), NOW(), 0) '); - $id = Db::getInstance()->Insert_ID(); + $id = Db::getInstance()->insert_id(); $langs = Db::getInstance()->executeS(' SELECT `id_lang` @@ -57,6 +59,6 @@ function generate_root_category_for_multishop() SET `id_category` = 1 WHERE `id_shop` = 1 '); - - Category::regenerateEntireNtree(); -} \ No newline at end of file + + generate_ntree(); +} diff --git a/install-new/upgrade/php/migrate_block_info_to_cms_block.php b/install-new/upgrade/php/migrate_block_info_to_cms_block.php index eae462321..5c629eb87 100644 --- a/install-new/upgrade/php/migrate_block_info_to_cms_block.php +++ b/install-new/upgrade/php/migrate_block_info_to_cms_block.php @@ -68,7 +68,7 @@ function migrate_block_info_to_cms_block() `position` int(10) unsigned NOT NULL default \'0\', `display_store` tinyint(1) unsigned NOT NULL default \'1\', PRIMARY KEY (`id_cms_block`) - ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'); + ) ENGINE=MyISAM DEFAULT CHARSET=utf8'); $res &= Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'cms_block` (`id_cms_category`, `location`, `position`) VALUES(1, 0, 0)'); $res &= Db::getInstance()->Execute(' @@ -77,7 +77,7 @@ function migrate_block_info_to_cms_block() `id_lang` int(10) unsigned NOT NULL, `name` varchar(40) NOT NULL default \'\', PRIMARY KEY (`id_cms_block`, `id_lang`) - ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'); + ) ENGINE=MyISAM DEFAULT CHARSET=utf8'); $query_lang = 'INSERT INTO `'._DB_PREFIX_.'cms_block_lang` (`id_cms_block`, `id_lang`) VALUES'; foreach ($languages AS $language) @@ -92,7 +92,7 @@ function migrate_block_info_to_cms_block() `id_cms` int(10) unsigned NOT NULL, `is_category` tinyint(1) unsigned NOT NULL, PRIMARY KEY (`id_cms_block_page`) - ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'); + ) ENGINE=MyISAM DEFAULT CHARSET=utf8'); $res &= Db::getInstance()->getValue('REPLACE INTO `'._DB_PREFIX_.'configuration` (name, value) VALUES ("FOOTER_CMS", "")'); diff --git a/install-new/upgrade/php/set_payment_module_group.php b/install-new/upgrade/php/set_payment_module_group.php index 84b6bcb3d..2f49ebd79 100644 --- a/install-new/upgrade/php/set_payment_module_group.php +++ b/install-new/upgrade/php/set_payment_module_group.php @@ -28,7 +28,7 @@ function set_payment_module_group() { // Get all modules then select only payment ones - $modules = Module::getModulesInstalled(); + $modules = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'module`'); foreach ($modules AS $module) { $file = _PS_MODULE_DIR_.$module['name'].'/'.$module['name'].'.php'; diff --git a/install-new/upgrade/php/update_carrier_url.php b/install-new/upgrade/php/update_carrier_url.php index 257f8ebab..3039bff6f 100644 --- a/install-new/upgrade/php/update_carrier_url.php +++ b/install-new/upgrade/php/update_carrier_url.php @@ -35,8 +35,8 @@ function update_carrier_url() // Check each one and erase carrier URL if not correct URL foreach ($carriers as $carrier) - if (!Validate::isAbsoluteUrl($carrier['url'])) - Db::getInstance()->execute(' + if (empty($carrier['url']) || !preg_match('/^https?:\/\/[:#%&_=\(\)\.\? \+\-@\/a-zA-Z0-9]+$/', $carrier['url'])) + Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'carrier` SET `url` = \'\' WHERE `id_carrier`= '.(int)($carrier['id_carrier'])); diff --git a/install-new/upgrade/php/update_for_13version.php b/install-new/upgrade/php/update_for_13version.php index fbcda6400..585e5f718 100644 --- a/install-new/upgrade/php/update_for_13version.php +++ b/install-new/upgrade/php/update_for_13version.php @@ -16,4 +16,4 @@ function update_for_13version() ("PS_REWRITING_SETTINGS", "0") ("PS_CANONICAL_REDIRECT", "0") '); -} \ No newline at end of file +} diff --git a/install-new/upgrade/php/update_module_followup.php b/install-new/upgrade/php/update_module_followup.php index a07c5869d..81dca7f39 100644 --- a/install-new/upgrade/php/update_module_followup.php +++ b/install-new/upgrade/php/update_module_followup.php @@ -20,7 +20,7 @@ * * @author PrestaShop SA * @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 6844 $ +* @version Release: $Revision: 12447 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ @@ -31,6 +31,6 @@ function update_module_followup() if (!$id_followup) return; - Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'log_email` ADD INDEX `date_add`(`date_add`), ADD INDEX `id_cart`(`id_cart`);'); + Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.'log_email` ADD INDEX `date_add`(`date_add`), ADD INDEX `id_cart`(`id_cart`);'); } diff --git a/install-new/upgrade/php/update_module_loyalty.php b/install-new/upgrade/php/update_module_loyalty.php index 2ffe7f6b2..b787fd5cc 100644 --- a/install-new/upgrade/php/update_module_loyalty.php +++ b/install-new/upgrade/php/update_module_loyalty.php @@ -20,7 +20,7 @@ * * @author PrestaShop SA * @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 12447 $ +* @version Release: $Revision: 12518 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ diff --git a/install-new/upgrade/php/update_order_canada.php b/install-new/upgrade/php/update_order_canada.php index 63dce0d2e..7d5b66efa 100644 --- a/install-new/upgrade/php/update_order_canada.php +++ b/install-new/upgrade/php/update_order_canada.php @@ -38,7 +38,7 @@ function update_order_canada() `tax_name` varchar(40) NOT NULL, `tax_rate` decimal(6,3) NOT NULL, `amount` decimal(20,6) NOT NULL - ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8'); + ) ENGINE=MyISAM DEFAULT CHARSET=utf8'); $address_field = Db::getInstance()->getValue('SELECT value @@ -66,7 +66,7 @@ function update_order_canada() // returns Group::getDefaultPriceDisplayMethod $tax_calculation_method = $order['price_display_method']; - $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' + $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = '.(int)$id_order); diff --git a/install-new/upgrade/php/update_order_details.php b/install-new/upgrade/php/update_order_details.php index 4ffecef37..83a2211ee 100644 --- a/install-new/upgrade/php/update_order_details.php +++ b/install-new/upgrade/php/update_order_details.php @@ -27,12 +27,12 @@ function update_order_details() { - $res = Db::getInstance()->executeS('SHOW COLUMNS FROM `'._DB_PREFIX_.'order_detail` LIKE \'reduction_percent\''); + $res = Db::getInstance()->ExecuteS('SHOW COLUMNS FROM `'._DB_PREFIX_.'order_detail` LIKE \'reduction_percent\''); if (sizeof($res) == 0) { - Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'order_detail` ADD `reduction_percent` DECIMAL(10, 2) NOT NULL default "0.00" AFTER `product_price`'); - Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'order_detail` ADD `reduction_amount` DECIMAL(20, 6) NOT NULL default "0.000000" AFTER `reduction_percent`'); + Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.'order_detail` ADD `reduction_percent` DECIMAL(10, 2) NOT NULL default \'0.00\' AFTER `product_price`'); + Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.'order_detail` ADD `reduction_amount` DECIMAL(20, 6) NOT NULL default \'0.000000\' AFTER `reduction_percent`'); } } diff --git a/install-new/upgrade/php/update_products_ecotax_v133.php b/install-new/upgrade/php/update_products_ecotax_v133.php index c6e83f85f..857a667b2 100644 --- a/install-new/upgrade/php/update_products_ecotax_v133.php +++ b/install-new/upgrade/php/update_products_ecotax_v133.php @@ -20,7 +20,7 @@ * * @author PrestaShop SA * @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 6844 $ +* @version Release: $Revision: 7541 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ @@ -33,4 +33,4 @@ function update_products_ecotax_v133() Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'product` SET `ecotax` = \'0\' WHERE 1'); Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'order_detail` SET `ecotax` = \'0\' WHERE 1;'); } -} \ No newline at end of file +} diff --git a/install-new/upgrade/php/updateproductcomments.php b/install-new/upgrade/php/updateproductcomments.php index a3f649ca4..8ff1e072b 100644 --- a/install-new/upgrade/php/updateproductcomments.php +++ b/install-new/upgrade/php/updateproductcomments.php @@ -20,38 +20,38 @@ * * @author PrestaShop SA * @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 6844 $ +* @version Release: $Revision: 6594 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ function updateproductcomments() { - if (Db::getInstance()->executeS('SELECT * FROM '._DB_PREFIX_.'product_comment') !== false) + if (Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'product_comment') !== false) { - Db::getInstance()->execute('CREATE TABLE IF NOT EXISTS '._DB_PREFIX_.'product_comment_criterion_lang ( + Db::getInstance()->Execute('CREATE TABLE IF NOT EXISTS '._DB_PREFIX_.'product_comment_criterion_lang ( `id_product_comment_criterion` INT( 11 ) UNSIGNED NOT NULL , `id_lang` INT(11) UNSIGNED NOT NULL , `name` VARCHAR(64) NOT NULL , PRIMARY KEY ( `id_product_comment_criterion` , `id_lang` ) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'); - Db::getInstance()->execute('CREATE TABLE IF NOT EXISTS '._DB_PREFIX_.'product_comment_criterion_category ( + Db::getInstance()->Execute('CREATE TABLE IF NOT EXISTS '._DB_PREFIX_.'product_comment_criterion_category ( `id_product_comment_criterion` int(10) unsigned NOT NULL, `id_category` int(10) unsigned NOT NULL, PRIMARY KEY(`id_product_comment_criterion`, `id_category`), KEY `id_category` (`id_category`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'); - Db::getInstance()->execute('ALTER TABLE '._DB_PREFIX_.'product_comment ADD `id_guest` INT(11) NULL AFTER `id_customer`'); - Db::getInstance()->execute('ALTER TABLE '._DB_PREFIX_.'product_comment ADD `customer_name` varchar(64) NULL AFTER `content`'); - Db::getInstance()->execute('ALTER TABLE '._DB_PREFIX_.'product_comment ADD `deleted` tinyint(1) NOT NULL AFTER `validate`'); - Db::getInstance()->execute('ALTER TABLE '._DB_PREFIX_.'product_comment ADD INDEX (id_customer)'); - Db::getInstance()->execute('ALTER TABLE '._DB_PREFIX_.'product_comment ADD INDEX (id_guest)'); - Db::getInstance()->execute('ALTER TABLE '._DB_PREFIX_.'product_comment ADD INDEX (id_product)'); - Db::getInstance()->execute('ALTER TABLE '._DB_PREFIX_.'product_comment_criterion DROP `id_lang`'); - Db::getInstance()->execute('ALTER TABLE '._DB_PREFIX_.'product_comment_criterion DROP `name`'); - Db::getInstance()->execute('ALTER TABLE '._DB_PREFIX_.'product_comment_criterion ADD `id_product_comment_criterion_type` tinyint(1) NOT NULL AFTER `id_product_comment_criterion`'); - Db::getInstance()->execute('ALTER TABLE '._DB_PREFIX_.'product_comment_criterion ADD `active` tinyint(1) NOT NULL AFTER `id_product_comment_criterion_type`'); - Db::getInstance()->execute('ALTER IGNORE TABLE `'._DB_PREFIX_.'product_comment` ADD `title` VARCHAR(64) NULL AFTER `id_guest`;'); + Db::getInstance()->Execute('ALTER TABLE '._DB_PREFIX_.'product_comment ADD `id_guest` INT(11) NULL AFTER `id_customer`'); + Db::getInstance()->Execute('ALTER TABLE '._DB_PREFIX_.'product_comment ADD `customer_name` varchar(64) NULL AFTER `content`'); + Db::getInstance()->Execute('ALTER TABLE '._DB_PREFIX_.'product_comment ADD `deleted` tinyint(1) NOT NULL AFTER `validate`'); + Db::getInstance()->Execute('ALTER TABLE '._DB_PREFIX_.'product_comment ADD INDEX (id_customer)'); + Db::getInstance()->Execute('ALTER TABLE '._DB_PREFIX_.'product_comment ADD INDEX (id_guest)'); + Db::getInstance()->Execute('ALTER TABLE '._DB_PREFIX_.'product_comment ADD INDEX (id_product)'); + Db::getInstance()->Execute('ALTER TABLE '._DB_PREFIX_.'product_comment_criterion DROP `id_lang`'); + Db::getInstance()->Execute('ALTER TABLE '._DB_PREFIX_.'product_comment_criterion DROP `name`'); + Db::getInstance()->Execute('ALTER TABLE '._DB_PREFIX_.'product_comment_criterion ADD `id_product_comment_criterion_type` tinyint(1) NOT NULL AFTER `id_product_comment_criterion`'); + Db::getInstance()->Execute('ALTER TABLE '._DB_PREFIX_.'product_comment_criterion ADD `active` tinyint(1) NOT NULL AFTER `id_product_comment_criterion_type`'); + Db::getInstance()->Execute('ALTER IGNORE TABLE `'._DB_PREFIX_.'product_comment` ADD `title` VARCHAR(64) NULL AFTER `id_guest`;'); } } diff --git a/install-new/upgrade/php/updatetabicon_from_11version.php b/install-new/upgrade/php/updatetabicon_from_11version.php index 1ff7b18f9..2b52cc325 100644 --- a/install-new/upgrade/php/updatetabicon_from_11version.php +++ b/install-new/upgrade/php/updatetabicon_from_11version.php @@ -20,7 +20,7 @@ * * @author PrestaShop SA * @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 6844 $ +* @version Release: $Revision: 6594 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ @@ -30,16 +30,16 @@ function updatetabicon_from_11version() if (version_compare($oldversion,'1.5.0.0','<')) { - $rows = Db::getInstance()->executeS('SELECT `id_tab`,`class_name` FROM '._DB_PREFIX_.'tab'); + $rows = Db::getInstance()->ExecuteS('SELECT `id_tab`,`class_name` FROM '._DB_PREFIX_.'tab'); if (sizeof($rows)) { - $img_dir = scandir(_PS_IMG_DIR_.'/t/'); + $img_dir = scandir(_PS_ROOT_DIR_.'/img/t/'); $result = true; foreach ($rows as $tab) { - if (file_exists(_PS_IMG_DIR_.'/t/'.$tab['id_tab'].'.gif') - AND !file_exists(_PS_IMG_DIR_.'/t/'.$tab['class_name'].'.gif')) - $result &= rename(_PS_IMG_DIR_.'/t/'.$tab['id_tab'].'.gif',_PS_IMG_DIR_.'/t/'.$tab['class_name'].'.gif'); + if (file_exists(_PS_ROOT_DIR_.'/img/t/'.$tab['id_tab'].'.gif') + AND !file_exists(_PS_ROOT_DIR_.'/img/t/'.$tab['class_name'].'.gif')) + $result &= rename(_PS_ROOT_DIR_.'/img/t/'.$tab['id_tab'].'.gif',_PS_ROOT_DIR_.'/img/t/'.$tab['class_name'].'.gif'); } } }