Skip to content

Removed leading backslash in xml #26948

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

Closed
wants to merge 9 commits into from
Closed

Removed leading backslash in xml #26948

wants to merge 9 commits into from

Conversation

srsathish92
Copy link
Contributor

@srsathish92 srsathish92 commented Feb 20, 2020

Description (*)

Removed leading backslash in namespace & class in XML

xsi:type="object">\Magento\... xsi:type="string">\Magento\... xsi:type="const">\Magento\... <type name="\Magento\... type="\Magento\... <virtualType name="\Magento\... for="\Magento\...

is replaced to

xsi:type="object">Magento\.. xsi:type="string">Magento\... xsi:type="const">Magento\... <type name="Magento\... type="Magento\... <virtualType name="Magento\... for="Magento\...

Questions or comments

If any please let me know your feedback's

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 are green)

Resolved issues:

  1. resolves [Issue] Removed leading backslash in xml #29614: Removed leading backslash in xml

@m2-assistant
Copy link

m2-assistant bot commented Feb 20, 2020

Hi @srsathish92. 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 give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

Please test on test instance the cases that fails on functional tests, seems that your changes break functionality somehow. It requires additional debug to explain why

@ghost ghost dismissed ihor-sviziev’s stale review February 23, 2020 17:29

Pull Request state was updated. Re-review required.

@srsathish92
Copy link
Contributor Author

@magento give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @srsathish92. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @srsathish92, here is your new Magento instance.
Admin access: https://pr-26948.instances.magento-community.engineering/admin_ee88
Login: 490a6f0a Password: 62684c25c79d
Instance will be terminated in up to 3 hours.

ihor-sviziev
ihor-sviziev previously approved these changes Mar 2, 2020
@ghost ghost dismissed ihor-sviziev’s stale review March 2, 2020 11:50

Pull Request state was updated. Re-review required.

@ihor-sviziev
Copy link
Contributor

Waiting approval for SVC failure

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, thank you for the review.
ENGCOM-7013 has been created to process this Pull Request
✳️ @ihor-sviziev, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@ihor-sviziev ihor-sviziev added the Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests label Mar 2, 2020
@srsathish92
Copy link
Contributor Author

@magento run Semantic Version Checker

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@Den4ik
Copy link
Contributor

Den4ik commented Aug 3, 2021

I believe that Failed Semantic Version check could be ignored for ES module

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Aug 27, 2021

It seems like SVC failure should be fixed already magento/magento-semver#59
@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@ihor-sviziev
Copy link
Contributor

@sidolov, are we using latest version of the SVC checker? Feels like the issue should be resolved already

@sidolov
Copy link
Contributor

sidolov commented Aug 27, 2021

@ihor-sviziev according to the composer.json - we always use the latest released version of the package

@ihor-sviziev
Copy link
Contributor

Oh, I see that that commit wasn't added to release yet :(

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Oct 12, 2021

Hi @srsathish92,
I did additional research, and it seems like removing leading backslash from the XML files in general - is a good practice, but it might lead to unexpected issues during the upgrade.
Reason - in the XML - two nodes

    <type name="Magento\AdvancedSearch\Model\Client\ClientResolver">
        <arguments>
            <argument name="path" xsi:type="const">Magento\CatalogSearch\Model\ResourceModel\EngineInterface::CONFIG_ENGINE_PATH</argument>
            <argument name="scopeType" xsi:type="const">Magento\Store\Model\ScopeInterface::SCOPE_STORE</argument>
        </arguments>
    </type>

and

    <type name="\Magento\AdvancedSearch\Model\Client\ClientResolver">
        <arguments>
            <argument name="path" xsi:type="const">Some\Another\Path::CONFIG_ENGINE_PATH</argument>
        </arguments>
    </type>

