From c5e65e1360f1fa0838bddbdbc3d519ceac51b99c Mon Sep 17 00:00:00 2001
From: Vincent Augagneur
Date: Wed, 26 Jun 2013 11:38:08 +0200
Subject: [PATCH 01/11] [-] BO - fixed bug #PSCFV-9435 - AdminController -
processUpdateOptions does not manage required field correctly in a
non-mutltishop context
---
classes/controller/AdminController.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php
index 98546450d..597e75371 100644
--- a/classes/controller/AdminController.php
+++ b/classes/controller/AdminController.php
@@ -955,7 +955,8 @@ class AdminControllerCore extends Controller
continue;
// Check if field is required
- if (isset($values['required']) && $values['required'] && !empty($_POST['multishopOverrideOption'][$field]))
+ if ((!Shop::isFeatureActive() && isset($values['required']) && $values['required'])
+ || (Shop::isFeatureActive() && isset($_POST['multishopOverrideOption'][$field]) && isset($values['required']) && $values['required']))
if (isset($values['type']) && $values['type'] == 'textLang')
{
foreach ($languages as $language)
From 3d2e46b14f79602b38291820dc40248da4ad4f4b Mon Sep 17 00:00:00 2001
From: Vincent Augagneur
Date: Wed, 26 Jun 2013 11:46:02 +0200
Subject: [PATCH 02/11] [-] FO : fixed bug #PSCFV-9388 - newsletter is required
error, showing two times
---
classes/ObjectModel.php | 8 ++++----
controllers/front/AuthController.php | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php
index 48fe026e4..fc6a40697 100644
--- a/classes/ObjectModel.php
+++ b/classes/ObjectModel.php
@@ -977,11 +977,11 @@ abstract class ObjectModelCore
// Checking for required fields
if (isset($data['required']) && $data['required'] && ($value = Tools::getValue($field, $this->{$field})) == false && (string)$value != '0')
if (!$this->id || $field != 'passwd')
- $errors[] = ''.self::displayFieldName($field, get_class($this), $htmlentities).' '.Tools::displayError('is required.');
+ $errors[$field] = ''.self::displayFieldName($field, get_class($this), $htmlentities).' '.Tools::displayError('is required.');
// Checking for maximum fields sizes
if (isset($data['size']) && ($value = Tools::getValue($field, $this->{$field})) && Tools::strlen($value) > $data['size'])
- $errors[] = sprintf(
+ $errors[$field] = sprintf(
Tools::displayError('%1$s is too long. Maximum length: %2$d'),
self::displayFieldName($field, get_class($this), $htmlentities),
$data['size']
@@ -992,7 +992,7 @@ abstract class ObjectModelCore
if (($value = Tools::getValue($field, $this->{$field})) || ($field == 'postcode' && $value == '0'))
{
if (isset($data['validate']) && !Validate::$data['validate']($value) && (!empty($value) || $data['required']))
- $errors[] = ''.self::displayFieldName($field, get_class($this), $htmlentities).' '.Tools::displayError('is invalid.');
+ $errors[$field] = ''.self::displayFieldName($field, get_class($this), $htmlentities).' '.Tools::displayError('is invalid.');
else
{
if (isset($data['copy_post']) && !$data['copy_post'])
@@ -1136,7 +1136,7 @@ abstract class ObjectModelCore
$value = Tools::getValue($field);
if (empty($value))
- $errors[] = sprintf(Tools::displayError('The field %s is required.'), self::displayFieldName($field, get_class($this), $htmlentities));
+ $errors[$field] = sprintf(Tools::displayError('The field %s is required.'), self::displayFieldName($field, get_class($this), $htmlentities));
}
return $errors;
diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php
index 7d599ed65..08c96d058 100644
--- a/controllers/front/AuthController.php
+++ b/controllers/front/AuthController.php
@@ -414,11 +414,11 @@ class AuthControllerCore extends FrontController
if ($error_phone)
$this->errors[] = Tools::displayError('You must register at least one phone number.');
-
+
$this->errors = array_unique(array_merge($this->errors, $customer->validateController()));
// Check the requires fields which are settings in the BO
- $this->errors = array_merge($this->errors, $customer->validateFieldsRequiredDatabase());
+ $this->errors = $this->errors + $customer->validateFieldsRequiredDatabase();
if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount'))
{
From c01619dfe3e330b160d7ac2365f4945959a82d88 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Gaillard?=
Date: Wed, 26 Jun 2013 12:05:36 +0200
Subject: [PATCH 03/11] // Change administrator access fixture
---
install-dev/fixtures/apple/data/access.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/install-dev/fixtures/apple/data/access.xml b/install-dev/fixtures/apple/data/access.xml
index 31636ce76..45126998a 100644
--- a/install-dev/fixtures/apple/data/access.xml
+++ b/install-dev/fixtures/apple/data/access.xml
@@ -96,7 +96,7 @@
-
+
From 9257dc80c2015b8885d08162d3cb52bb8bf4e89c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Gaillard?=
Date: Wed, 26 Jun 2013 14:17:45 +0200
Subject: [PATCH 04/11] [-] BO: Fix #PSCFV-9455 stock was resetted if adv stock
management is enable and product preference is submited on shop context
---
controllers/admin/AdminPPreferencesController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/controllers/admin/AdminPPreferencesController.php b/controllers/admin/AdminPPreferencesController.php
index c3cb9a352..ee69e93ea 100644
--- a/controllers/admin/AdminPPreferencesController.php
+++ b/controllers/admin/AdminPPreferencesController.php
@@ -231,7 +231,7 @@ class AdminPPreferencesControllerCore extends AdminController
// if advanced stock management is disabled, updates concerned tables
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 1 &&
- (int)Tools::getValue('PS_ADVANCED_STOCK_MANAGEMENT') == 0)
+ (int)Tools::getValue('PS_ADVANCED_STOCK_MANAGEMENT') == 0 && Context::getContext()->shop->getContext() == Shop::CONTEXT_ALL)
{
ObjectModel::updateMultishopTable('Product', array('advanced_stock_management' => 0), 'product_shop.`advanced_stock_management` = 1');
From 19ee2c953f9a5cef1d0d185c38cef05167cefdd1 Mon Sep 17 00:00:00 2001
From: Damien Metzger
Date: Wed, 26 Jun 2013 14:26:22 +0200
Subject: [PATCH 05/11] [*] IN : removed the possibility to choose his own
storage engine, automatically select the best one
---
classes/db/Db.php | 4 +-
classes/db/DbMySQLi.php | 37 +++++++++++-----
classes/db/DbPDO.php | 52 +++++++++++------------
classes/db/MySQL.php | 52 +++++++++++------------
install-dev/controllers/http/database.php | 14 +++---
install-dev/models/database.php | 28 ++++++------
install-dev/theme/views/database.phtml | 3 +-
7 files changed, 105 insertions(+), 85 deletions(-)
diff --git a/classes/db/Db.php b/classes/db/Db.php
index e543f35ce..f408d3af9 100644
--- a/classes/db/Db.php
+++ b/classes/db/Db.php
@@ -169,6 +169,8 @@ abstract class DbCore
/* do not remove, useful for some modules */
abstract public function set_db($db_name);
+
+ abstract public function getBestEngine();
/**
* Get Db object instance
@@ -674,7 +676,7 @@ abstract class DbCore
return call_user_func_array(array(Db::getClass(), 'hasTableWithSamePrefix'), array($server, $user, $pwd, $db, $prefix));
}
- public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
+ public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
return call_user_func_array(array(Db::getClass(), 'checkCreatePrivilege'), array($server, $user, $pwd, $db, $prefix, $engine));
}
diff --git a/classes/db/DbMySQLi.php b/classes/db/DbMySQLi.php
index 3d5556908..e03974a38 100644
--- a/classes/db/DbMySQLi.php
+++ b/classes/db/DbMySQLi.php
@@ -172,21 +172,36 @@ class DbMySQLiCore extends Db
if (!$link->real_connect($server, $user, $pwd, $db))
return (mysqli_connect_errno() == 1049) ? 2 : 1;
- if (strtolower($engine) == 'innodb')
- {
- $sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
- $result = $link->query($sql);
- if (!$result)
- return 4;
- $row = $result->fetch_assoc();
- if (!$row || strtolower($row['Value']) != 'yes')
- return 4;
- }
$link->close();
return 0;
}
- public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
+ public function getBestEngine()
+ {
+ $value = 'InnoDB';
+
+ $sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
+ $result = $link->query($sql);
+ if (!$result)
+ $value = 'MyISAM';
+ $row = $result->fetch_assoc();
+ if (!$row || strtolower($row['Value']) != 'yes')
+ $value = 'MyISAM';
+
+ /* MySQL >= 5.6 */
+ $sql = 'SHOW ENGINES';
+ $result = $link->query($sql);
+ while ($row = $result->fetch_assoc())
+ if ($row['Engine'] == 'InnoDB')
+ {
+ if (in_array($row['Support'], array('DEFAULT', 'YES')))
+ $value = 'InnoDB';
+ break;
+ }
+ return $value;
+ }
+
+ public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
$link = @new mysqli($server, $user, $pwd, $db);
if (mysqli_connect_error())
diff --git a/classes/db/DbPDO.php b/classes/db/DbPDO.php
index ed2870a16..9a381d721 100644
--- a/classes/db/DbPDO.php
+++ b/classes/db/DbPDO.php
@@ -174,7 +174,7 @@ class DbPDOCore extends Db
return (bool)$result->fetch();
}
- public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
+ public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, 5);
@@ -206,34 +206,34 @@ class DbPDOCore extends Db
} catch (PDOException $e) {
return ($e->getCode() == 1049) ? 2 : 1;
}
-
- if (strtolower($engine) == 'innodb')
- {
- $value = 0;
-
- $sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
- $result = $link->query($sql);
- if (!$result)
- $value = 4;
- $row = $result->fetch();
- if (!$row || strtolower($row['Value']) != 'yes')
- $value = 4;
-
- /* MySQL >= 5.6 */
- $sql = 'SHOW ENGINES';
- $result = $link->query($sql);
- while ($row = $result->fetch())
- if ($row['Engine'] == 'InnoDB')
- {
- if (in_array($row['Support'], array('DEFAULT', 'YES')))
- $value = 0;
- break;
- }
- return $value;
- }
unset($link);
return 0;
}
+
+ public function getBestEngine()
+ {
+ $value = 'InnoDB';
+
+ $sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
+ $result = $link->query($sql);
+ if (!$result)
+ $value = 'MyISAM';
+ $row = $result->fetch();
+ if (!$row || strtolower($row['Value']) != 'yes')
+ $value = 'MyISAM';
+
+ /* MySQL >= 5.6 */
+ $sql = 'SHOW ENGINES';
+ $result = $link->query($sql);
+ while ($row = $result->fetch())
+ if ($row['Engine'] == 'InnoDB')
+ {
+ if (in_array($row['Support'], array('DEFAULT', 'YES')))
+ $value = 'InnoDB';
+ break;
+ }
+ return $value;
+ }
/**
* @see Db::checkEncoding()
diff --git a/classes/db/MySQL.php b/classes/db/MySQL.php
index ba05fd29c..d66f488da 100644
--- a/classes/db/MySQL.php
+++ b/classes/db/MySQL.php
@@ -165,36 +165,36 @@ class MySQLCore extends Db
return 1;
if (!@mysql_select_db($db, $link))
return 2;
-
- if (strtolower($engine) == 'innodb')
- {
- $value = 0;
-
- $sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
- $result = mysql_query($sql);
- if (!$result)
- $value = 4;
- $row = mysql_fetch_assoc($result);
- if (!$row || strtolower($row['Value']) != 'yes')
- $value = 4;
-
- /* MySQL >= 5.6 */
- $sql = 'SHOW ENGINES';
- $result = mysql_query($sql);
- while ($row = mysql_fetch_assoc($result))
- if ($row['Engine'] == 'InnoDB')
- {
- if (in_array($row['Support'], array('DEFAULT', 'YES')))
- $value = 0;
- break;
- }
- return $value;
- }
@mysql_close($link);
return 0;
}
+
+ public function getBestEngine()
+ {
+ $value = 'InnoDB';
+
+ $sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
+ $result = mysql_query($sql);
+ if (!$result)
+ $value = 'MyISAM';
+ $row = mysql_fetch_assoc($result);
+ if (!$row || strtolower($row['Value']) != 'yes')
+ $value = 'MyISAM';
+
+ /* MySQL >= 5.6 */
+ $sql = 'SHOW ENGINES';
+ $result = mysql_query($sql);
+ while ($row = mysql_fetch_assoc($result))
+ if ($row['Engine'] == 'InnoDB')
+ {
+ if (in_array($row['Support'], array('DEFAULT', 'YES')))
+ $value = 'InnoDB';
+ break;
+ }
+ return $value;
+ }
- public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
+ public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
ini_set('mysql.connect_timeout', 5);
if (!$link = @mysql_connect($server, $user, $pwd, true))
diff --git a/install-dev/controllers/http/database.php b/install-dev/controllers/http/database.php
index 6ec8ece98..3a603acdc 100644
--- a/install-dev/controllers/http/database.php
+++ b/install-dev/controllers/http/database.php
@@ -56,7 +56,6 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
$this->session->database_login = trim(Tools::getValue('dbLogin'));
$this->session->database_password = trim(Tools::getValue('dbPassword'));
$this->session->database_prefix = trim(Tools::getValue('db_prefix'));
- $this->session->database_engine = Tools::getValue('dbEngine');
$this->session->database_clear = Tools::getValue('database_clear');
// Save email config
@@ -81,13 +80,15 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
$this->session->database_login,
$this->session->database_password,
$this->session->database_prefix,
- $this->session->database_engine,
-
// We do not want to validate table prefix if we are already in install process
($this->session->step == 'process') ? true : $this->session->database_clear
);
-
- return count($this->errors) ? false : true;
+ if (count($this->errors))
+ return false;
+
+ if (!isset($this->session->database_engine))
+ $this->session->database_engine = $this->model_database->getBestEngine($this->session->database_server, $this->session->database_name, $this->session->database_login, $this->session->database_password);
+ return true;
}
public function process()
@@ -108,10 +109,9 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
$login = Tools::getValue('dbLogin');
$password = Tools::getValue('dbPassword');
$prefix = Tools::getValue('db_prefix');
- $engine = Tools::getValue('dbEngine');
$clear = Tools::getValue('clear');
- $errors = $this->model_database->testDatabaseSettings($server, $database, $login, $password, $prefix, $engine, $clear);
+ $errors = $this->model_database->testDatabaseSettings($server, $database, $login, $password, $prefix, $clear);
$this->ajaxJsonAnswer(
(count($errors)) ? false : true,
diff --git a/install-dev/models/database.php b/install-dev/models/database.php
index 387713854..7105ebe9b 100644
--- a/install-dev/models/database.php
+++ b/install-dev/models/database.php
@@ -38,7 +38,7 @@ class InstallModelDatabase extends InstallAbstractModel
* @param bool $clear
* @return array List of errors
*/
- public function testDatabaseSettings($server, $database, $login, $password, $prefix, $engine, $clear = false)
+ public function testDatabaseSettings($server, $database, $login, $password, $prefix, $clear = false)
{
$errors = array();
@@ -55,14 +55,11 @@ class InstallModelDatabase extends InstallAbstractModel
if ($prefix && !Validate::isTablePrefix($prefix))
$errors[] = $this->language->l('Tables prefix is invalid');
- if (!Validate::isMySQLEngine($engine))
- $errors[] = $this->language->l('Wrong engine chosen for MySQL');
-
if (!$errors)
{
$dbtype = ' ('.Db::getClass().')';
// Try to connect to database
- switch (Db::checkConnection($server, $login, $password, $database, true, $engine))
+ switch (Db::checkConnection($server, $login, $password, $database, true))
{
case 0:
if (!Db::checkEncoding($server, $login, $password))
@@ -71,28 +68,33 @@ class InstallModelDatabase extends InstallAbstractModel
// Check if a table with same prefix already exists
if (!$clear && Db::hasTableWithSamePrefix($server, $login, $password, $database, $prefix))
$errors[] = $this->language->l('At least one table with same prefix was already found, please change your prefix or drop your database');
- if (($create_error = Db::checkCreatePrivilege($server, $login, $password, $database, $prefix, $engine)) !== true)
+ if (($create_error = Db::checkCreatePrivilege($server, $login, $password, $database, $prefix)) !== true)
{
$errors[] = $this->language->l(sprintf('Your database login don\'t have the privileges to create table on the database "%s". Ask your hosting provider:', $database));
if ($create_error != false)
$errors[] = $create_error;
}
- break;
+ break;
case 1:
$errors[] = $this->language->l('Database Server is not found. Please verify the login, password and server fields').$dbtype;
- break;
+ break;
case 2:
$errors[] = $this->language->l('Connection to MySQL server succeeded, but database "%s" not found', $database).$dbtype;
- break;
-
- case 4:
- $errors[] = $this->language->l('Engine innoDB is not supported by your MySQL server, please use MyISAM').$dbtype;
- break;
+ break;
}
}
return $errors;
}
+
+ public function getBestEngine($server, $database, $login, $password)
+ {
+ $class = Db::getClass();
+ $instance = new $class($server, $login, $password, $database, true);
+ $engine = $instance->getBestEngine();
+ unset($instance);
+ return $engine;
+ }
}
diff --git a/install-dev/theme/views/database.phtml b/install-dev/theme/views/database.phtml
index 8dae7d7a9..a24c92878 100644
--- a/install-dev/theme/views/database.phtml
+++ b/install-dev/theme/views/database.phtml
@@ -27,13 +27,14 @@
+
From 7427efdb6f3a5b58d843d008e32e2ca512b88014 Mon Sep 17 00:00:00 2001
From: Damien Metzger
Date: Wed, 26 Jun 2013 15:52:40 +0200
Subject: [PATCH 06/11] // Added addlashes for some js messages
---
.../controllers/groups/helpers/form/form.tpl | 86 +++++++++----------
.../controllers/import/helpers/form/form.tpl | 4 +-
.../request_sql/helpers/form/form.tpl | 2 +-
.../shop/helpers/list/list_action_delete.tpl | 4 +-
.../supply_orders/helpers/form/form.tpl | 2 +-
js/admin_order.js | 6 +-
6 files changed, 50 insertions(+), 54 deletions(-)
diff --git a/admin-dev/themes/default/template/controllers/groups/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/groups/helpers/form/form.tpl
index acb52c2e8..681758327 100644
--- a/admin-dev/themes/default/template/controllers/groups/helpers/form/form.tpl
+++ b/admin-dev/themes/default/template/controllers/groups/helpers/form/form.tpl
@@ -106,63 +106,61 @@
if ($(this).attr('name') == 'category_reduction['+$('[name="id_category"]:checked').val()+']')
{
exist = true;
- jAlert('{l s='This category already exists for this group.'}');
+ jAlert('{l s='This category already exists for this group.' js='1'}');
return false;
}
-
});
if (exist)
return;
$.ajax({
- type:"POST",
- url: "ajax-tab.php",
- async: true,
- dataType: "json",
- data : {
- ajax: "1",
- token: "{getAdminToken tab='AdminGroups'}",
- controller: "AdminGroups",
- action: "addCategoryReduction",
- category_reduction: $('#category_reduction_fancybox').val() ,
- id_category: $('[name="id_category"]:checked').val()
- },
- success : function(jsonData)
+ type:"POST",
+ url: "ajax-tab.php",
+ async: true,
+ dataType: "json",
+ data : {
+ ajax: "1",
+ token: "{getAdminToken tab='AdminGroups'}",
+ controller: "AdminGroups",
+ action: "addCategoryReduction",
+ category_reduction: $('#category_reduction_fancybox').val() ,
+ id_category: $('[name="id_category"]:checked').val()
+ },
+ success : function(jsonData) {
+ if (jsonData.hasError)
{
- if (jsonData.hasError)
- {
- var errors = '';
- for(error in jsonData.errors)
- //IE6 bug fix
- if(error != 'indexOf')
- errors += jsonData.errors[error] + "\n";
- jAlert(errors);
- }
- else
- {
- $('#group_discount_category_table').append('| '+jsonData.catPath+' | {l s='Discount:'}'+jsonData.discount+'{l s='%'} |  |
');
-
- var input_hidden = document.createElement("input");
- input_hidden.setAttribute('type', 'hidden');
- input_hidden.setAttribute('value', jsonData.discount);
- input_hidden.setAttribute('name', 'category_reduction['+jsonData.id_category+']');
- input_hidden.setAttribute('class', 'category_reduction');
-
- $('#group_discount_category_table tr#'+jsonData.id_category+' > td:last').append(input_hidden);
- $.fancybox.close();
- }
+ var errors = '';
+ for(error in jsonData.errors)
+ //IE6 bug fix
+ if(error != 'indexOf')
+ errors += jsonData.errors[error] + "\n";
+ jAlert(errors);
}
- });
+ else
+ {
+ $('#group_discount_category_table').append('| '+jsonData.catPath+' | {l s='Discount:'}'+jsonData.discount+'{l s='%'} |  |
');
+
+ var input_hidden = document.createElement("input");
+ input_hidden.setAttribute('type', 'hidden');
+ input_hidden.setAttribute('value', jsonData.discount);
+ input_hidden.setAttribute('name', 'category_reduction['+jsonData.id_category+']');
+ input_hidden.setAttribute('class', 'category_reduction');
+
+ $('#group_discount_category_table tr#'+jsonData.id_category+' > td:last').append(input_hidden);
+ $.fancybox.close();
+ }
+ }
+ });
return false;
}
- function initFancyBox()
- {
- $('[name="id_category"]:checked').removeAttr('checked');
- collapseAllCategories();
- $('#category_reduction_fancybox').val('0.00');
- }
+ function initFancyBox()
+ {
+ $('[name="id_category"]:checked').removeAttr('checked');
+ collapseAllCategories();
+ $('#category_reduction_fancybox').val('0.00');
+ }