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

Prompt for enabling module. #72

Open
vyasamit2007 opened this issue Dec 28, 2020 · 3 comments · May be fixed by #119
Open

Prompt for enabling module. #72

vyasamit2007 opened this issue Dec 28, 2020 · 3 comments · May be fixed by #119
Assignees
Labels
enhancement New feature or request

Comments

@vyasamit2007
Copy link
Collaborator

No description provided.

@vyasamit2007 vyasamit2007 added the enhancement New feature or request label Dec 28, 2020
@omkar-pednekar
Copy link
Collaborator

Hello @gauravgoyal / @vyasamit2007 ,

I have added a user interaction in command where user can enable module while running command. But I am facing issue in this.
I am enabling required module in Validation phase. After enabling module, we are not getting entity type and handlers provided by enabled module in command.
image
If we run same command again, then are able to run it without any error.
image

@omkar-pednekar
Copy link
Collaborator

Here issue is, all required services, we are injecting through DI. Before validation phase, all required services gets instantiated. So, in command, when we try to load storage of newly installed entity through module like Media or Paragraph, entityTypeManager is not able to find it as service object was created before installing module. It is an old copy of service object.
I tried below approaches:

  1. Injecting service_container instead of entity_type.manager. Get required service from container wherever needed. This also returning old copy.
  2. Lazy loading service. https://www.webomelette.com/lazy-loaded-services-drupal-8
  3. Flushing entity cache with $this->entityTypeManager->useCaches(FALSE).
  4. Clearing cached definitions with $this->entityTypeManager->clearCachedDefinitions()
  5. Clearing complete cache in validation hook after enabling module.
  6. Adding service as Optional dependency

I asked this on our internal slack but not received problem solving response.
Ref: https://acquia.slack.com/archives/G01772FE4KU/p1615543619013200

@omkar-pednekar omkar-pednekar added the help wanted Extra attention is needed label Mar 13, 2021
@omkar-pednekar
Copy link
Collaborator

@gauravgoyal / @vyasamit2007 ,

We can enable required modules and terminate command. User can can manually run command again to process entities. I have updated code in PR. Please review.

@omkar-pednekar omkar-pednekar removed the help wanted Extra attention is needed label Mar 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants