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

Proxy code generation does not generate classes #35252

Closed
5 tasks
DmitryFurs opened this issue Mar 31, 2022 · 8 comments · Fixed by #37434
Closed
5 tasks

Proxy code generation does not generate classes #35252

DmitryFurs opened this issue Mar 31, 2022 · 8 comments · Fixed by #37434
Assignees
Labels
Area: Framework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@DmitryFurs
Copy link
Contributor

DmitryFurs commented Mar 31, 2022

Preconditions (*)

  1. Magento Commerce 2.4.3-p1
  2. PRODUCTION mode (!important)

Steps to reproduce (*)

  1. Create a new module
  2. Add the file etc/adminhtml/di.xml with content in which the proxy arguments have line breaks at the end
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Amasty\Oaction\Model\Action\ActionModifierProvider">
        <arguments>
            <argument name="modifiers" xsi:type="array">
                <item name="amasty_oaction_orderattr" xsi:type="object">
                    Amasty\Oaction\Model\Action\Modifier\OrderAttributesModifier\Proxy
                </item>
                <item name="pdfshipments_order" xsi:type="object">
                    Amasty\Oaction\Model\Action\Modifier\PrintPackingSlipsModifier\Proxy
                </item>
            </argument>
        </arguments>
    </type>
    <type name="Amasty\Oaction\Model\Command\Pdf\PdfCollectorResolver">
        <arguments>
            <argument name="collector" xsi:type="object">
                Amasty\Oaction\Model\Command\Pdf\PdfCollector\ZipCollector\Proxy
            </argument>
        </arguments>
    </type>
</config>
  1. Set production mode
  2. run the setup:di:compile command
  3. Check the generated/code folder for Amasty\Oaction\Model\Action\Modifier\OrderAttributesModifier\Proxy and Amasty\Oaction\Model\Action\Modifier\PrintPackingSlipsModifier\Proxy
  4. Check the generated/metadata folder for generated/metadata/adminhtml.php content

Expected result (*)

  1. Proxy files were successfully created after compilation
  2. Factory files have been successfully created after compilation

Actual result (*)

  1. Proxy files are missing
  2. In my case, there is even an error when trying to open the admin panel
Class Amasty\\Oaction\\Model\\Action\\Modifier\\OrderAttributesModifier\\Proxy does not exist

#1 Magento\\Framework\\Code\\Reader\\ClassReader->getConstructor() called at [vendor\/magento\/framework\/ObjectManager\/Definition\/Runtime.php:54],,,
#2 Magento\\Framework\\ObjectManager\\Definition\\Runtime->getParameters() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/Compiled.php:100]
#3 Magento\\Framework\\ObjectManager\\Factory\\Compiled->create() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/Compiled.php:150]
#4 Magento\\Framework\\ObjectManager\\Factory\\Compiled->get() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/Compiled.php:125]
#5 Magento\\Framework\\ObjectManager\\Factory\\Compiled->parseArray() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/Compiled.php:86]
#6 Magento\\Framework\\ObjectManager\\Factory\\Compiled->create() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/Compiled.php:150]
#7 Magento\\Framework\\ObjectManager\\Factory\\Compiled->get() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/Compiled.php:79]
#8 Magento\\Framework\\ObjectManager\\Factory\\Compiled->create() called at [vendor\/magento\/framework\/ObjectManager\/ObjectManager.php:70]
#9 Magento\\Framework\\ObjectManager\\ObjectManager->get() called at [vendor\/magento\/framework\/Interception\/PluginList\/PluginList.php:174]
#10 Magento\\Framework\\Interception\\PluginList\\PluginList->getPlugin() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:144]
#11 Magento\\Ui\\Config\\Reader\\Interceptor->Magento\\Framework\\Interception\\{closure}() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:153]
#12 Magento\\Ui\\Config\\Reader\\Interceptor->___callPlugins() called at [generated\/code\/Magento\/Ui\/Config\/Reader\/Interceptor.php:23]
#13 Magento\\Ui\\Config\\Reader\\Interceptor->read() called at [vendor\/magento\/module-ui\/Config\/Data.php:102]
#14 Magento\\Ui\\Config\\Data->initData() called at [vendor\/magento\/module-ui\/Config\/Data.php:136]
#15 Magento\\Ui\\Config\\Data->get() called at [vendor\/magento\/framework\/View\/Layout\/Reader\/UiComponent.php:100]
#16 Magento\\Framework\\View\\Layout\\Reader\\UiComponent->interpret() called at [vendor\/magento\/framework\/View\/Layout\/ReaderPool.php:105]
#17 Magento\\Framework\\View\\Layout\\ReaderPool->interpret() called at [vendor\/magento\/framework\/View\/Layout\/Reader\/Container.php:84]
#18 Magento\\Framework\\View\\Layout\\Reader\\Container->interpret() called at [vendor\/magento\/framework\/View\/Layout\/ReaderPool.php:105]
#19 Magento\\Framework\\View\\Layout\\ReaderPool->interpret() called at [vendor\/magento\/framework\/View\/Page\/Config\/Reader\/Body.php:68]
#20 Magento\\Framework\\View\\Page\\Config\\Reader\\Body->interpret() called at [vendor\/magento\/framework\/View\/Layout\/ReaderPool.php:105]
#21 Magento\\Framework\\View\\Layout\\ReaderPool->interpret() called at [vendor\/magento\/framework\/View\/Layout.php:346]
#22 Magento\\Framework\\View\\Layout->generateElements() called at [generated\/code\/Magento\/Framework\/View\/Layout\/Interceptor.php:32]
#23 Magento\\Framework\\View\\Layout\\Interceptor->generateElements() called at [vendor\/magento\/framework\/View\/Layout\/Builder.php:129]
#24 Magento\\Framework\\View\\Layout\\Builder->generateLayoutBlocks() called at [vendor\/magento\/framework\/View\/Page\/Builder.php:65]
#25 Magento\\Framework\\View\\Page\\Builder->generateLayoutBlocks() called at [vendor\/magento\/framework\/View\/Layout\/Builder.php:65]
#26 Magento\\Framework\\View\\Layout\\Builder->build() called at [vendor\/magento\/framework\/View\/Page\/Config.php:224]
#27 Magento\\Framework\\View\\Page\\Config->build() called at [vendor\/magento\/framework\/View\/Page\/Config.php:237]
#28 Magento\\Framework\\View\\Page\\Config->publicBuild() called at [vendor\/magento\/framework\/View\/Result\/Page.php:244]
#29 Magento\\Framework\\View\\Result\\Page->render() called at [vendor\/magento\/framework\/View\/Result\/Layout.php:171]
#30 Magento\\Framework\\View\\Result\\Layout->renderResult() called at [generated\/code\/Magento\/Backend\/Model\/View\/Result\/Page\/Interceptor.php:23]
#31 Magento\\Backend\\Model\\View\\Result\\Page\\Interceptor->renderResult() called at [vendor\/magento\/framework\/App\/Http.php:120]
#32 Magento\\Framework\\App\\Http->launch() called at [vendor\/magento\/framework\/App\/Bootstrap.php:264]
#33 Magento\\Framework\\App\\Bootstrap->run() called at [pub\/index.php:29]

Discovery

When production mode is set, code generation is performed only during setup:di:compile.

After code generation, Proxy and Factory files are missing because \Magento\Setup\Module\Di\Code\Scanner\XmlScanner::collectEntities() and \Magento\Setup\Module\Di\Code\Scanner\XmlScanner::scanFactories() use not quite correct regular expressions that want to meet the value without extra whitespace characters after Proxy and Factory

At the same time, these arguments were successfully added to the metadata file generated/metadata/adminhtml.php

image

If you use developer mode, then after compiling di, there is also no proxy files, but when accessing the website, these classes are generated on the fly, which avoids errors.

Most likely, this problem can be fixed by changing regexp, which will allow you to use whitespace characters at the end, or by replacing this regulatory expression with a suitable xpath expression.

$regex = '/^(.*)\\\(.*)Proxy$/'; -> $regex = '/^(.*)\\\(.*)Proxy(\s*)$/';
$regex = '/^(.*)Factory$/'; -> $regex = '/^(.*)Factory(\s*)$/';

When I reformat di.xml without line breaks, then everything starts working correctly.

From image

To image

But the use of line breaks in the arguments is not prohibited in any way


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Mar 31, 2022

Hi @DmitryFurs. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-community-project m2-community-project bot added this to Ready for Confirmation in Issue Confirmation and Triage Board Mar 31, 2022
@DmitryFurs DmitryFurs changed the title Proxy code generation for does not generate classes Proxy code generation does not generate classes Mar 31, 2022
@engcom-Hotel engcom-Hotel added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Jul 5, 2022
@engcom-Charlie engcom-Charlie self-assigned this Jul 20, 2022
@m2-assistant
Copy link

m2-assistant bot commented Jul 20, 2022

Hi @engcom-Charlie. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@m2-assistant
Copy link

m2-assistant bot commented Jul 20, 2022

Hi @engcom-Hotel. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Hotel
Copy link
Contributor

Hello @DmitryFurs,

Thanks for the report and collaboration!

We have tried to reproduce the issue in Magento 2.4-develop branch and followed the following steps to replicate the issue:-

  1. Created a custom module named ‘Magento_CustomModule’
  2. In the etc folder of the module created a di.xml with this content
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
   <type name="Magento\Catalog\Model\ProductLink\CollectionProvider">
       <arguments>
           <argument name="providers" xsi:type="array">
               <item name="crosssell" xsi:type="object">
                       Magento\Catalog\Model\ProductLink\CollectionProvider\Crosssell\Proxy
               </item>
               <item name="upsell" xsi:type="object">Magento\Catalog\Model\ProductLink\CollectionProvider\Upsell\Proxy</item>
               <item name="related" xsi:type="object">Magento\Catalog\Model\ProductLink\CollectionProvider\Related\Proxy</item>
           </argument>
       </arguments>
   </type>
   <type name="Magento\Catalog\Model\Product">
       <arguments>
           <argument name="catalogProductStatus" xsi:type="object">
           Magento\Catalog\Model\Product\Attribute\Source\Status\Proxy
           </argument>
           <argument name="productLink" xsi:type="object">
           Magento\Catalog\Model\Product\Link\Proxy
           </argument>
       </arguments>
   </type>
</config>
  1. Set the Production mode on
  2. Deleted the generated folder from the root and run the command bin/magento setup:di:compile
  3. In the generated folder, the Proxy file is only generated for proxy arguments that are given without the line break and not for the arguments that are given with a line break.
    image

Hence this issue is reproducible and confirmed.

Thanks

@engcom-Hotel engcom-Hotel added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Area: Framework labels Jul 20, 2022
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Confirmed in Issue Confirmation and Triage Board Jul 20, 2022
@engcom-Hotel engcom-Hotel added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Issue: ready for confirmation labels Jul 20, 2022
@m2-community-project m2-community-project bot added this to Dev In Progress in High Priority Backlog Jul 20, 2022
@maqlec
Copy link
Contributor

maqlec commented Mar 20, 2023

I can confirm that issue and I can add that Magento must be in production mode or must be without installation (eg. config.php is present but env.php is not). Im using this configuration for generate classes before create classmap optimization and now its causes error. Im counting on fast fix

@ihor-sviziev
Copy link
Contributor

We also started noticing this isuee. I created Pull Request that fixes this issue #37434

@engcom-Echo engcom-Echo removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Aug 28, 2023
@engcom-Echo engcom-Echo added the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Aug 28, 2023
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-9388 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented Aug 28, 2023

✅ Confirmed by @engcom-Echo. Thank you for verifying the issue.
Issue Available: @engcom-Echo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Development

Successfully merging a pull request may close this issue.

7 participants