From 5f32555837a24fec07fbbb3f3a5baf90cab94573 Mon Sep 17 00:00:00 2001 From: mMarinetti Date: Tue, 14 Feb 2012 17:21:47 +0000 Subject: [PATCH] // fix upgrade fail when blockcms was not installed --- install-dev/upgrade/php/upgrade_cms_15.php | 19 +++++++++++++++++++ install-dev/upgrade/sql/1.5.0.0.sql | 10 +--------- install-dev/upgrade/upgrade.php | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 install-dev/upgrade/php/upgrade_cms_15.php diff --git a/install-dev/upgrade/php/upgrade_cms_15.php b/install-dev/upgrade/php/upgrade_cms_15.php new file mode 100644 index 000000000..49efd29ee --- /dev/null +++ b/install-dev/upgrade/php/upgrade_cms_15.php @@ -0,0 +1,19 @@ +getValue('SELECT id_module from `'._DB_PREFIX_.'_module where name="blockcms"`'); + if (!$id_module_cms) + return true; + + $res &= Db::getInstance()->execute('CREATE TABLE `'._DB_PREFIX_.'_cms_shop` ( +`id_cms` INT( 11 ) UNSIGNED NOT NULL, +`id_shop` INT( 11 ) UNSIGNED NOT NULL , + PRIMARY KEY (`id_cms`, `id_shop`), + KEY `id_shop` (`id_shop`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;'); + $res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'_cms_shop` (id_shop, id_cms) (SELECT 1, id_cms FROM '._DB_PREFIX_.'_cms)'); + $res &= Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'._cms_block` ADD `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT "1" AFTER `id_cms_block`'); + + return $res; +} diff --git a/install-dev/upgrade/sql/1.5.0.0.sql b/install-dev/upgrade/sql/1.5.0.0.sql index c855b8ad7..4d09beb72 100755 --- a/install-dev/upgrade/sql/1.5.0.0.sql +++ b/install-dev/upgrade/sql/1.5.0.0.sql @@ -105,15 +105,7 @@ CREATE TABLE `PREFIX_carrier_shop` ( ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; INSERT INTO `PREFIX_carrier_shop` (id_shop, id_carrier) (SELECT 1, id_carrier FROM PREFIX_carrier); -CREATE TABLE `PREFIX_cms_shop` ( -`id_cms` INT( 11 ) UNSIGNED NOT NULL, -`id_shop` INT( 11 ) UNSIGNED NOT NULL , - PRIMARY KEY (`id_cms`, `id_shop`), - KEY `id_shop` (`id_shop`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; -INSERT INTO `PREFIX_cms_shop` (id_shop, id_cms) (SELECT 1, id_cms FROM PREFIX_cms); - -ALTER TABLE `PREFIX_cms_block` ADD `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_cms_block`; +/* PHP:upgrade_cms_15(); */; CREATE TABLE `PREFIX_lang_shop` ( `id_lang` INT( 11 ) UNSIGNED NOT NULL, diff --git a/install-dev/upgrade/upgrade.php b/install-dev/upgrade/upgrade.php index 0ac720417..47098cb5a 100644 --- a/install-dev/upgrade/upgrade.php +++ b/install-dev/upgrade/upgrade.php @@ -65,7 +65,7 @@ else // need for upgrade before 1.5 if (!defined('__PS_BASE_URI__')) - define('__PS_BASE_URI__', str_replace('//', '/', '/'.trim(preg_replace('#/(install(-dev|-new)?)$#', '/', str_replace('\\', '/', dirname($_SERVER['REQUEST_URI']))), '/').'/')); + define('__PS_BASE_URI__', str_replace('//', '/', '/'.trim(preg_replace('#/(install(-dev)?)$#', '/', str_replace('\\', '/', dirname($_SERVER['REQUEST_URI']))), '/').'/')); // need for upgrade before 1.5 if (!defined('_THEME_NAME_'))