// upgrade fix relative to php scripts from 1.1.0.5 + generate_root_category_for_multishop

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12635 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
mMarinetti
2012-01-24 09:26:46 +00:00
parent b2125f0302
commit df3a5ce460
14 changed files with 51 additions and 53 deletions
+1 -7
View File
@@ -25,7 +25,7 @@
* International Registered Trademark & Property of PrestaShop SA * 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(); $array = array();
foreach (explode('|', $name) AS $item) foreach (explode('|', $name) AS $item)
@@ -57,10 +57,4 @@ function add_new_tab($className, $name, $id_parent, $returnId = false)
FROM `'._DB_PREFIX_.'tab` FROM `'._DB_PREFIX_.'tab`
WHERE `class_name` = \''.pSQL($className).'\' LIMIT 0,1 WHERE `class_name` = \''.pSQL($className).'\' LIMIT 0,1
), 1, 1, 1, 1 FROM `'._DB_PREFIX_.'profile` )'); ), 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).'\'');
}
} }
@@ -32,9 +32,11 @@ function convert_product_price()
$taxRates = array(); $taxRates = array();
foreach ($taxes as $data) foreach ($taxes as $data)
$taxRates[$data['id_tax']] = (float)($data['rate']) / 100; $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) if (!$resource)
die(mysql_error()); return array('error' => 1, 'msg' => Db::getInstance()->getMsgError()); // was previously die(mysql_error())
while ($row = DB::getInstance()->nextRow($resource)) while ($row = DB::getInstance()->nextRow($resource))
if ($row['id_tax']) if ($row['id_tax'])
{ {
@@ -44,7 +46,7 @@ function convert_product_price()
{ {
$newPrice = (float)(number_format($price, 6, '.', '')); $newPrice = (float)(number_format($price, 6, '.', ''));
$newPrice = Tools::floorf($newPrice / (1 + $taxRates[$row['id_tax']]), 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']);
} }
} }
} }
@@ -1,5 +1,7 @@
<?php <?php
require_once('./generate_ntree.php');
function generate_root_category_for_multishop() function generate_root_category_for_multishop()
{ {
Db::getInstance()->execute(' Db::getInstance()->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 INSERT INTO `'._DB_PREFIX_.'category` (`id_parent`, `level_depth`, `active`, `date_add`, `date_upd`, `is_root_category`) VALUES
(0, 0, 1, NOW(), NOW(), 0) (0, 0, 1, NOW(), NOW(), 0)
'); ');
$id = Db::getInstance()->Insert_ID(); $id = Db::getInstance()->insert_id();
$langs = Db::getInstance()->executeS(' $langs = Db::getInstance()->executeS('
SELECT `id_lang` SELECT `id_lang`
@@ -58,5 +60,5 @@ function generate_root_category_for_multishop()
WHERE `id_shop` = 1 WHERE `id_shop` = 1
'); ');
Category::regenerateEntireNtree(); generate_ntree();
} }
@@ -68,7 +68,7 @@ function migrate_block_info_to_cms_block()
`position` int(10) unsigned NOT NULL default \'0\', `position` int(10) unsigned NOT NULL default \'0\',
`display_store` tinyint(1) unsigned NOT NULL default \'1\', `display_store` tinyint(1) unsigned NOT NULL default \'1\',
PRIMARY KEY (`id_cms_block`) PRIMARY KEY (`id_cms_block`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'); ) ENGINE=MyISAM DEFAULT CHARSET=utf8');
$res &= Db::getInstance()->Execute(' $res &= Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'cms_block` (`id_cms_category`, `location`, `position`) VALUES(1, 0, 0)'); INSERT INTO `'._DB_PREFIX_.'cms_block` (`id_cms_category`, `location`, `position`) VALUES(1, 0, 0)');
$res &= Db::getInstance()->Execute(' $res &= Db::getInstance()->Execute('
@@ -77,7 +77,7 @@ function migrate_block_info_to_cms_block()
`id_lang` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL,
`name` varchar(40) NOT NULL default \'\', `name` varchar(40) NOT NULL default \'\',
PRIMARY KEY (`id_cms_block`, `id_lang`) 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'; $query_lang = 'INSERT INTO `'._DB_PREFIX_.'cms_block_lang` (`id_cms_block`, `id_lang`) VALUES';
foreach ($languages AS $language) foreach ($languages AS $language)
@@ -92,7 +92,7 @@ function migrate_block_info_to_cms_block()
`id_cms` int(10) unsigned NOT NULL, `id_cms` int(10) unsigned NOT NULL,
`is_category` tinyint(1) unsigned NOT NULL, `is_category` tinyint(1) unsigned NOT NULL,
PRIMARY KEY (`id_cms_block_page`) 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` $res &= Db::getInstance()->getValue('REPLACE INTO `'._DB_PREFIX_.'configuration`
(name, value) VALUES ("FOOTER_CMS", "")'); (name, value) VALUES ("FOOTER_CMS", "")');
@@ -28,7 +28,7 @@
function set_payment_module_group() function set_payment_module_group()
{ {
// Get all modules then select only payment ones // Get all modules then select only payment ones
$modules = Module::getModulesInstalled(); $modules = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'module`');
foreach ($modules AS $module) foreach ($modules AS $module)
{ {
$file = _PS_MODULE_DIR_.$module['name'].'/'.$module['name'].'.php'; $file = _PS_MODULE_DIR_.$module['name'].'/'.$module['name'].'.php';
@@ -35,8 +35,8 @@ function update_carrier_url()
// Check each one and erase carrier URL if not correct URL // Check each one and erase carrier URL if not correct URL
foreach ($carriers as $carrier) foreach ($carriers as $carrier)
if (!Validate::isAbsoluteUrl($carrier['url'])) if (empty($carrier['url']) || !preg_match('/^https?:\/\/[:#%&_=\(\)\.\? \+\-@\/a-zA-Z0-9]+$/', $carrier['url']))
Db::getInstance()->execute(' Db::getInstance()->Execute('
UPDATE `'._DB_PREFIX_.'carrier` UPDATE `'._DB_PREFIX_.'carrier`
SET `url` = \'\' SET `url` = \'\'
WHERE `id_carrier`= '.(int)($carrier['id_carrier'])); WHERE `id_carrier`= '.(int)($carrier['id_carrier']));
@@ -20,7 +20,7 @@
* *
* @author PrestaShop SA <contact@prestashop.com> * @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 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) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*/ */
@@ -31,6 +31,6 @@ function update_module_followup()
if (!$id_followup) if (!$id_followup)
return; 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`);');
} }
@@ -20,7 +20,7 @@
* *
* @author PrestaShop SA <contact@prestashop.com> * @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 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) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*/ */
@@ -38,7 +38,7 @@ function update_order_canada()
`tax_name` varchar(40) NOT NULL, `tax_name` varchar(40) NOT NULL,
`tax_rate` decimal(6,3) NOT NULL, `tax_rate` decimal(6,3) NOT NULL,
`amount` decimal(20,6) 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 $address_field = Db::getInstance()->getValue('SELECT value
@@ -66,7 +66,7 @@ function update_order_canada()
// returns Group::getDefaultPriceDisplayMethod // returns Group::getDefaultPriceDisplayMethod
$tax_calculation_method = $order['price_display_method']; $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 SELECT * FROM `'._DB_PREFIX_.'order_detail` od
WHERE od.`id_order` = '.(int)$id_order); WHERE od.`id_order` = '.(int)$id_order);
@@ -27,12 +27,12 @@
function update_order_details() 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) 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_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_amount` DECIMAL(20, 6) NOT NULL default \'0.000000\' AFTER `reduction_percent`');
} }
} }
@@ -20,7 +20,7 @@
* *
* @author PrestaShop SA <contact@prestashop.com> * @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 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) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*/ */
@@ -20,38 +20,38 @@
* *
* @author PrestaShop SA <contact@prestashop.com> * @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 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) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*/ */
function updateproductcomments() 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_product_comment_criterion` INT( 11 ) UNSIGNED NOT NULL ,
`id_lang` INT(11) UNSIGNED NOT NULL , `id_lang` INT(11) UNSIGNED NOT NULL ,
`name` VARCHAR(64) NOT NULL , `name` VARCHAR(64) NOT NULL ,
PRIMARY KEY ( `id_product_comment_criterion` , `id_lang` ) PRIMARY KEY ( `id_product_comment_criterion` , `id_lang` )
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'); ) 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_product_comment_criterion` int(10) unsigned NOT NULL,
`id_category` int(10) unsigned NOT NULL, `id_category` int(10) unsigned NOT NULL,
PRIMARY KEY(`id_product_comment_criterion`, `id_category`), PRIMARY KEY(`id_product_comment_criterion`, `id_category`),
KEY `id_category` (`id_category`) KEY `id_category` (`id_category`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'); ) 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 `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 `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 `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_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_guest)');
Db::getInstance()->execute('ALTER TABLE '._DB_PREFIX_.'product_comment ADD INDEX (id_product)'); 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 `id_lang`');
Db::getInstance()->execute('ALTER TABLE '._DB_PREFIX_.'product_comment_criterion DROP `name`'); 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 `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 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 IGNORE TABLE `'._DB_PREFIX_.'product_comment` ADD `title` VARCHAR(64) NULL AFTER `id_guest`;');
} }
} }
@@ -20,7 +20,7 @@
* *
* @author PrestaShop SA <contact@prestashop.com> * @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 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) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*/ */
@@ -30,16 +30,16 @@ function updatetabicon_from_11version()
if (version_compare($oldversion,'1.5.0.0','<')) 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)) if (sizeof($rows))
{ {
$img_dir = scandir(_PS_IMG_DIR_.'/t/'); $img_dir = scandir(_PS_ROOT_DIR_.'/img/t/');
$result = true; $result = true;
foreach ($rows as $tab) foreach ($rows as $tab)
{ {
if (file_exists(_PS_IMG_DIR_.'/t/'.$tab['id_tab'].'.gif') if (file_exists(_PS_ROOT_DIR_.'/img/t/'.$tab['id_tab'].'.gif')
AND !file_exists(_PS_IMG_DIR_.'/t/'.$tab['class_name'].'.gif')) AND !file_exists(_PS_ROOT_DIR_.'/img/t/'.$tab['class_name'].'.gif'))
$result &= rename(_PS_IMG_DIR_.'/t/'.$tab['id_tab'].'.gif',_PS_IMG_DIR_.'/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');
} }
} }
} }