Skip to content
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 type hint of customer-data updateSectionId parameters #16115

Merged
merged 4 commits into from
Oct 10, 2018
Merged

Fix type hint of customer-data updateSectionId parameters #16115

merged 4 commits into from
Oct 10, 2018

Conversation

Vinai
Copy link
Contributor

@Vinai Vinai commented Jun 14, 2018

Description

The type hint wrongly indicates the parameter should be a number, where in fact it is a boolean.
It is passed through to the server side to the controller action
\Magento\Customer\Controller\Section\Load::execute()
where it is cast to a bool and passed as the $updateIds parameter to
\Magento\Customer\CustomerData\SectionPool::getSectionsData(),
and from there as the boolean parameter $forceUpdate to the \Magento\Customer\CustomerData\Section\Identifier::initMark()` method.

This PR introduces no backward incompatibilities, it only fixes the type
hint to make the code more readable and improve compatibility with static
code analysis tools.

Fixed Issues (if relevant)

I didn't bother first opening an issue about this small change.

Manual testing scenarios

None, since it's only a comment change.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

The typehint wrongly indicates the parameter should be a number, where
in fact it is a boolean.
It is passed through to the server side to the controller action
\Magento\Customer\Controller\Section\Load::execute()
where it is cast to a boolean and passed as the $updateIds parameter to
\Magento\Customer\CustomerData\SectionPool::getSectionsData()
and from there as the boolean parameter $forceUpdate to the
\Magento\Customer\CustomerData\Section\Identifier::initMark() method.

This PR introduces no backward incompatibilities, it only fixes the type
hint to make the code more readable and improve compatibility with static
code analysis tools.
@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Jun 14, 2018

CLA assistant check
All committers have signed the CLA.

@magento-engcom-team
Copy link
Contributor

Hi @Vinai. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on Pull Request changes
  • @magento-engcom-team give me new test instance - deploy NEW test instance based on Pull Request changes
  • @magento-engcom-team give me {$VERSION} instance - deploy Vanilla Magento instance for Issue or Pull Request

For more details, please, review the Magento Contributor Assistant documentation

@Vinai
Copy link
Contributor Author

Vinai commented Jun 14, 2018

I already signed the contributor license agreement years ago.

@orlangur
Copy link
Contributor

@Vinai maybe CLA was changed? :) I had to re-sign few days ago as well.

Copy link
Contributor

@orlangur orlangur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getFromServer: function (sectionNames, updateSectionId) {
            var parameters;

            sectionNames = sectionConfig.filterClientSideSections(sectionNames);
            parameters = _.isArray(sectionNames) ? {
                sections: sectionNames.join(',')
            } : [];
            parameters['update_section_id'] = updateSectionId;

The code looks quite confusing currently. Yeah, I see that second parameter of reload() is true or false but it does not really help when you read the method code.

Could you please rename those into something like

parameters['is_section_id_update_required'] = isSectionIdUpdateRequired;

(I didn't check exact semantics, naming is up to you). I believe such change will not be a BC break as well.

@Vinai
Copy link
Contributor Author

Vinai commented Jun 16, 2018

I renamed the variable to be more intent revealng. The is or has prefix does not really work here, as it's not a state description, but rather a command. I chose forceNewSectionTimestamp since that is a name that clearly identifies the purpose and type of the parameter for me.

@Vinai
Copy link
Contributor Author

Vinai commented Jun 18, 2018

Why is the Travis build not starting? And it’s not only this PR...

@Vinai
Copy link
Contributor Author

Vinai commented Jun 22, 2018

For reference a copy of a chat on slack:

orlangur [8:23 AM]
I already looked into that PR
parameters['update_section_id'] = forceNewSectionTimestamp;
had a talk with core guys regarding BC and left part of this
what do you think about renamin request parameter as well?
according to my understanding it will not break anything, just will require additional request for section data once

Vinai Kopp [8:25 AM]
Well, wouldn’t a parameter name change be a bc break?
Personally I think it would be good to choose a more expressive name.
Any customizations that might use that parameter would break.

orlangur [8:26 AM]
there is no such explicit rule and in this case it will break only in rare chance of customization of this controller
so, please change parameter name as well

Vinai Kopp [8:27 AM]
Okay, will do.

@orlangur
Copy link
Contributor

Why is the Travis build not starting? And it’s not only this PR...

@Vinai no idea yet, Magento guys are aware of it.

@magento-engcom-team
Copy link
Contributor

Hi @orlangur, thank you for the review.
ENGCOM-2104 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

Hi @Vinai. Thank you for your contribution.
We will aim to release these changes as part of 2.2.8.
Please check the release notes for final confirmation.

Please, consider to port this solution to 2.3 release line.
You may use Porting tool to port commits automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants