Skip to content

Change the "main" function in NonComposerComponentRegistration.php to closure to avoid naming conflicts. #21831

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

Conversation

Hailong
Copy link
Member

@Hailong Hailong commented Mar 19, 2019

Description (*)

There is a function definition "main" in app/etc/NonComposerComponentRegistration.php, which is used by autoload. This change is to use a closure instead, to avoid naming conflicts.

Here is one scenario that the naming conflict happens:

  1. I installed Magento 2.3 with composer as the document recommends:

    composer create-project --repository=https://repo.magento.com/ magento/project-community-edition <install-directory-name>
    
  2. While later I need some new patches from the 2.3-develop branch, so I decided to change the Magento source to GitHub repository, my changes to the composer.json file looks like this:

    {
        "name": "magento/project-community-edition",
        ...
        "require": {
            ...
            "magento/magento2ce": "dev-2.3",
            ...
        },
        "replace": {
            "magento/magento2-base": "*"
        },
        ...
    }
    

    (There is also a change to the magento/magento2ce composer.json to add the "map arrays" accordingly)

  3. Now since both the main project and magento/magento2ce would need to load the app/etc/NonComposerComponentRegistration.php, there will be an error says "Cannot redeclare ..."

Change the main function definition to closure would definitely resolve this issue.

Fixed Issues (if relevant)

N/A

Manual testing scenarios (*)

  1. Create a Magento 2.3 project installation.
  2. Update composer.json to reference Magento core code from GitHub repository.
  3. Make sure the NonComposerComponentRegistration.php is loaded from both project directory and magento/magento2ce vendor package directory and no conflict during autoload process.

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)

@magento-engcom-team
Copy link
Contributor

Hi @Hailong. 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 PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

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

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Mar 19, 2019

CLA assistant check
All committers have signed the CLA.

@ghost ghost assigned sidolov May 24, 2019
@magento-engcom-team
Copy link
Contributor

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

@ghost
Copy link

ghost commented Jun 19, 2019

@magento-cicd2 unfortunately, only members of the maintainers team are allowed to unassign developers from the pull request

@engcom-Foxtrot
Copy link
Contributor

@magento run all tests

@magento-engcom-team magento-engcom-team merged commit 92b83c0 into magento:2.3-develop Aug 8, 2019
@m2-assistant
Copy link

m2-assistant bot commented Aug 8, 2019

Hi @Hailong, 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.

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.4 milestone Aug 8, 2019
magento-engcom-team pushed a commit that referenced this pull request Aug 8, 2019
…ration.php to closure to avoid naming conflicts. #21831
@sidolov sidolov added the Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests label Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests Progress: accept Release Line: 2.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants