Deleting User Role crashes Drupal

Created on 25 September 2022, almost 2 years ago
Updated 9 November 2023, 8 months ago

Problem/Motivation

Deleting a user role crashes drupal with the following message:

El sitio web encontrรณ un error inesperado. Vuelva a intentarlo mรกs tarde.

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: 'rol_test2': DELETE FROM "node_access" WHERE ("gid" = :db_condition_placeholder_0) AND ("realm" = :db_condition_placeholder_1); Array ( [:db_condition_placeholder_0] => rol_test2 [:db_condition_placeholder_1] => forum_access ) in forum_access_user_role_delete() (line 490 of modules/contrib/forum_access/forum_access.module).

Drupal\Core\Database\StatementWrapper->execute() (Line: 59)
Drupal\Core\Database\Query\Delete->execute() (Line: 490)
forum_access_user_role_delete()
call_user_func_array() (Line: 426)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}() (Line: 405)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 433)
Drupal\Core\Extension\ModuleHandler->invokeAll() (Line: 337)
Drupal\Core\Config\Entity\ConfigEntityStorage->invokeHook() (Line: 496)
Drupal\Core\Entity\EntityStorageBase->delete() (Line: 347)
Drupal\Core\Entity\EntityBase->delete() (Line: 122)
Drupal\Core\Entity\EntityDeleteForm->submitForm()
call_user_func_array() (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 592)
Drupal\Core\Form\FormBuilder->processForm() (Line: 320)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 159)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 709)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

Create a user role and then delete the role.

After the crash the website loads but you can find a trace of the deleted role in the admin menu, as "not found" role with the respective links that go to a not found page. A cache clear deletes the trace from the menu but as the delete process is interrupted, I'm not sure if there is some baggage left anywhere.

๐Ÿ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

๐Ÿ‡ต๐Ÿ‡ชPeru pompetardo

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia junaidpv Kannur, Kerala

    Facing same issue.

  • Status changed to Postponed: needs info 11 months ago
  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland salvis

    Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: 'rol_test2': DELETE FROM "node_access" WHERE ("gid" = :db_condition_placeholder_0) AND ("realm" = :db_condition_placeholder_1); Array ( [:db_condition_placeholder_0] => rol_test2 [:db_condition_placeholder_1] => forum_access ) in forum_access_user_role_delete() (line 490 of modules/contrib/forum_access/forum_access.module).

    So, this results in the following query:

    DELETE FROM "node_access" WHERE ("gid" = 'rol_test2') AND ("realm" = 'forum_access');
    

    I don't see how this could produce an error message like

    Invalid datetime format: 1292 Truncated incorrect DOUBLE value: 'rol_test2'

  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland salvis

    I've tried creating and deleting a role using the current -dev version (requires ACL 8.x-1.1) and I did not get any crash.

    Please try this again and let us know.

  • Status changed to Active 8 months ago
  • I am able to reliably reproduce the issue with the current dev version on Drupal 9.5.11 with ACL 8.x-1.1.

    Here are the steps to reproduce the issue:
    - Set up a fresh Drupal installation ("standard" installation profile) - I used simplytest.me for this
    - Install forum_access
    - Create a role with name "Test"
    - Edit the "General discussion" forum and allow the new role to "View this forum" and "Post in this forum"
    - Save (and rebuild permissions)
    - Create a forum post in the "General discussion" forum
    - Delete the role with name "Test"
    -> Issue occurs

    Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: 'test': DELETE FROM "node_access" WHERE ("gid" = :db_condition_placeholder_0) AND ("realm" = :db_condition_placeholder_1); Array ( [:db_condition_placeholder_0] => test [:db_condition_placeholder_1] => forum_access ) in forum_access_user_role_delete() (line 503 of /var/lib/tugboat/stm/web/modules/contrib/forum_access/forum_access.module).

  • Status changed to Needs review 8 months ago
  • Now that I've looked at the code, I think I've also identified the issue. In the query you (@galvis) have already shown above

    DELETE FROM "node_access" WHERE ("gid" = 'rol_test2') AND ("realm" = 'forum_access');
    

    we pass the role ID (which is a string since Drupal 8/9) to "gid". However, the "gid" column in the database is actually an integer column. We need to map the role ID to the "gid" first (similar to as it's also done at other places in the module).

    I have created a merge request that implements this and I was not able to reproduce the issue anymore.

  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 8 months ago
    Waiting for branch to pass
  • @nicob opened merge request.
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 8 months ago
    Waiting for branch to pass
Production build 0.69.0 2024