From cd3dce4a826f9f8d7148f5a0dc230b4fdfcf98c2 Mon Sep 17 00:00:00 2001 From: mMarinetti Date: Mon, 11 Jun 2012 15:29:43 +0000 Subject: [PATCH] // fix upgrade script missing tab images (and all img located in /install/data/img/ immediates subdir) #PSCFV-2749, #PSCFV-2506 git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15973 b9a71923-0436-4b27-9f14-aed3839534dd --- install-dev/install_version.php | 2 +- ...copy_missing_images_tab_from_installer.php | 59 +++++++++++++++++++ install-dev/upgrade/sql/1.5.0.14.sql | 3 + 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 install-dev/upgrade/php/p15014_copy_missing_images_tab_from_installer.php create mode 100644 install-dev/upgrade/sql/1.5.0.14.sql diff --git a/install-dev/install_version.php b/install-dev/install_version.php index a2b3cef4e..68fe7b0f4 100644 --- a/install-dev/install_version.php +++ b/install-dev/install_version.php @@ -25,4 +25,4 @@ * International Registered Trademark & Property of PrestaShop SA */ -define('_PS_INSTALL_VERSION_', '1.5.0.13'); +define('_PS_INSTALL_VERSION_', '1.5.0.14'); diff --git a/install-dev/upgrade/php/p15014_copy_missing_images_tab_from_installer.php b/install-dev/upgrade/php/p15014_copy_missing_images_tab_from_installer.php new file mode 100644 index 000000000..4841b1828 --- /dev/null +++ b/install-dev/upgrade/php/p15014_copy_missing_images_tab_from_installer.php @@ -0,0 +1,59 @@ + +* @copyright 2007-2012 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +/** + * This function copy all images located in /install/data/img/* that are missing in previous upgrade + * in the matching img dir. This does not modify images that are already present. + * + */ +function p15014_copy_missing_images_tab_from_installer() +{ + $res = true; + $DIR_SEP = DIRECTORY_SEPARATOR; + if (!defined('_PS_ROOT_DIR_')) + define('_PS_ROOT_DIR_', realpath(INSTALL_PATH.'/../')); + + $install_dir_path = INSTALL_PATH.$DIR_SEP.'data'.$DIR_SEP.'img'; + $img_dir = scandir($install_dir_path); + foreach($img_dir as $dir) + { + if ($dir[0] == '.') + continue; + + $img_subdir = scandir($install_dir_path.$DIR_SEP.$dir); + foreach($img_subdir as $img) + { + if ($img[0] == '.') + continue; + if (!file_exists(_PS_ROOT_DIR_.$DIR_SEP.'img'.$DIR_SEP.$dir.$DIR_SEP.$img)) + $res &= copy($install_dir_path.$DIR_SEP.$dir.$DIR_SEP.$img, _PS_ROOT_DIR_.$DIR_SEP.'img'.$DIR_SEP.$dir.$DIR_SEP.$img); + } + } + + return $res; +} + diff --git a/install-dev/upgrade/sql/1.5.0.14.sql b/install-dev/upgrade/sql/1.5.0.14.sql new file mode 100644 index 000000000..45da752ac --- /dev/null +++ b/install-dev/upgrade/sql/1.5.0.14.sql @@ -0,0 +1,3 @@ +SET NAMES 'utf8'; + +/* PHP:p15014_copy_missing_images_tab_from_installer(); */;