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 AddressController.php #34152
Fix AddressController.php #34152
Conversation
metacreo
commented
Oct 3, 2023
•
edited
edited
Questions | Answers |
---|---|
Branch? | 8.1.x |
Description? | Duplicate function FillWith call in AddressController.php. Address form filled two times. First time normal, second time with empty country. If default country is US, form shows needed states to enter. Fix bugs: #35013, #34080, #33991 |
Type? | bug fix |
Category? | FO |
BC breaks? | no |
Deprecations? | no |
How to test? | Indicate how to verify that this change works as expected. |
UI Tests | Please run UI tests and paste here the link to the run. Read this page to know why and how to use this tool.. |
Fixed issue or discussion? | Fixes #{issue number here}, Fixes #{another issue number here}, Fixes https://github.com/PrestaShop/PrestaShop/discussions/ {#35013 #34080 #33991} |
Hello @metacreo! This is your first pull request on the PrestaShop project. Thank you, and welcome to this Open Source community! |
Hi, thanks for this contribution! I found some issues with the Pull Request description:
Would you mind having a look at it? This will help us understand how interesting your contribution is, thank you very much! (Note: this is an automated message, but answering it will reach a real human) |
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 good, but can you tell us where the address form is already filled in the code ? thanks
@mflasquin
CustomerAddressForm.php
As mentioned above public function fillWith(array $params = []) called twice. Second call destroys country->id
result: Fix: |
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.
LGTM
Hello @metacreo It looks legit. What I suggest now:
|
rebase ok, but I don`t known how to help QA. They cannot reproduce, although I reproduced on 3 production servers and on demo. There no additional steps. Just go to my account and click Update. |
Hi @metacreo, if it happens only in some browsers, I don't know how JS error is related to removing something on PHP side? |
@Hlavtox Hello. Ok. let to try see what shows dump where no bug in form... Edit: |
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.
thank you for your contribution @metacreo 👍
Would you mind changing the base of the PR (setting the base as 8.1.x instead of develop)
Please wait. After 8.1.1 -> 8.1.2 This fix not works. |
Initialize address if an id exists and prevent fill form with default country second time. If this is only form request. Add param id_country for CustomerAddressForm class.
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.
Need review. Basically need serious rework of this functions in CustomerAddressForm, AbstractForm and AddressControllerCore.
In order to not touch a lot of code, the only solution for now is this.
Optimisation
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.
Small optimization. Checked on 8.1.1 and 8.1.2. My account address edit, add. Checkout process edit, add.
Seems to final of PR ;) |
if ($id_address) { | ||
$this->address_form->loadAddressById($id_address); | ||
// If this is only form request. Adding param id_country for CustomerAddressForm class. |
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 looks like a hack honestly, I'll have to look deeper since I'm not sure if we should have to do that there
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.
@kpodemski no... this param needs only for correct form fill.
@kpodemski |
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.
@Hlavtox Issue reproduced in #33991 See comment 1729389392 Just QA does not have proper qualification to reproduce this bug. |
@metacreo I think I managed to reproduce the issue, I will get back to you. |
@Hlavtox, I'm trying to do some cleaning in PRs, did you really manage to reproduce the issue? 🤔 |
@kpodemski Well, somehow - try it #34080 (comment) |
Screencast.from.28.12.2023.16.30.36.webm |
No need second 0 param in getValue, because (int).
Fix mistake
@metacreo Could you please check, if the address form uses geolocation when creating new address? I think that by moving the fillWith call, this logic is not processed at all.
|
Tested. This logic not depend on function fillWith in real called 3 times in original... Detection works ok, but you need all lang-pack to be installed for "auto" country... and one more comment: this is not "geolocation", this functions use browser headers 🙂 |
@Hlavtox I use Moz FF. CustomerAddressForm.php
Try move @Hlavtox we need exactly move I don’t understand why you are going into the weeds, starting to rewrite code that has been working perfectly for many years |
@ChillCode hello, |
I found out where this whole story came from #27187 |