Will be just merged to something like this (instead of overriding the value):

    <type name="Magento\AdvancedSearch\Model\Client\ClientResolver">
        <arguments>
            <argument name="path" xsi:type="const">Magento\CatalogSearch\Model\ResourceModel\EngineInterface::CONFIG_ENGINE_PATH</argument>
            <argument name="scopeType" xsi:type="const">Magento\Store\Model\ScopeInterface::SCOPE_STORE</argument>
        </arguments>
    </type>
    <type name="\Magento\AdvancedSearch\Model\Client\ClientResolver">
        <arguments>
            <argument name="path" xsi:type="const">Some\Another\Path::CONFIG_ENGINE_PATH</argument>
        </arguments>
    </type>

In this case, Magento will use only one of these sections that might lead to unexpected results.

It's a limitation of XML, so I think it's better not to touch these lines to prevent breaking backward compatibility rather than do this cleanup.
I'm closing this Pull Request.

Thank you so much for your contribution!

@m2-assistant
Copy link

m2-assistant bot commented Oct 12, 2021

Hi @srsathish92, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@Den4ik
Copy link
Contributor

Den4ik commented Oct 12, 2021

@ihor-sviziev Do you mean merge during prepare Magento release or merging of xml files during app execution?

@srsathish92
Copy link
Contributor Author

Hi @srsathish92, I did additional research, and it seems like removing leading backslash from the XML files in general - is a good practice, but it might lead to unexpected issues during the upgrade. Reason - in the XML - two nodes

    <type name="Magento\AdvancedSearch\Model\Client\ClientResolver">
        <arguments>
            <argument name="path" xsi:type="const">Magento\CatalogSearch\Model\ResourceModel\EngineInterface::CONFIG_ENGINE_PATH</argument>
            <argument name="scopeType" xsi:type="const">Magento\Store\Model\ScopeInterface::SCOPE_STORE</argument>
        </arguments>
    </type>

and

    <type name="\Magento\AdvancedSearch\Model\Client\ClientResolver">
        <arguments>
            <argument name="path" xsi:type="const">Some\Another\Path::CONFIG_ENGINE_PATH</argument>
        </arguments>
    </type>

Will be just merged to something like this (instead of overriding the value):

    <type name="Magento\AdvancedSearch\Model\Client\ClientResolver">
        <arguments>
            <argument name="path" xsi:type="const">Magento\CatalogSearch\Model\ResourceModel\EngineInterface::CONFIG_ENGINE_PATH</argument>
            <argument name="scopeType" xsi:type="const">Magento\Store\Model\ScopeInterface::SCOPE_STORE</argument>
        </arguments>
    </type>
    <type name="\Magento\AdvancedSearch\Model\Client\ClientResolver">
        <arguments>
            <argument name="path" xsi:type="const">Some\Another\Path::CONFIG_ENGINE_PATH</argument>
        </arguments>
    </type>

In this case, Magento will use only one of these sections that might lead to unexpected results.

It's a limitation of XML, so I think it's better not to touch these lines to prevent breaking backward compatibility rather than do this cleanup. I'm closing this Pull Request.

Thank you so much for your contribution!

@ihor-sviziev Did you tried the viceversa? What will be output? - If it is the same behaviour as aforementioned then we need to update the document somewhere.

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Oct 13, 2021

@srsathish92, basically the same result. The reason is pretty simple - at the time of XML merge, the nodes aren't getting merged, similar to PHP. After that, Magento trying to retrieve the data, and it's using the only one section

Example:

var_dump(array_merge(['\test' => 0], ['test' => 1]));

outputs

array(2) {
  ["\test"]=>
  int(0)
  ["test"]=>
  int(1)
}

not the

array(1) {
  ["test"]=>
  int(1)
}

@Den4ik
Copy link
Contributor

Den4ik commented Oct 14, 2021

@ihor-sviziev Could you little bit explain when you have time. One place where we have merging is config load. Are you see problems here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests Cleanup Component: multiple Partner: Ziffity partners-contribution Pull Request is created by Magento Partner Priority: P4 No current plan to fix. Fixing can be deferred as a logical part of more important work. Release Line: 2.4 Severity: S4 Affects aesthetics, professional look and feel, “quality” or “usability”.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue] Removed leading backslash in xml
9 participants