-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refacto AdminImportControllerCore #8122
Conversation
Hello LittleBigDev! This is your first pull request on the PrestaShop project. Thank you, and welcome to this Open Source community! |
To reviewers : bug was fixed by |
Fixed :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to refacto / clean, all comments are made regarding this task.
However, some changes were not easy to understand. In my opinion, we need more tests prior merge.
if (!(AdminImportController::copyImg($store->id, null, $store->image, 'stores', !$regenerate))) { | ||
$this->warnings[] = $store->image.' '.$this->trans('cannot be copied.', array(), 'Admin.Advparameters.Notification'); | ||
if (!empty($store->image)) { | ||
$imgWasCopied = AdminImportController::copyImg($store->id, null, $store->image, 'stores', !$regenerate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the value is not used on another line, no need to store it in a variable. The previous version was correct in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was done to enhance readability of the code. AdminImportController::copyImg()
return value was unclear.
$imgWasCopied = AdminImportController::copyImg($store->id, null, $store->image, 'stores', !$regenerate); | ||
if (!$imgWasCopied) { | ||
$this->warnings[] = $store->image . ' ' | ||
. $this->trans('cannot be copied.', [], 'Admin.Advparameters.Notification'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @AlexEven
If we mix refacto and bug fix in this PR, it would be great to make $store->image
as a variable in the translated message. It may be not available on the beginning of the string in some language. However, this means we cannot merge it for 1.7.2.x if 1.7.2.0 is released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirm that we'd rather have
'%1 cannot be copied
(or some equivalent)
than
$img . ' ' . ' cannot be copied'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And yeah, if the PR introduces string changes, it's kinda late in the 1.7.2.x game, and might force the PR to be moved to 1.7.3.x...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer too but it would be outside BOOM-294's scope.
I'm ok to fix this in another PR (this is not the only one that would need a fix).
$storeId = isset($info['id']) ? (int)$info['id'] : null; | ||
$store = new Store($storeId); | ||
|
||
$store->force_id = (bool)$forceIds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happen for $force_ids
and Store::existsInDatabase(...)
?
You should explain why you changed the tests, because after a quick look this is unclear. If we want to refacto it without modifying the test cases, I would have written i.e:
if (!empty($info['id']) && ($force_ids || Store::existsInDatabase((int)$info['id'], 'store'))) {
$storeId = (int)$info['id'];
} else {
$storeId = null;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this code block is redundant with Store
and ObjectModel
constructors' logic :
- passing empty or unknown id will lead to an unloaded
Store
object $force_ids
is used only whenStore::add()
is executed and has no meaning when we need to decide whether we pass an id to the constructor or not.
|
||
// If errors, log them and stop execution | ||
if (true !== $fieldsValidationResult || true !== $langFieldsValidationResult) { | ||
$errorGenericMessage = $this->trans('Store is invalid', [], 'Admin.Advparameters.Notification'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[]
--> array()
); | ||
} | ||
} else { | ||
$this->errors[] = $this->trans('Store is invalid', array(), 'Admin.Advparameters.Notification').' ('.$store->name.')'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexEven, aren't we supposed to add ('.$store->name.')
in the translated string as a variable? This could be the occasion to update this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too late for 1.7.2 :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. Should I change this couple of translations in this PR ?
Edit : according to Maxime's comment, I won't fix it here.
// If nothing worked, log an error | ||
if (!$res) { | ||
$this->errors[] = Db::getInstance()->getMsgError() . ' ' | ||
. sprintf( | ||
$this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Advparameters.Notification'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we refacto stuff, it would be great to not use sprintf for a translated string, but insert $info['name']
and ($store->id ? $store->id : 'null')
in the second parameter of trans instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In progress...
|
||
// If store doesn't exist or update failed | ||
if (!$res) { | ||
$store->force_id = (bool)$forceIds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be a duplicate of line 3724
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I forgot to remove it here.
|
||
$res = false; | ||
if ($store->storeExists($store->id)) { | ||
$res = $store->update(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would save()
help you? It handles both update()
and add()
whether it exists or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it would. Should I fix this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a look at ObjectModel::save()
method and behavior is slightly different.
ObjectModel::save()
only checks if an id
is present and if so, ObjectModel::update()
is called.
Our code explicitely checks in DB if this is a known id. I'm ok to use ObjectModel::save()
, but I need your feedback before.
@LittleBigDev I put your PR in Edit: you need to rebase this one 😄 too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this refacto! There are many little things to fix :)
classes/Manufacturer.php
Outdated
@@ -64,6 +64,8 @@ class ManufacturerCore extends ObjectModel | |||
/** @var bool active */ | |||
public $active; | |||
|
|||
public $shop; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't forget to add PHPDoc if you know what this property contains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in next commit.
'Attribute (Name:Type:Position)', | ||
array(), | ||
'Admin.Advparameters.Feature' | ||
) . '*', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Symfony standards say:
Add a single space around binary operators (
==
,&&
, ...), with the exception of the concatenation (.
) operator;
So unfortunately you need to remove the spaces around the .
operator.
See: http://symfony.com/doc/current/contributing/code/standards.html#structure
@@ -559,12 +855,14 @@ public function __construct() | |||
} | |||
} | |||
|
|||
$this->separator = ($separator = Tools::substr(strval(trim(Tools::getValue('separator'))), 0, 1)) ? $separator : ';'; | |||
$separator = Tools::substr(strval(trim(Tools::getValue('separator'))), 0, 1); | |||
$this->separator = $separator ? $separator : ';'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch it, you wrote two spaces after :
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in next commit.
$this->convert = false; | ||
$this->multiple_value_separator = ($separator = Tools::substr(strval(trim(Tools::getValue('multiple_value_separator'))), 0, 1)) ? $separator : ','; | ||
$separator = Tools::substr(strval(trim(Tools::getValue('multiple_value_separator'))), 0, 1); | ||
$this->multiple_value_separator = $separator ? $separator : ','; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in next commit.
@@ -652,14 +959,18 @@ public function renderForm() | |||
$last = strtolower($post_max_size[strlen($post_max_size) - 1]); | |||
|
|||
switch ($last) { | |||
|
|||
/** @noinspection PhpMissingBreakStatementInspection */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need this if your case ends with a comment
', false); | ||
$datas = Db::getInstance()->getRow( | ||
'SELECT p.`id_product` ' | ||
. 'FROM `' . _DB_PREFIX_ . 'product` p ' . Shop::addSqlAssociation('product', 'p') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leading space before FROM
* @param $notUsed : Not used anymore. | ||
* @param bool $regenerate : If images should be regenerated | ||
* @param bool $forceIds : If passed store id should be used for store creation | ||
* @param bool $validateOnly : If set to true, store will not be updated nor created with $info data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When writing PHPDoc, please don't use a separator between the variable name and the description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). | ||
Db::getInstance()->getMsgError(); | ||
if ($fieldsValidationResult !== true | ||
|| isset($langFieldsValidationResult) && $langFieldsValidationResult !== true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please wrap isset($langFieldsValidationResult) && $langFieldsValidationResult !== true
with parentheses for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- && is prevalent on ||
- I created a new line for this group
- but ok, I'll change this in next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -4078,7 +5147,8 @@ protected function supplyOrdersDetailsImportOne($info, &$products, &$reset, $for | |||
IFNULL(pa.upc, IFNULL(p.upc, \'\')) as upc | |||
'); | |||
$query->from('product', 'p'); | |||
$query->leftJoin('product_attribute', 'pa', 'pa.id_product = p.id_product AND id_product_attribute = '.(int)$id_product_attribute); | |||
$query->leftJoin('product_attribute', 'pa', 'pa.id_product = p.id_product AND id_product_attribute = ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the line is too long, I'd prefer if it was broken up by arguments (one per line).
@@ -4224,7 +5294,8 @@ protected function truncateTables($case) | |||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'specific_price_priority`'); | |||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_carrier`'); | |||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'cart_product`'); | |||
if (count(Db::getInstance()->executeS('SHOW TABLES LIKE \''._DB_PREFIX_.'favorite_product\' '))) { //check if table exist | |||
//check if table exist before truncate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"table exists" 😉
@@ -52,6 +52,9 @@ class ProductCore extends ObjectModel | |||
/** @var int default Category id */ | |||
public $id_category_default; | |||
|
|||
/** @var array */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @LittleBigDev
I've no idea of the context, just an alert, is it really array ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is. Have a look at this line in AdminImportController.
'help' => $this->trans('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.', array(), 'Admin.Advparameters.Help'), | ||
'help' => $this->trans( | ||
'Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, ' | ||
. 'the default shop will be used.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't split a translatable string like that, the parser will fail.
Please, remove the concatenation even if you did it for the line length.
'meta_title' => array('label' => $this->trans('Meta title', array(), 'Admin.Global')), | ||
'meta_keywords' => array('label' => $this->trans('Meta keywords', array(), 'Admin.Global')), | ||
'meta_description' => array('label' => $this->trans('Meta description', array(), 'Admin.Global')), | ||
'image' => array('label' => $this->trans('Image URL', array(), 'Admin.Advparameters.Feature')), | ||
'shop' => array( | ||
'label' => $this->trans('ID / Name of group shop', array(), 'Admin.Advparameters.Feature'), | ||
'help' => $this->trans('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.', array(), 'Admin.Advparameters.Help'), | ||
'help' => $this->trans( | ||
'Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't split a translatable string like that, the parser will fail.
Please, remove the concatenation even if you did it for the line length.
'image' => array('label' => $this->trans('Image URL', array(), 'Admin.Advparameters.Feature')), | ||
'shop' => array( | ||
'label' => $this->trans('ID / Name of shop', array(), 'Admin.Advparameters.Feature'), | ||
'help' => $this->trans('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.', array(), 'Admin.Advparameters.Help'), | ||
'help' => $this->trans( | ||
'Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't split a translatable string like that, the parser will fail.
Please, remove the concatenation even if you did it for the line length.
<code>php_value post_max_size 20M</code> '. | ||
$this->trans('(click to open "Generators" page)', array(), 'Admin.Advparameters.Notification').'</a>'; | ||
$uploadErrorMessage = $this->trans( | ||
'The uploaded file exceeds the post_max_size directive in php.ini. If your server ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't split a translatable string like that, the parser will fail.
Please, remove the concatenation even if you did it for the line length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It stopped during the review to avoid spam.
It would be great to give names to the placeholders in translated strings. This is important to give a context to the translator, and may help us to remove the duplicated strings (started in #7840).
'available_fields' => $this->getAvailableFields(), | ||
'truncateAuthorized' => (Shop::isFeatureActive() && $this->context->employee->isSuperAdmin()) || !Shop::isFeatureActive(), | ||
'truncateAuthorized' => !(Shop::isFeatureActive()) || $this->context->employee->isSuperAdmin(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parentheses around Shop::isFeatureActive()
can be removed
|| $category->parent == $categoryId | ||
) { | ||
$this->errors[] = $this->trans('The category ID must be unique. It can\'t be the same as the one for the parent category (ID: %1$s).', | ||
array($categoryId ? $categoryId : 'null'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using a placeholder with the Symfony translator, your must name them (https://symfony.com/doc/current/components/translation/usage.html#message-placeholders). Then you affect this name a variable to be replaced in the translated string.
Here is the correct syntax to translate this string:
$this->errors[] = $this->trans('The category ID must be unique. It can\'t be the same as the one for the parent category (ID: %id%).',
array('%id%' => ($categoryId ? $categoryId : 'null')),
'Admin.Advparameters.Notification'
);
} | ||
$category->id_parent = $category->parent; | ||
} elseif (isset($category->parent) && is_string($category->parent)) { | ||
// Validation for parenting itself | ||
if ($validateOnly && isset($category->name) && ($category->parent == $category->name)) { | ||
$this->errors[] = $this->trans( | ||
'A category can\'t be its own parent. You should rename it (current name: %1$s).', | ||
$this->errors[] = $this->trans('A category can\'t be its own parent. You should rename it (current name: %1$s).', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about translation placeholder. Please use a variable name surrounded by %%
an add it in the second parameter.
); | ||
$this->errors[] = $this->trans('%1$s (ID: %2$s) cannot be saved', array( | ||
$categoryToCreate->name[$idLang], | ||
!empty($categoryToCreate->id) ? $categoryToCreate->id : 'null', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about translation placeholder. Please use a variable name surrounded by %%
an add it in the second parameter.
if ($category->link_rewrite == '') { | ||
$category->link_rewrite = 'friendly-url-autogeneration-failed'; | ||
$this->warnings[] = sprintf($this->trans('URL rewriting failed to auto-generate a friendly URL for: %s', array(), 'Admin.Advparameters.Notification'), $category->name[$default_language_id]); | ||
$this->warnings[] = $this->trans('URL rewriting failed to auto-generate a friendly URL for: %s', | ||
array($category->name[$defaultLanguageId]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about translation placeholder. Please use a variable name surrounded by %%
an add it in the second parameter.
$category_to_create->name[$default_language_id], | ||
(isset($category_to_create->id) && !empty($category_to_create->id))? $category_to_create->id : 'null' | ||
); | ||
$this->errors[] = $this->trans('%1$s (ID: %2$s) cannot be saved', array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about translation placeholder. Please use a variable name surrounded by %%
an add it in the second parameter.
if ($category['id_category']) { | ||
$product->id_category[] = (int)$category['id_category']; | ||
} else { | ||
$this->errors[] = $this->trans( | ||
'%s cannot be saved', | ||
$this->errors[] = $this->trans('%s cannot be saved', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about translation placeholder. Please use a variable name surrounded by %%
an add it in the second parameter.
'Invalid tag(s) (%s)', | ||
$isTagAdded = Tag::addTags($key, $product->id, $str, $this->multiple_value_separator); | ||
if (!$isTagAdded) { | ||
$this->addProductWarning(Tools::safeOutput($productData['name']), (int)$product->id, $this->trans('Invalid tag(s) (%s)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about translation placeholder. Please use a variable name surrounded by %%
an add it in the second parameter.
$image->delete(); | ||
$this->warnings[] = sprintf($this->trans('Error copying image: %s', array(), 'Admin.Advparameters.Notification'), $url); | ||
$this->warnings[] = $this->trans('Error copying image: %s', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about translation placeholder. Please use a variable name surrounded by %%
an add it in the second parameter.
@@ -2116,7 +2789,10 @@ protected function productImportOne($info, $default_language_id, $id_lang, $forc | |||
} | |||
|
|||
if ($error) { | |||
$this->warnings[] = sprintf($this->trans('Product #%1$d: the picture (%2$s) cannot be saved.', array(), 'Admin.Advparameters.Notification'), $image->id_product, $url); | |||
$this->warnings[] = $this->trans('Product #%1$d: the picture (%2$s) cannot be saved.', array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about translation placeholder. Please use a variable name surrounded by %%
an add it in the second parameter.
'lastname' => array('label' => $this->trans('Last name', array(), 'Admin.Global').'*'), | ||
'firstname' => array('label' => $this->trans('First name ', array(), 'Admin.Global').'*'), | ||
'address1' => array('label' => $this->trans('Address', array(), 'Admin.Global').'*'), | ||
'lastname' => array('label' => $this->trans('Last name', array(), 'Admin.Global') . '*'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it behave in RTL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe @maximebiloe could answer this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not as expected. I found several part of text which needs to be updated (in another PR).
!$regenerate | ||
)) { | ||
// TODO : insert translation placeholder here | ||
$this->warnings[] = $manufacturer->image . ' ' . $this->trans('cannot be copied.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a variable here too
$imgWasCopied = AdminImportController::copyImg($store->id, null, $store->image, 'stores', !$regenerate); | ||
if (!$imgWasCopied) { | ||
$this->warnings[] = $store->image . ' ' | ||
. $this->trans('cannot be copied.', array(), 'Admin.Advparameters.Notification'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be a full sentence with a variable.
Pushed fixes according to review comments. |
Hello @LittleBigDev, this need to be rebased (and probably validated again by @Quetzacoalt91 ?) Mickaël |
. $generatorsPageMessage | ||
. '</a>'; | ||
|
||
$_FILES['file']['error'] = $uploadErrorMessage . $directiveExample; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ach, I didn't see this line. For the RTL languages, this will need to be merged in a single string to translate (in another PR).
/** | ||
* Initializes import toolbar (for import display only) | ||
* | ||
* @return void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line to be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
'lastname' => array('label' => $this->trans('Last name', array(), 'Admin.Global').'*'), | ||
'firstname' => array('label' => $this->trans('First name ', array(), 'Admin.Global').'*'), | ||
'address1' => array('label' => $this->trans('Address', array(), 'Admin.Global').'*'), | ||
'lastname' => array('label' => $this->trans('Last name', array(), 'Admin.Global') . '*'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not as expected. I found several part of text which needs to be updated (in another PR).
// If nothing to fill, just get out ("0" string is NOT nothing). | ||
if (empty($data) && $data !== '0') { | ||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the first check was made before to handle the multilang case, and now this is an check which returns if the value is empty or equals 0.
Did you test that part? I'm afraid that would have some consequence on the feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I xDebugged it, and in any case, when data is empty, nothing is filled
Configuration::get('PS_HOME_CATEGORY'), | ||
Configuration::get('PS_ROOT_CATEGORY') | ||
); | ||
$categoryId = !empty($info['id']) ? (int)$info['id'] : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By looking at the next lines of this function, and the calls to new Category, I wonder if you should not set null
if the $info['id'] is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
|
||
if (!$shop_is_feature_active) { | ||
if (!$shopIsFeatureActive) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that's too much. ;)
But in that case, we have:
if ($shopIsFeatureActive) {
[...]
if (!$shopIsFeatureActive) {
}
}
Which cannot happen.
Removing this test and the line after ($info['shop'] = 1;
) is enough
$moreStep = 0 | ||
) { | ||
if (!is_array($crossStepsVariables)) { | ||
$crossStepsVariables = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with the suggested change.
But I wonder if array &$crossStepsVariables = array(),
would work as well and would fit better to our need.
) { | ||
$categoryToCreate->link_rewrite = AdminImportController::createMultiLangField( | ||
$categoryLinkRewrite | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it now in the test?
if ($taxRate < 0 || $taxRate > 100) { | ||
$this->errors[] = $this->trans('Tax rate (%rate%) is not valid (at line %line%).', array( | ||
'%rate%' => $taxRate, | ||
'%line%' => $currentLine + 1, | ||
$this->trans('Format: Between 0 and 100', array(), 'Admin.Advparameters.Notification') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In both case, it seems $this->trans('Format: Between 0 and 100', array(), 'Admin.Advparameters.Notification')
is never displayed
- "if" statements arrangement - SQL query strings arrangement - php code sniffer warnings
I didn't refacto the visible symbols (public, static...)
…rans(" and the whole translated string need to be on the same line). PSR broken rules are intended.
Hi @Quetzacoalt91 , I tried to address all your comments but after the rebase, I wasn't able to find the related code and/or to understand your suggestions. Could you please check it again ? EDIT : and maybe we should use Reviewable for such a big review ? |
This change is