From 536bdb550b14d8254fb8e721e6fe583dc11ea9f0 Mon Sep 17 00:00:00 2001 From: sjousse Date: Mon, 26 Aug 2013 18:23:39 +0200 Subject: [PATCH 01/19] fix file validation to use PHP native method --- modules/shopimporter/shopimporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/shopimporter/shopimporter.php b/modules/shopimporter/shopimporter.php index 00f07a70a..1383d09da 100644 --- a/modules/shopimporter/shopimporter.php +++ b/modules/shopimporter/shopimporter.php @@ -434,7 +434,7 @@ class shopimporter extends ImportModule if ((sizeof($rules['requiredLang']) || sizeof($rules['sizeLang']) || sizeof($rules['validateLang']) || Tools::isSubmit('syncLang') || Tools::isSubmit('syncCurrency'))) { $moduleName = Tools::getValue('moduleName'); - if (Validate::isModuleName($moduleName) && Validate::file_exists('../../modules/'.$moduleName.'/'.$moduleName.'.php')) + if (Validate::isModuleName($moduleName) && file_exists('../../modules/'.$moduleName.'/'.$moduleName.'.php')) { require_once('../../modules/'.$moduleName.'/'.$moduleName.'.php'); $importModule = new $moduleName(); From ffd712312da0fdad349bcf157763f215e0515538 Mon Sep 17 00:00:00 2001 From: ha99y Date: Wed, 28 Aug 2013 00:27:52 -0700 Subject: [PATCH 02/19] Add new argument to function getImages 1st: The function will return the product attribute id's with the list. 2nd: If product attribute id is passed to the function it will return only the image id of the given attribute. --- classes/Image.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/Image.php b/classes/Image.php index f2b749bf1..5050f98c9 100644 --- a/classes/Image.php +++ b/classes/Image.php @@ -120,15 +120,19 @@ class ImageCore extends ObjectModel * * @param integer $id_lang Language ID * @param integer $id_product Product ID + * @param integer $id_product_attribute Product Attribute ID * @return array Images */ - public static function getImages($id_lang, $id_product) + public static function getImages($id_lang, $id_product, $id_product_attribute = NULL) { + $attribute_filter = ($id_product_attribute ? ' AND ai.`id_product_attribute` = '.(int)$id_product_attribute : ''); + return Db::getInstance()->executeS(' SELECT * FROM `'._DB_PREFIX_.'image` i LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image`) - WHERE i.`id_product` = '.(int)$id_product.' AND il.`id_lang` = '.(int)$id_lang.' + LEFT JOIN `'._DB_PREFIX_.'product_attribute_image` ai ON (i.`id_image` = ai.`id_image`) + WHERE i.`id_product` = '.(int)$id_product.' AND il.`id_lang` = '.(int)$id_lang . $attribute_filter.' ORDER BY i.`position` ASC'); } From 4c633b8b4605324a27c59cfd8a7bb21a468ec0b5 Mon Sep 17 00:00:00 2001 From: PrestaEdit Date: Sun, 1 Sep 2013 16:55:22 +0200 Subject: [PATCH 03/19] [*] BO: sort modules name in Stats --- controllers/admin/AdminStatsTabController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/controllers/admin/AdminStatsTabController.php b/controllers/admin/AdminStatsTabController.php index 8f6895ba7..a143841a4 100644 --- a/controllers/admin/AdminStatsTabController.php +++ b/controllers/admin/AdminStatsTabController.php @@ -131,8 +131,13 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor $modules = $this->getModules(); $module_instance = array(); - foreach ($modules as $module) + foreach ($modules as $m => $module) + { $module_instance[$module['name']] = Module::getInstanceByName($module['name']); + $modules[$m]['displayName'] = $module_instance[$module['name']]->displayName; + } + + uasort($modules, array($this, 'checkModulesNames')); $tpl->assign(array( 'current' => self::$currentIndex, @@ -143,6 +148,11 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor return $tpl->fetch(); } + + public function checkModulesNames($a, $b) + { + return (bool)($a['displayName'] > $b['displayName']); + } protected function getModules() { From 5f1e08e7e20dbb2542d8ceee40f3f915567500f4 Mon Sep 17 00:00:00 2001 From: dlage Date: Sun, 1 Sep 2013 22:47:41 +0100 Subject: [PATCH 04/19] Fix variable context Avoid attribution to the variable $newProducts inside the if. It caused the code to potentially misbehave throwing errors of: "variable $newProducts not defined". --- modules/blocknewproducts/blocknewproducts.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/blocknewproducts/blocknewproducts.php b/modules/blocknewproducts/blocknewproducts.php index d5ca90eda..ae04a77ee 100644 --- a/modules/blocknewproducts/blocknewproducts.php +++ b/modules/blocknewproducts/blocknewproducts.php @@ -111,7 +111,10 @@ class BlockNewProducts extends Module { if (!$this->isCached('blocknewproducts.tpl', $this->getCacheId())) { - if (!Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY') && !($newProducts = Product::getNewProducts((int)$params['cookie']->id_lang, 0, (int)Configuration::get('NEW_PRODUCTS_NBR')))) + if (!Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY')) + return; + $newProducts = Product::getNewProducts((int) $params['cookie']->id_lang, 0, (int) Configuration::get('NEW_PRODUCTS_NBR')); + if (!$newProducts) return; $this->smarty->assign(array( @@ -151,4 +154,4 @@ class BlockNewProducts extends Module { $this->_clearCache('blocknewproducts.tpl'); } -} \ No newline at end of file +} From 94bdde4630f3750514c5a9a5035381114814690c Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 2 Sep 2013 18:19:21 +0200 Subject: [PATCH 05/19] [-] CORE : Remove PHP Warning: file_put_contents on modules config.xml --- classes/module/Module.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/classes/module/Module.php b/classes/module/Module.php index f6b2fd8fd..2c95d60bf 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -1726,7 +1726,15 @@ abstract class ModuleCore '.(int)$this->need_instance.''.(isset($this->limited_countries) ? "\n\t".''.(count($this->limited_countries) == 1 ? $this->limited_countries[0] : '').'' : '').' '; if (is_writable(_PS_MODULE_DIR_.$this->name.'/')) - file_put_contents(_PS_MODULE_DIR_.$this->name.'/config.xml', $xml); + { + $file = _PS_MODULE_DIR_.$this->name.'/config.xml'; + if (!@file_put_contents($file, $xml)) + if (!is_writable($file)) + { + @unlink($file); + @file_put_contents($file, $xml); + } + } } /** From da12fbdd5e5412c0c0f45e73da5f287d14f504b9 Mon Sep 17 00:00:00 2001 From: Jerome Nadaud Date: Mon, 2 Sep 2013 19:09:47 +0200 Subject: [PATCH 06/19] [-] BO : FixBug #PSCFV-10213 check product/attribute id - Thanks F. Cespedes --- controllers/admin/AdminImportController.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index e00153fe8..b0bef57b6 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -2435,17 +2435,12 @@ class AdminImportControllerCore extends AdminController $discount_rate = (float)$info['discount_rate']; $tax_rate = (float)$info['tax_rate']; - // checks if one product is there only once - if (isset($product['id_product'])) - { - if ($product['id_product'] == $id_product_attribute) - $this->errors[] = sprintf($this->l('Product (%d/%D) cannot be added twice (at line %d).'), $id_product, - $id_product_attribute, $current_line + 1); - else - $product['id_product'] = $id_product_attribute; - } + // checks if one product/attribute is there only once + if (isset($products[$id_product][$id_product_attribute])) + $this->errors[] = sprintf($this->l('Product/Attribute (%d/%d) cannot be added twice (at line %d).'), $id_product, + $id_product_attribute, $current_line + 1); else - $product['id_product'] = 0; + $products[$id_product][$id_product_attribute] = $quantity_expected; // checks parameters if (false === ($supplier_reference = ProductSupplier::getProductSupplierReference($id_product, $id_product_attribute, $supply_order->id_supplier))) From 97f1db480af852e01f0e523da05a318242102b1d Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 3 Sep 2013 11:35:50 +0400 Subject: [PATCH 07/19] BO: Cursor "pointer" for .button Cursor "pointer" for each button in back office --- admin-dev/themes/default/css/admin.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/admin-dev/themes/default/css/admin.css b/admin-dev/themes/default/css/admin.css index b62cd34b2..a40b7e237 100644 --- a/admin-dev/themes/default/css/admin.css +++ b/admin-dev/themes/default/css/admin.css @@ -30,6 +30,7 @@ select[disabled="disabled"], input[disabled="disabled"],textarea[disabled="disab /*BUTTON*/ .button{ + cursor: pointer; background: #e3e3e3 url('../img/bg-button-degrade.png') repeat-x scroll left top; background: -moz-linear-gradient(center top , #F9F9F9, #E3E3E3) repeat scroll 0 0 transparent; background: -webkit-gradient(linear, center top ,center bottom, from(#F9F9F9), to(#E3E3E3)) repeat scroll 0 0 transparent; @@ -673,4 +674,4 @@ ul.listForm li {padding-bottom:3px;} /************** SCENE *****************/ -#large_scene_image{clear:both;border:1px solid transparent;} \ No newline at end of file +#large_scene_image{clear:both;border:1px solid transparent;} From 98f60d039bd6198a1ab21b08bdc03cb8b0e88034 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Tue, 3 Sep 2013 12:29:17 +0200 Subject: [PATCH 08/19] // fix warning --- classes/Language.php | 3 ++- controllers/admin/AdminTranslationsController.php | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/classes/Language.php b/classes/Language.php index 724cbbb9b..786ed75a6 100644 --- a/classes/Language.php +++ b/classes/Language.php @@ -460,7 +460,8 @@ class LanguageCore extends ObjectModel } closedir($handle); } - rmdir($dir); + if (is_writable($dir)) + rmdir($dir); } public function delete() diff --git a/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index 3bbb11dc0..9766e356b 100644 --- a/controllers/admin/AdminTranslationsController.php +++ b/controllers/admin/AdminTranslationsController.php @@ -460,7 +460,9 @@ class AdminTranslationsControllerCore extends AdminController if (!$default_language || !Validate::isLanguageIsoCode($default_language)) return false; // 1 - Scan mails files - $mails = scandir(_PS_MAIL_DIR_.$default_language.'/'); + $mails = array(); + if (Tools::file_exists_cache(_PS_MAIL_DIR_.$default_language.'/')) + $mails = scandir(_PS_MAIL_DIR_.$default_language.'/'); $mails_new_lang = array(); From 572a2e45aab919001849da9e84020377487407a3 Mon Sep 17 00:00:00 2001 From: djfm Date: Tue, 3 Sep 2013 12:51:21 +0000 Subject: [PATCH 09/19] // fixed unstranslatable string in AdminSupplyOrdersController --- controllers/admin/AdminSupplyOrdersController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminSupplyOrdersController.php b/controllers/admin/AdminSupplyOrdersController.php index 17da45533..5d581be0f 100644 --- a/controllers/admin/AdminSupplyOrdersController.php +++ b/controllers/admin/AdminSupplyOrdersController.php @@ -754,7 +754,7 @@ class AdminSupplyOrdersControllerCore extends AdminController 'orderby' => false, 'filter' => false, 'search' => false, - 'hint' => 'Note that you can see details on the receptions - per products', + 'hint' => $this->l('Note that you can see details on the receptions - per products'), ), 'quantity_expected' => array( 'title' => $this->l('Quantity expected'), From cd7d604b757d8f3d2004ec0cc2bc8b77d93df0a4 Mon Sep 17 00:00:00 2001 From: soufyan Date: Tue, 3 Sep 2013 14:38:35 +0200 Subject: [PATCH 10/19] [*] Project : Orders should rely only on ps_order_cart_rule --- classes/order/Order.php | 3 +-- classes/order/OrderCartRule.php | 6 +++++- classes/order/OrderSlip.php | 13 ------------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/classes/order/Order.php b/classes/order/Order.php index a4d4db1b0..42e5b42b0 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -712,11 +712,10 @@ class OrderCore extends ObjectModel } public function getCartRules() - { + { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT * FROM `'._DB_PREFIX_.'order_cart_rule` ocr - LEFT JOIN `'._DB_PREFIX_.'cart_rule` cr ON cr.`id_cart_rule` = ocr.`id_cart_rule` WHERE ocr.`id_order` = '.(int)$this->id); } diff --git a/classes/order/OrderCartRule.php b/classes/order/OrderCartRule.php index 3eceb173d..dcc06203a 100644 --- a/classes/order/OrderCartRule.php +++ b/classes/order/OrderCartRule.php @@ -46,6 +46,9 @@ class OrderCartRuleCore extends ObjectModel /** @var float value (tax excl.) of voucher */ public $value_tax_excl; + + /** @var boolean value : voucher gives free shipping or not */ + public $free_shipping; /** * @see ObjectModel::$definition @@ -59,7 +62,8 @@ class OrderCartRuleCore extends ObjectModel 'id_order_invoice' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'required' => true), 'value' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true), - 'value_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true) + 'value_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true), + 'free_shipping' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool') ) ); diff --git a/classes/order/OrderSlip.php b/classes/order/OrderSlip.php index a9b38457d..527df4bb4 100644 --- a/classes/order/OrderSlip.php +++ b/classes/order/OrderSlip.php @@ -129,19 +129,6 @@ class OrderSlipCore extends ObjectModel { $products[$key] = $product; $products[$key]['product_quantity'] = $slip_quantity[$product['id_order_detail']]; - if (count($cart_rules)) - { - $order->setProductPrices($product); - $realProductPrice = $products[$key]['product_price']; - // Todo : must be updated to use the cart rules - foreach ($cart_rules as $cart_rule) - { - if ($cart_rule['reduction_percent']) - $products[$key]['product_price'] -= $realProductPrice * ($cart_rule['reduction_percent'] / 100); - elseif ($cart_rule['reduction_amount']) - $products[$key]['product_price'] -= (($cart_rule['reduction_amount'] * ($product['product_price_wt'] / $order->total_products_wt)) / (1.00 + ($product['tax_rate'] / 100))); - } - } } return $order->getProducts($products); } From 0891c986d6b95d05052af3bd420e515cbd664e57 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Tue, 3 Sep 2013 17:43:33 +0200 Subject: [PATCH 11/19] // fix from comment https://github.com/PrestaShop/PrestaShop/commit/c6d2e1252e1757478339009ec7b48320b1ccd92ahttps://github.com/PrestaShop/PrestaShop/commit/c6d2e1252e1757478339009ec7b48320b1ccd92a#commitcomment-4002919 --- install-dev/upgrade/php/block_category_1521.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install-dev/upgrade/php/block_category_1521.php b/install-dev/upgrade/php/block_category_1521.php index a132475ed..4ff4d086b 100644 --- a/install-dev/upgrade/php/block_category_1521.php +++ b/install-dev/upgrade/php/block_category_1521.php @@ -26,11 +26,11 @@ function block_category_1521() { - if (!Db::getInstance()->getValue('SELECT FROM `'._DB_PREFIX_.'configuration` WHERE `name` LIKE \'BLOCK_CATEG_MAX_DEPTH\' ')) + if (!Db::getInstance()->getValue('SELECT value FROM `'._DB_PREFIX_.'configuration` WHERE `name` LIKE \'BLOCK_CATEG_MAX_DEPTH\' ')) Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'configuration` (`id_configuration` ,`id_shop_group` ,`id_shop` ,`name` ,`value` ,`date_add` ,`date_upd`) VALUES (NULL, NULL, NULL, \'BLOCK_CATEG_MAX_DEPTH\', 4, NOW(), NOW())'); - else if ($maxdepth = (int)Db::getInstance()->getValue('SELECT FROM `'._DB_PREFIX_.'configuration` WHERE `value` IS NOT NULL AND `value` <> 0')) + else if ($maxdepth = (int)Db::getInstance()->getValue('SELECT value FROM `'._DB_PREFIX_.'configuration` WHERE `value` IS NOT NULL AND `value` <> 0 AND `name` LIKE \'BLOCK_CATEG_MAX_DEPTH\'')) Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'configuration` SET `value` = '.($maxdepth + 1).' WHERE `name` LIKE \'BLOCK_CATEG_MAX_DEPTH\''); } \ No newline at end of file From 6daf8ebbfad011b7888905da786876a5c5738c4e Mon Sep 17 00:00:00 2001 From: gRoussac Date: Tue, 3 Sep 2013 18:20:58 +0200 Subject: [PATCH 12/19] [-] BO : Fix error returned when first import of a localisation pack --- .../controllers/localization/content.tpl | 4 ++-- classes/Language.php | 21 +++++++++++++++---- classes/controller/AdminController.php | 6 +++++- .../admin/AdminLocalizationController.php | 3 --- .../admin/AdminTranslationsController.php | 4 +++- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/localization/content.tpl b/admin-dev/themes/default/template/controllers/localization/content.tpl index 3fefc850d..4515293f5 100644 --- a/admin-dev/themes/default/template/controllers/localization/content.tpl +++ b/admin-dev/themes/default/template/controllers/localization/content.tpl @@ -24,9 +24,9 @@ *}
- {$localization_form} + {if isset($localization_form)}{$localization_form}{/if}

