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

setup:install fails if console command that injects Customer model class exists #34220

Closed
1 of 5 tasks
Revengance1024 opened this issue Oct 1, 2021 · 8 comments
Closed
1 of 5 tasks
Assignees
Labels
Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: needs update Additional information is require, waiting for response

Comments

@Revengance1024
Copy link

Revengance1024 commented Oct 1, 2021

Preconditions (*)

  1. Magento Community 2.4.2 (possibly earlier versions affected)
  2. Custom console command that has Customer model (directly or indirectly) injected in constructor
  3. Database tables not yet created (install hasn't been run yet)

Steps to reproduce (*)

  1. Create custom module
  2. Add custom console command that injects \Magento\Customer\Model\ResourceModel\Customer (directly or via another class, e.g. CustomerRepository)
  3. Run setup:install. For example:
setup:install
--base-url=https://local.magento.com/
--db-host=127.0.0.1
--db-name=magento
--db-user=magento
--db-password=magento
--admin-firstname=Admin
--admin-lastname=User
--admin-email=example@example.com
--admin-user=admin
--admin-password=admin123
--language=en_US
--currency=USD
--timezone=America/Chicago
--use-rewrites=1
-vvv

Expected result (*)

  1. setup:install completes without issues

Actual result (*)

  1. setup:install fails during step 4 (Installing database schema) with error
[Magento\Framework\DB\Adapter\TableNotFoundException (1146)]                                                                                                                
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento.eav_entity_type' doesn't exist, query was: SELECT `main_table`.* FROM `eav_entity_type` AS `main_table`

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 Oct 1, 2021

Hi @Revengance1024. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

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

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

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

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

Please, add a comment to assign the issue: @magento I am working on this


⚠️ 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, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

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

@Revengance1024
Copy link
Author

Revengance1024 commented Oct 1, 2021

This issue is caused by \Magento\Customer\Model\ResourceModel\Customer calling $this->setType('customer'); in constructor (vendor/magento/module-customer/Model/ResourceModel/Customer.php:87).

For anyone currently facing this issue there are 2 workarounds:

  • Disable the custom module before install, run install, re-enable the module and run setup:upgrade
  • Add dependencies that directly or indirectly inject Customer model as proxies. For example, if Foo/Bar/Console/Command/TestCommand has \Magento\Customer\Api\CustomerRepositoryInterface (argument name customerRepository) as a dependency (CustomerRepository has Customer Resource Model as a dependency), then you could add this in di.xml
    <type name="Foo/Bar/Console/Command/TestCommand">
        <arguments>
            <argument name="customerRepository" xsi:type="object">Magento\Customer\Api\CustomerRepositoryInterface\Proxy</argument>
        </arguments>
    </type>

@engcom-Hotel engcom-Hotel self-assigned this Oct 8, 2021
@m2-assistant
Copy link

m2-assistant bot commented Oct 8, 2021

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 @Revengance1024,

Thanks for posting this issue!

But can you please let us know any specific use case to create a custom module before installing Magento?

Thanks

@engcom-Hotel engcom-Hotel added the Issue: needs update Additional information is require, waiting for response label Oct 11, 2021
@hostep
Copy link
Contributor

hostep commented Oct 11, 2021

@engcom-Hotel, here's a case:

We've recently build a platform that has the ability to quickly spin up a new Magento installation with a whole bunch of modules pre-installed. We don't want to first setup a clean Magento installation and in a second step install a bunch of modules. We want to do this in one step. This has worked fine in the past, Magento seems to have been build with this flow in mind, only in a few rare cases, we have to find workarounds for this sort of installation flow.

Also: with the way Magento is trying to go in the future with trying to separate more and more modules from the core, should we expect those separate modules to also only work when we install them after first setting up a vanilla Magento installation? Or should we expect them to work correctly when installing them before we initialise Magento for the first time? I would really hope for the second option here, right?

Also: all those extra modules that come with Adobe Commerce, they also just work before initialising Magento for the first time, right? So why can't this also be the case for 3rd party modules?

@Revengance1024
Copy link
Author

@engcom-Hotel

Our specific case is this: While creating the magento store there haven't been any issues because when we needed to setup an instance (locally or for testing) we would use a database dump and skip installing.
However, now that it's nearing completion we are setting up a production instance. Since we don't need any testing data we are trying to run a clean install which is failing.

We don't really need those custom modules during install, but there isn't an easy way to disable all added modules, nor there is a way to tell which module is causing the issue without using a debugger.

@engcom-Hotel
Copy link
Contributor

Hello @Revengance1024,

We have tried to reproduce the issue on Magento 2.4-develop, but we are getting another error, not the same you are getting. Please have a look at the below screenshot:
error

Please find attached the custom module, we have made in order to reproduce the issue:
Magz_ConsoleCmd.tar.gz

Please let us know in case we have missed any steps in order to reproduce the issue.

Thanks

@engcom-Hotel engcom-Hotel added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Oct 21, 2021
@engcom-Hotel
Copy link
Contributor

Dear @Revengance1024,

We have noticed that this issue has not been updated for a period of 14 Days. Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket or reopen this ticket if you need more assistance on this.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: needs update Additional information is require, waiting for response
Projects
None yet
Development

No branches or pull requests

3 participants