-
Notifications
You must be signed in to change notification settings - Fork 44
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
[DRUP-803] Real fix for the module uninstall problem + test coverage #203
Conversation
These changes does not fix anything. The actual problem is a Drupal core bug: https://www.drupal.org/project/drupal/issues/3056604
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to add try/catch blocks just to follow a different pattern than what core is doing. Adding tests are a good idea, but we need to focus on getting features out the door instead of fixing solved problems in different ways.
@cnovak I think you are misunderstanding what is going on here :) In Drupal core, you may not see this pattern* (which is bad, because hiding object dependencies is anti-pattern) but this problem is not about where do you retrieve entity storages from entity type manager in a class and why. <?php
class ResponseSubscriber implements EventSubscriberInterface {
/**
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
private $entity_type_manager;
/**
* ResponseSubscriber constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
*/
public function __construct(EntityTypeManagerInterface $entityTypeManager) {
$this->entity_type_manager = $entityTypeManager;
}
/**
* Does something with foo entities.
*
* @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
* The event.
*/
public function handle(FilterResponseEvent $event) {
$foo_entities = $this->entity_type_manager->getStorage('foo')->loadMultiple();
// TODO Do something with foo entities.
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[KernelEvents::RESPONSE][] = ['handle'];
return $events;
}
} and this <?php
/**
* ResponseSubscriber constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
*/
public function __construct(EntityTypeManagerInterface $entityTypeManager) {
$this->fooStorage = $entityTypeManager->getStorage('foo');
}
/**
* Does something with foo entities.
*
* @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
* The event.
*/
public function handle(FilterResponseEvent $event) {
$foo_entities = $this->fooStorage->loadMultiple();
// TODO Do something with foo entities.
} fails exactly the same way with Drupal 8.7. So it does not matter where do you retrieve the entity storage instance, until 3056604 has not been fixed in Drupal core. Consequently, this change does not fix anything, it just works at this moment because of the Compared this with my fix which actually provides a proper temporary workaround for the Drupal core bug which could be easily followed in the new event subscribers and it could be removed when the Drupal core bug gets fixed. |
Fixed failing Apigee Edge uninstall test because of dependencies. New test build: https://travis-ci.org/mxr576/apigee-devportal-drupal/builds/536737890 |
@Jaesin Let's continue the discussion about this if you still disagree, shall we? |
I have a working patch for the Drupal core bug which is in review at this moment. Added that instead of the workaround that I implemented. https://travis-ci.org/mxr576/apigee-devportal-drupal/builds/537746931 |
The previous test also passed, but I updated to patch so updated this PR as well. |
The API Docs module was removed some time back, closing issue |
As it revealed the real problem with the module uninstalls in #198 were caused by a Drupal core bug:
#198 (comment)
This PR reverts the unnecessary changes and adds workarounds for the Drupal core. Also contains tests for module uninstalls.
Latest test on Travis CI: https://travis-ci.org/mxr576/apigee-devportal-drupal/builds/538575563