- {$localization_options} + {if isset($localization_options)}{$localization_options}{/if}
\ No newline at end of file diff --git a/classes/Language.php b/classes/Language.php index 786ed75a6..8aa65596d 100644 --- a/classes/Language.php +++ b/classes/Language.php @@ -111,18 +111,22 @@ class LanguageCore extends ObjectModel $iso_code = $newIso ? $newIso : $this->iso_code; if (!file_exists(_PS_TRANSLATIONS_DIR_.$iso_code)) - mkdir(_PS_TRANSLATIONS_DIR_.$iso_code); + { + if (@mkdir(_PS_TRANSLATIONS_DIR_.$iso_code)) + @chmod(_PS_TRANSLATIONS_DIR_.$iso_code, 0777); + } + foreach ($this->translationsFilesAndVars as $file => $var) { $path_file = _PS_TRANSLATIONS_DIR_.$iso_code.'/'.$file.'.php'; if (!file_exists($path_file)) if ($file != 'tabs') - file_put_contents($path_file, ''); else - file_put_contents($path_file, ''); @@ -784,13 +788,22 @@ class LanguageCore extends ObjectModel $lang_pack_ok = false; $errors = array(); $file = _PS_TRANSLATIONS_DIR_.$iso.'.gzip'; + if (!$lang_pack_link = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.$version.'&iso_lang='.Tools::strtolower($iso))) $errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.'); elseif (!$lang_pack = Tools::jsonDecode($lang_pack_link)) $errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.'); elseif ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/'.$lang_pack->version.'/'.Tools::strtolower($lang_pack->iso_code.'.gzip'))) if (!@file_put_contents($file, $content)) - $errors[] = Tools::displayError('Server does not have permissions for writing.'); + { + if (is_writable(dirname($file))) + { + @unlink($file); + @file_put_contents($file, $content); + } + elseif (!is_writable($file)) + $errors[] = Tools::displayError('Server does not have permissions for writing.').' ('.$file.')'; + } if (file_exists($file)) { $gz = new Archive_Tar($file, true); diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 0508ecaab..4064aca38 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -726,6 +726,8 @@ class AdminControllerCore extends Controller */ public function processAdd() { + if (!isset($this->className) || empty($this->className)) + return false; /* Checking fields validity */ $this->validateRules(); if (count($this->errors) <= 0) @@ -1142,6 +1144,8 @@ class AdminControllerCore extends Controller */ protected function loadObject($opt = false) { + if (!isset($this->className) || empty($this->className)) + return true; $id = (int)Tools::getValue($this->identifier); if ($id && Validate::isUnsignedId($id)) { @@ -2400,7 +2404,7 @@ class AdminControllerCore extends Controller public function getFieldValue($obj, $key, $id_lang = null) { if ($id_lang) - $default_value = ($obj->id && isset($obj->{$key}[$id_lang])) ? $obj->{$key}[$id_lang] : false; + $default_value = (isset($obj->id) && $obj->id && isset($obj->{$key}[$id_lang])) ? $obj->{$key}[$id_lang] : false; else $default_value = isset($obj->{$key}) ? $obj->{$key} : false; diff --git a/controllers/admin/AdminLocalizationController.php b/controllers/admin/AdminLocalizationController.php index c5158f9fa..882ad4e5e 100644 --- a/controllers/admin/AdminLocalizationController.php +++ b/controllers/admin/AdminLocalizationController.php @@ -28,9 +28,6 @@ class AdminLocalizationControllerCore extends AdminController { public function __construct() { - $this->className = 'Configuration'; - $this->table = 'configuration'; - parent::__construct(); $this->fields_options = array( diff --git a/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index 9766e356b..52b178edc 100644 --- a/controllers/admin/AdminTranslationsController.php +++ b/controllers/admin/AdminTranslationsController.php @@ -581,7 +581,9 @@ class AdminTranslationsControllerCore extends AdminController if (preg_match('#^translations\/'.$iso_code.'\/tabs.php#Ui', $file['filename'], $matches) && Validate::isLanguageIsoCode($iso_code)) { // Include array width new translations tabs - $tabs = include _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.$file['filename']; + $tabs = array(); + if (Tools::file_exists_cache(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.$file['filename'])) + $tabs = include_once(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.$file['filename']); foreach ($tabs as $class_name => $translations) { From b55a84e961213fcc4a804d0dfa1f8ad2bcb2533f Mon Sep 17 00:00:00 2001 From: gRoussac Date: Tue, 3 Sep 2013 18:36:30 +0200 Subject: [PATCH 13/19] [-] INSTALLER : Fix infinite loop when order message has additional ampersand --- install-dev/upgrade/php/update_order_messages.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/install-dev/upgrade/php/update_order_messages.php b/install-dev/upgrade/php/update_order_messages.php index 369b753d5..29d4cc07e 100644 --- a/install-dev/upgrade/php/update_order_messages.php +++ b/install-dev/upgrade/php/update_order_messages.php @@ -29,17 +29,18 @@ function update_order_messages() $step = 3000; $count_messages = Db::getInstance()->getValue('SELECT count(id_message) FROM '._DB_PREFIX_.'message'); $nb_loop = $start = 0; + $pattern = ' 0) $nb_loop = ceil($count_messages / $step); for($i = 0; $i < $nb_loop; $i++) { - $sql = 'SELECT id_message, message FROM `'._DB_PREFIX_.'message` WHERE message REGEXP \'query($sql)) while ($message = Db::getInstance()->nextRow($messages)) { if(is_array($message)) { - $sql = 'UPDATE `'._DB_PREFIX_.'message` SET message = \''.pSQL(Tools::htmlentitiesDecodeUTF8(br2nl($message['message']))).'\' + $sql = 'UPDATE `'._DB_PREFIX_.'message` SET message = \''.pSQL(preg_replace('/'.$pattern.'/', '', Tools::htmlentitiesDecodeUTF8(br2nl($message['message'])))).'\' WHERE id_message = '.(int)$message['id_message']; $result = Db::getInstance()->execute($sql); } @@ -50,13 +51,13 @@ function update_order_messages() $nb_loop = ceil($count_messages / $step); for($i = 0; $i < $nb_loop; $i++) { - $sql = 'SELECT id_customer_message, message FROM `'._DB_PREFIX_.'customer_message` WHERE message REGEXP \'query($sql)) while ($message = Db::getInstance()->nextRow($messages)) { if(is_array($message)) { - $sql = 'UPDATE `'._DB_PREFIX_.'customer_message` SET message = \''.pSQL(Tools::htmlentitiesDecodeUTF8(str_replace('&', '&', $message['message']))).'\' + $sql = 'UPDATE `'._DB_PREFIX_.'customer_message` SET message = \''.pSQL(preg_replace('/'.$pattern.'/', '', Tools::htmlentitiesDecodeUTF8(str_replace('&', '&', $message['message'])))).'\' WHERE id_customer_message = '.(int)$message['id_customer_message']; Db::getInstance()->execute($sql); } From f4892686c178a23d121f3628a41a0e34b0d403d3 Mon Sep 17 00:00:00 2001 From: ha99y Date: Tue, 3 Sep 2013 17:30:05 -0700 Subject: [PATCH 14/19] Warning in AdminController.php If debugging is on (_PS_MODE_DEV_ set to TRUE) On a fresh install there is a warning on line 1542 in /classes/controller/AdminController.php in function addToolBarModulesListButton(). Because of the warning xml files are not populated with data. Warning: simplexml_load_file() 1: parser error : Document is empty --- classes/controller/AdminController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 4064aca38..0ba74a1c3 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -1544,10 +1544,13 @@ class AdminControllerCore extends Controller file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, Tools::addonsRequest('native')); $country_module_list_xml = simplexml_load_file(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST); + if($country_module_list_xml === TRUE) + { $country_module_list = array(); foreach ($country_module_list_xml->module as $k => $m) $country_module_list[] = (string)$m->name; - $this->tab_modules_list['slider_list'] = array_intersect($this->tab_modules_list['slider_list'], $country_module_list); + $this->tab_modules_list['slider_list'] = array_intersect($this->tab_modules_list['slider_list'], $country_module_list); + } if (is_array($this->tab_modules_list['slider_list']) && count($this->tab_modules_list['slider_list'])) $this->toolbar_btn['modules-list'] = array( From 75a663b6e315b5f58b7d282310ad6e6c693d2c27 Mon Sep 17 00:00:00 2001 From: Jerome Nadaud Date: Wed, 4 Sep 2013 09:40:12 +0200 Subject: [PATCH 15/19] [-] BO : Fix pull request #665 --- classes/Image.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/classes/Image.php b/classes/Image.php index 5050f98c9..a5de0fb24 100644 --- a/classes/Image.php +++ b/classes/Image.php @@ -126,14 +126,16 @@ class ImageCore extends ObjectModel public static function getImages($id_lang, $id_product, $id_product_attribute = NULL) { $attribute_filter = ($id_product_attribute ? ' AND ai.`id_product_attribute` = '.(int)$id_product_attribute : ''); + $sql = 'SELECT * + FROM `'._DB_PREFIX_.'image` i + LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image`)'; - return Db::getInstance()->executeS(' - SELECT * - FROM `'._DB_PREFIX_.'image` i - LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image`) - LEFT JOIN `'._DB_PREFIX_.'product_attribute_image` ai ON (i.`id_image` = ai.`id_image`) - WHERE i.`id_product` = '.(int)$id_product.' AND il.`id_lang` = '.(int)$id_lang . $attribute_filter.' - ORDER BY i.`position` ASC'); + if ($id_product_attribute) + $sql .= ' LEFT JOIN `'._DB_PREFIX_.'product_attribute_image` ai ON (i.`id_image` = ai.`id_image`)'; + + $sql .= ' WHERE i.`id_product` = '.(int)$id_product.' AND il.`id_lang` = '.(int)$id_lang . $attribute_filter.' + ORDER BY i.`position` ASC'; + return Db::getInstance()->executeS($sql); } /** From df56d7af427e2f4b674089944e709a61059c1e52 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Wed, 4 Sep 2013 10:38:14 +0200 Subject: [PATCH 16/19] [-] CORE: Fix for field length and type regarding https://github.com/PrestaShop/PrestaShop/pull/678 --- classes/Manufacturer.php | 2 +- classes/Supplier.php | 2 +- install-dev/upgrade/sql/1.5.6.0.sql | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 install-dev/upgrade/sql/1.5.6.0.sql diff --git a/classes/Manufacturer.php b/classes/Manufacturer.php index 8cc573bad..c40fa01c8 100644 --- a/classes/Manufacturer.php +++ b/classes/Manufacturer.php @@ -79,7 +79,7 @@ class ManufacturerCore extends ObjectModel // Lang fields 'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), - 'short_description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 254), + 'short_description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), 'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName'), diff --git a/classes/Supplier.php b/classes/Supplier.php index 7749fb6de..3130913c1 100644 --- a/classes/Supplier.php +++ b/classes/Supplier.php @@ -72,7 +72,7 @@ class SupplierCore extends ObjectModel 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), // Lang fields - 'description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName'), + 'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), 'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), diff --git a/install-dev/upgrade/sql/1.5.6.0.sql b/install-dev/upgrade/sql/1.5.6.0.sql new file mode 100644 index 000000000..5f5521cff --- /dev/null +++ b/install-dev/upgrade/sql/1.5.6.0.sql @@ -0,0 +1 @@ +ALTER TABLE `PREFIX_manufacturer_lang` CHANGE `short_description` `short_description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL; \ No newline at end of file From da353c884de6d02863b9f6ce1c621c88f98129d1 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Wed, 4 Sep 2013 10:45:48 +0200 Subject: [PATCH 17/19] [-] INSTALLER: short_description for PREFIX_manufacturer_lang is now type TEXT --- install-dev/data/db_structure.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-dev/data/db_structure.sql b/install-dev/data/db_structure.sql index d067ea6f0..4ad6974fc 100644 --- a/install-dev/data/db_structure.sql +++ b/install-dev/data/db_structure.sql @@ -936,7 +936,7 @@ CREATE TABLE `PREFIX_manufacturer_lang` ( `id_manufacturer` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, `description` text, - `short_description` varchar(254) default NULL, + `short_description` text, `meta_title` varchar(128) default NULL, `meta_keywords` varchar(255) default NULL, `meta_description` varchar(255) default NULL, From efa81a7107e9bdf163caad2a8f652883fa6cfa34 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Wed, 4 Sep 2013 11:14:00 +0200 Subject: [PATCH 18/19] [-] INSTALLER: Wrong SQL query for PS_LEGACY_IMAGES to 0 --- install-dev/upgrade/sql/1.5.5.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-dev/upgrade/sql/1.5.5.0.sql b/install-dev/upgrade/sql/1.5.5.0.sql index 04d4af493..52ecc9841 100644 --- a/install-dev/upgrade/sql/1.5.5.0.sql +++ b/install-dev/upgrade/sql/1.5.5.0.sql @@ -34,6 +34,6 @@ ALTER TABLE `PREFIX_product_shop` DROP INDEX `date_add`, ADD INDEX `date_add` (` UPDATE `PREFIX_hook` SET `live_edit` = '1' WHERE `name` LIKE 'leftcolumn'; -UPDATE `PREFIX_configuration` SET `name` = '0' WHERE `name` LIKE 'PS_LEGACY_IMAGES' AND `value` LIKE '1'; +UPDATE `PREFIX_configuration` SET `value` = '0' WHERE `name` LIKE 'PS_LEGACY_IMAGES' AND `value` LIKE '1'; INSERT INTO `PREFIX_configuration` (`name`, `value`, `date_add`, `date_upd`) VALUES('PS_SMARTY_CONSOLE_KEY', 'SMARTY_DEBUG', NOW(), NOW()); From 7b0349ca332d378cd4e6548e8bfbfbb6c4b2331e Mon Sep 17 00:00:00 2001 From: gRoussac Date: Wed, 4 Sep 2013 11:14:45 +0200 Subject: [PATCH 19/19] // bad commit sorry for that --- install-dev/upgrade/sql/1.5.5.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-dev/upgrade/sql/1.5.5.0.sql b/install-dev/upgrade/sql/1.5.5.0.sql index 52ecc9841..c93e293ac 100644 --- a/install-dev/upgrade/sql/1.5.5.0.sql +++ b/install-dev/upgrade/sql/1.5.5.0.sql @@ -34,6 +34,6 @@ ALTER TABLE `PREFIX_product_shop` DROP INDEX `date_add`, ADD INDEX `date_add` (` UPDATE `PREFIX_hook` SET `live_edit` = '1' WHERE `name` LIKE 'leftcolumn'; -UPDATE `PREFIX_configuration` SET `value` = '0' WHERE `name` LIKE 'PS_LEGACY_IMAGES' AND `value` LIKE '1'; +UPDATE `PREFIX_configuration` SET `value` = '0' WHERE `name` LIKE 'PS_LEGACY_IMAGES' AND `value` = 1; INSERT INTO `PREFIX_configuration` (`name`, `value`, `date_add`, `date_upd`) VALUES('PS_SMARTY_CONSOLE_KEY', 'SMARTY_DEBUG', NOW(), NOW());