Problem/Motivation

When webform_node declared in custom install profile it prevents install because checking requirements failed

Starting Drupal installation. This takes a while. Consider using the        [ok]
--notify global option.
Drupal\Core\Entity\Exception\NoCorrespondingEntityClassException: The    [error]
Drupal\node\Entity\NodeType class does not correspond to an entity
type. in
.../core/lib/Drupal/Core/Entity/EntityTypeRepository.php:98
Stack trace:
#0
.../core/lib/Drupal/Core/Entity/EntityManager.php(377):
Drupal\Core\Entity\EntityTypeRepository->getEntityTypeFromClass('Drupal\\node\\Ent...')
#1
.../core/lib/Drupal/Core/Entity/Entity.php(499):
Drupal\Core\Entity\EntityManager->getEntityTypeFromClass('Drupal\\node\\Ent...')
#2
.../modules/webform/modules/webform_node/webform_node.install(19):
Drupal\Core\Entity\Entity::load('webform')
.../core/includes/install.inc(957):
webform_node_requirements('install')
#4
.../core/includes/install.core.inc(1969):
drupal_check_profile('custom_profile')

Proposed resolution

Do not try to access NodeType at webform_node_requirements() because node module could not be installed yet

Remaining tasks

fix issue

Comments

andypost created an issue. See original summary.

andypost’s picture

Issue summary: View changes
jrockowitz’s picture

andypost’s picture

Thanx for pointer, looking at patch it needs improve comment and I will try to a bit different approach

jrockowitz’s picture

@andypost Maybe just calling function_exists('node_type_get_types') will do the trick.

andypost’s picture

Status: Active » Needs review
StatusFileSize
new2.36 KB

That works for me
- install custom profile & config_installer
- module uninstall

andypost’s picture

StatusFileSize
new975 bytes
new2.84 KB

Proper fix for uninstall config

andypost’s picture

Issue tags: +Needs tests

Test case
- install node + webform_node
- uninstall webform_node
- make sure no field storage & node type

jrockowitz’s picture

When I uninstall the webform_node any existing 'webform' nodes are losing their content-type and display the below error...

Error: Call to a member function displaySubmitted() on null in template_preprocess_node() (line 621 of core/modules/node/node.module).

Steps to reproduce

  • Start with a clean install
  • Install the webform and webform_node module
  • Create a webform node (/node/add/webform) using the 'Contact' form
  • Generate a test submission (/node/NID/webform/test)
  • Uninstall the webform node module.
  • Go back the webform node (/node/NID)
  • Get the above error message

Notes

  • The webform content type and field are being completely uninstalled, which is what we want.
  • We need to decide if we should just delete all webform node during the uninstall
  • How are other contrib module handling uninstall content-types?

When I perform the same steps with the book module, I get the below error when I try to uninstall the book module with existing book pages.

The following extensions will be uninstalled: book
Do you really want to continue? (y/n): y
Drupal\Core\Extension\ModuleUninstallValidatorException: The following reasons prevent the modules from being           [error]
uninstalled: To uninstall Book, delete all content that has the Book content type in
/private/var/www/sites/d8_webform/core/lib/Drupal/Core/Extension/ModuleInstaller.php:354

The only immediate difference I see between the book module and webform node module is the book module's config is optional but node module is still required.

jrockowitz’s picture

So I figured what is throwing the book module uninstall error... the BookUninstallValidator.

We just need to copy the BookUninstallValidator class and service definition over to the webform node module

jrockowitz’s picture

StatusFileSize
new6.94 KB

Attached patch adds the WebformNodeUninstallValidator and move all config into the optional directory.

andypost’s picture

Awesome idea!
I'll check any node-related parts in webform module - they should be exactly a part of webform_node module (book is nice example)

optional config ++ but require enforce to webform_node module so uninstalled with "feature" but content and submissions needs removal manually somehow

index 9625bf5d..00000000
--- a/modules/webform_node/config/install/core.base_field_override.node.webform.promote.yml

--- a/modules/webform_node/config/install/core.base_field_override.node.webform.promote.yml
+++ /dev/null

you just deletes files)

Status: Needs review » Needs work

The last submitted patch, 11: webform_node_breaks-2865302-11.patch, failed testing.

jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new8.53 KB

I need to take a break. Hopefully this patch applies.

Next steps would be to copy \Drupal\Tests\book\Kernel\BookUninstallTest and tweak it.

jrockowitz’s picture

I am off for the weekend. @andypost (or anyone else) if you have time to write the needed tests, please reassign this ticket to yourself.

jrockowitz’s picture

Assigned: Unassigned » jrockowitz

  • jrockowitz committed b22520c on 2865302-webform-node-install
    Issue #2865302 by andypost, jrockowitz: webform_node breaks profile...
jrockowitz’s picture

StatusFileSize
new14.93 KB

Here is a patch with 'decent' test coverage. If it passes, I will commit it.

Status: Needs review » Needs work

The last submitted patch, 18: adding_deleting-2865486-2.patch, failed testing.

jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new51.16 KB

  • jrockowitz committed d3cac77 on 2865302-webform-node-install
    Issue #2865302 by andypost, jrockowitz: webform_node breaks profile...
jrockowitz’s picture

StatusFileSize
new16.78 KB

Patch removes code accidentally copied from the book.module.

andypost’s picture

+++ b/modules/webform_node/src/ProxyClass/WebformNodeUninstallValidator.php
@@ -0,0 +1,88 @@
+    class WebformNodeUninstallValidator implements \Drupal\Core\Extension\ModuleUninstallValidatorInterface
...
+        use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
...
+        public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, $drupal_proxy_original_service_id)

looks quietly strange to see classes without use at the top of the file

  • jrockowitz committed a930a6e on 2865302-webform-node-install
    Issue #2865302 by andypost, jrockowitz: webform_node breaks profile...
jrockowitz’s picture

Status: Needs review » Fixed

  • jrockowitz committed d71235f on 8.x-5.x
    Issue #2865302 by jrockowitz, andypost: webform_node breaks profile...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.