Removing Rules causes WSOD TypeError: if package removed - even when uninstalled first.

Created on 26 May 2024, 3 months ago
Updated 16 July 2024, about 2 months ago

Problem/Motivation

So decided to just get rid of the Rules module because for the most part "It Does Not Work." Literally does not work at all, and after two week of frustration (going through every post and all documentation for anything related to rules) trying to work with it for what should be some super simple tasks I have had enough!

This was an essential module for Drupal 7 and worked wonderfully...not the case for Drupal 9 and 10. It may be a little more work and a bit more complicated but using core events and creating a listener as a plugin to check for conditions with the ability to execute an action/function in a custom module (which always work) looks to be the best alternative.

So...the problem!

After uninstallation via Drupal (everything appeared to be fine main theme worked no errors) that is "until" I actually deleted the module package using composer remove drupal/rules well...that caused a big-ole WSOD when accessing the sites public facing custom theme. Administration theme was fine but not the custom theme. How or why "Rules" would cause this is beyond me, as far as I know rules doesn't have any direct theme integration (but I could be wrong, I just don't have the time to dig into another broken module right now).

Here is the stack/log:

TypeError: Drupal\Core\Plugin\Context\Context::__construct(): Argument #1 ($context_definition) must be of type Drupal\Core\Plugin\Context\ContextDefinitionInterface, __PHP_Incomplete_Class given, called in /var/www/html/web/core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php on line 51 in Drupal\Core\Plugin\Context\Context->__construct() (line 50 of /var/www/html/web/core/lib/Drupal/Core/Plugin/Context/Context.php).

#0 /var/www/html/web/core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php(51): Drupal\Core\Plugin\Context\Context->__construct(Object(__PHP_Incomplete_Class))
#1 /var/www/html/web/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php(100): Drupal\Core\Executable\ExecutablePluginBase->getContext('user')
#2 /var/www/html/web/core/modules/block/src/BlockAccessControlHandler.php(92): Drupal\Core\Plugin\Context\ContextHandler->applyContextMapping(Object(Drupal\user\Plugin\Condition\UserRole), Array)
#3 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php(109): Drupal\block\BlockAccessControlHandler->checkAccess(Object(Drupal\block\Entity\Block), 'view', Object(Drupal\Core\Session\AccountProxy))
#4 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php(329): Drupal\Core\Entity\EntityAccessControlHandler->access(Object(Drupal\block\Entity\Block), 'view', Object(Drupal\Core\Session\AccountProxy), true)
#5 /var/www/html/web/core/modules/block/src/BlockRepository.php(63): Drupal\Core\Entity\EntityBase->access('view', NULL, true)
#6 /var/www/html/web/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php(137): Drupal\block\BlockRepository->getVisibleBlocksPerRegion(Array)
#7 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(270): Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build()
#8 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#9 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#10 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#11 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#12 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
#13 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#14 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /var/www/html/web/modules/contrib/advban/src/AdvbanMiddleware.php(57): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /var/www/html/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\advban\AdvbanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#28 {main}

I'm not sure if this is related to another issue (I've searched thru them all for Rules) these are about the closest I found: https://www.drupal.org/project/rules/issues/3219012 β†’ and https://www.drupal.org/project/rules/issues/3182336 β†’
- If they are related it's hard to believe this is still a problem, yet it is...

Steps to reproduce

Install Rules module and activate it. Try one of the example Rules like assign a role to new users (change role in rule to a role you have already created or create the role listed in the rule to test).
- Create a new user (role is not applied, module does not work.)
- Uninstall Rules module using Drupal uninstall - which deactivates the module. If you check your main /custom theme (public facing) everything will appear as if it is fine.
- Now remove the module completely (if using composer use composer remove, otherwise delete the rules module package from ../modules/contrib/ directory.
- Now check main theme "BROKEN with WSOD" for all public pages (admin still works fine).
- Try clearing cache, running update.php and rebuild nothing helps still WSOD - even tried to rebuild all permissions and that also had no affect.

The only way to get things working again was to put the rules module package back in ../modules/contrib/ directory and you don't even have to activate the module and there is no more WSOD and all pages work no errors produced anywhere.

Why would that happen? How is it that a not installed module is still trying to be used by Drupal?

How is it rules is still in this dysfunctional state? There hasn't been any updates since October of 2023?

And finally - "How can I remove the package without breaking my site?" I no longer wish to use Rules for anything..
- Feels like something isn't getting removed properly when running Drupal's uninstall for this module.

Also, the import export feature is broken for Rules the only option on a single export or import is Rules "Components" nothing for an entire rule, which may be some of the issue (as I was testing I wanted to export one of the example rules modify it an reimport it accept there was no option to export) so I tried to import the config file listed on git for the example rule I listed in steps to produce "Add a role to new users" and I tried to import it as a rules component which created an incomplete component and caused other issues and was quite a pain to get rid of the component to try some other tests with rules, but I managed and then finally just gave up on rules (not worth the frustration)
- Additionally I don't like having a useless module that is not active on my server so this really needs to be addressed.

Apologies for any harshness in my comments (I'm honestly just sick and frustrated with incomplete and problematic modules that worked great in Drupal 7 but are pretty much worthless in Drupal 10 as I've already spent way...way too much time fixing needed modules on a website upgrade from Drupal 7 to 9 or 10) "literally been dealing with this for 2 years solid, extending Drupal 7 EOL every year is not helping the situation either - but that's a bigger problem than this issue..

Rules was tested with latest version of Drupal 10.2.6 with PHP 8.1.13 running on Apache 2.4.38

πŸ’¬ Support request
Status

Closed: won't fix

Component

Rules Core

Created by

πŸ‡ΊπŸ‡ΈUnited States sidgrafix

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sidgrafix
  • πŸ‡ΊπŸ‡ΈUnited States sidgrafix
  • Status changed to Closed: won't fix 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States TR Cascadia

    I'm not interested in helping you fix your problem.

  • Status changed to Active 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States sidgrafix

    @TR, don't really care if you don't want to help - someone else might, closing a ticket for no reason is childish like your throwing a tantrum .. good luck with that!

  • Status changed to Closed: won't fix 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States TR Cascadia

    What you report is not a bug in Rules. __PHP_Incomplete_Class means you still have something in your database or memory that references a removed class, which is why restoring the module code containing the class stops the error. All configuration entities created by Rules are removed when Rules is uninstalled, so this missing class is being referenced by something other than Rules.

    I'm not going to even try to address all the wrong information and accusations and insults in your original post. The "tantrum" here is you lashing out at the one person who is most likely to be able to help you.

    I set the status for this issue to "Closed (won't fix)". Please leave it that way.

  • πŸ‡ΊπŸ‡ΈUnited States sidgrafix

    If anyone else falls victim to this the problem is caused by the typed_data module required by rules. If you uninstall rules and don't uninstall typed_data as well deleting rules causes the listed error.

    Not sure if this is on rules as a bug (but it sure seems like it is)...

    All configuration entities created by Rules are removed when Rules is uninstalled

    If rules removes all configuration entities it appears to be missing any related configuration with typed_data.
    - If I'm understanding correctly typed_data (the function and features behind it that was part of rules for Drupal 7 was taken out of rules and made a requirement for rules because other modules could benefit from/use the typed_data module.

  • πŸ‡¨πŸ‡¦Canada arakwar

    #6 works for me.

    Uninstall both Rules and Typed Data at the same time and you'll be ok.

    Either Rules isn't truly uninstalling properly, or Typed data has an issue when a module using it is uninstalled.

Production build 0.71.5 2024