-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Framework Escaper - remove direct Object Manager usage #19310
Framework Escaper - remove direct Object Manager usage #19310
Conversation
Hi @maciejslawik. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
Thanks for your contribution @maciejslawik , however adding a constructor is backward incompatible change - it will result in issue on instances where this class is instantiated or extended. Please see https://devdocs.magento.com/guides/v2.0/contributor-guide/backward-compatible-development/ |
@sivaschenko Alright, I understand. |
\Psr\Log\LoggerInterface $logger | ||
) { | ||
$this->escaper = $escaper; | ||
$this->logger = $logger; |
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.
Such change is backward-incompatible.
Please inject new dependencies in backward-compatible manner: https://devdocs.magento.com/guides/v2.3/contributor-guide/backward-compatible-development/#adding-a-constructor-parameter
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 added null as default to keep all instances that are instantiated directly unbroken.
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.
@maciejslawik please remove private deprecated methods as you did before and add property initialization into constructor (as in devdoc I mentioned).
Hi @sivaschenko, thank you for the review. |
@maciejslawik thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository. |
\Psr\Log\LoggerInterface $logger | ||
) { | ||
$this->escaper = $escaper; | ||
$this->logger = $logger; |
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.
@maciejslawik please remove private deprecated methods as you did before and add property initialization into constructor (as in devdoc I mentioned).
@orlangur I pushed changes that should reflect your request. |
@maciejslawik great! Changes look good now, please rebase against latest |
@orlangur Rebase has been done. |
Hi @orlangur, thank you for the review. |
Hi @maciejslawik. Thank you for your contribution. |
Hi @maciejslawik unfortunately we had to revert this PR changes because of backward compatibility concerns: |
@sivaschenko mentioned use case does not seem valid to me. It means any other similar addition of dependency is backward incompatible. First of all, we do not recommend inheritance. In the second place, it is not correct to not call parent constructor. |
@orlangur in this specific case there is a high risk that if the class was extended the parent constructor was not called as there was no constructor implementation in place. |
@slitvyachenko did somebody really extend this class having some troubles? I believe we should follow https://devdocs.magento.com/guides/v2.3/contributor-guide/backward-compatible-development/ and nothing more than that. If doc is not sufficient, it should be extended with your note - "dependencies MUST NOT be added in case there were none before" or something. |
@orlangur I believe that change is falling into the category of "adding public method" rather than adding more dependencies (each class does have a constructor, but in this case, as the constructor was not explicitly defined, it would have been treated as it does not exist). |
Description (*)
This PR removes direct ObjectManager calls from
\Magento\Framework\Escaper
. Additionally, it allows for injecting different implementations of\Psr\Log\LoggerInterface
via the constructor.Manual testing scenarios (*)
Contribution checklist (*)