-
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
Fix customer address form #17526
Fix customer address form #17526
Conversation
return []; | ||
} | ||
|
||
$states = State::getStatesByIdCountry($countryId, $resolvedOptions['only_active']); | ||
$choices = []; |
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.
$choices
must be decalred above. If there is an exception in new Country
, $choices
will be undefined
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 get what you mean it would be cleaner, but it shoudn't be a problem here since an exception is thrown in the catch block It will never reach the return $choices;
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 if it's not a PrestaShopException
🤔
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.
Then it's not caught by this class and either the process crashes or it's caught by something higher In both cases it still won't reach the return
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.
Could you just move the return $choices
after the foreach to have a cleaner code :D 🙏
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.
see my comment
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.
Nothing blocking for me But I always have concerns regarding this "Address" feature, it is mixed/common with brand addresses, manufacturer addresses But each one has been developed separately, so we fix bugs separately as well And the improvement are never ported from one to another
Since you said some improvement should be made in 178 about the customer address, maybe it would be worth refactoring all the address management so all rules are clear everywhere?
@@ -46,7 +46,7 @@ final class SetRequiredFieldsForAddressHandler implements SetRequiredFieldsForAd | |||
*/ | |||
public function handle(SetRequiredFieldsForAddressCommand $command) | |||
{ | |||
$address = new Address(); | |||
$address = new CustomerAddress(); |
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.
One question, how does it work for brand or manufacturer address? Because I believe they all share the same Address
class But using CustomerAddress
here means it's only dedicated to customer addresses, but not the other ones? Then shouldn't the handler name and namespace reflect this limitation?
=> SetRequiredFieldsForCustomerAddressHandler::handle(SetRequiredFieldsForCustomerAddressCommand $command)
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.
Only customer address is affected 🤷♂️
Maybe as you say it could be reworked in 178.
It came from legacy that in db required_fields are saved by classname of the object (in this case CustomerAddress. By providing Address it doesn't work at all).
return []; | ||
} | ||
|
||
$states = State::getStatesByIdCountry($countryId, $resolvedOptions['only_active']); | ||
$choices = []; |
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 get what you mean it would be cleaner, but it shoudn't be a problem here since an exception is thrown in the catch block It will never reach the return $choices;
moved var declaration up before try-catch |
Related issue: #17647 |
48c5894
to
e0ccead
Compare
@jolelievre, @PierreRambaud addressed. |
4e9edb7
to
90283c0
Compare
I tested again, with France and Spain addresses, both BO & FO are OK (except the "issue" which was already there in 176) ! Thanks @zuk3975 :) |
Thank you, doing a great job! |
Hello @zuk3975, thanks for your contribution, would you mind to rebase your pull request? Thanks |
bc20fdb
to
8657aab
Compare
Thanks @zuk3975 |
This change is