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.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pompetardo created an issue. See original summary.

pompetardo’s picture

New finding:
I exported the config with drush and in forum_access.settings.yml under forum_access_roles_gids: the deleted roles are still there.

junaidpv’s picture

Facing same issue.

salvis’s picture

Status: Active » Postponed (maintainer needs more info)

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'

salvis’s picture

Version: 8.x-1.0-alpha4 » 8.x-1.x-dev

I've tried creating and deleting a role under D89 and D95, 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.

nico.b’s picture

Status: Postponed (maintainer needs more info) » Active

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).

nico.b’s picture

Status: Active » Needs review

Now that I've looked at the code, I think I've also identified the issue. In the query you (@salvis) 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.

nico.b’s picture

Priority: Normal » Major
dillix’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs review » Needs work

MR needs rebase for 2.0.x

nico.b’s picture

Status: Needs work » Needs review

Merged 2.0.x into the branch and changed the target of the MR.

nevergone’s picture

Status: Needs review » Closed (cannot reproduce)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

nico.b’s picture

Status: Closed (cannot reproduce) » Needs review

@nevergone For me, this is still reproducible with the steps outlined in #6 (tested with 2.0.1 on Drupal 10.5.6, via simplytest.me).

The website encountered an unexpected error. Try again later.

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 508 of modules/contrib/forum_access/forum_access.module).

Drupal\Core\Database\StatementWrapperIterator->execute(Array, Array) (Line: 59)
Drupal\Core\Database\Query\Delete->execute() (Line: 508)
forum_access_user_role_delete(Object)
call_user_func_array(Object, Array) (Line: 416)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'forum_access') (Line: 395)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('user_role_delete', Object) (Line: 415)
Drupal\Core\Extension\ModuleHandler->invokeAll('user_role_delete', Array) (Line: 341)
Drupal\Core\Config\Entity\ConfigEntityStorage->invokeHook('delete', Object) (Line: 462)
Drupal\Core\Entity\EntityStorageBase->delete(Array) (Line: 362)
Drupal\Core\Entity\EntityBase->delete() (Line: 122)
Drupal\Core\Entity\EntityDeleteForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 129)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 67)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
Drupal\Core\Form\FormBuilder->processForm('user_role_delete_form', Array, Object) (Line: 326)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 637)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
nevergone’s picture

Drupal 10.5.6, 10.6.2 and 11.3.2 tested and affected.

nevergone’s picture

MySQL is affected, but MariaDB not.

nevergone’s picture

Issue tags: +Needs tests

Manually tested and works well.

  • nevergone committed c10be822 on 2.0.x authored by nico.b
    feat: #3311661 Deleting User Role crashes Drupal
    
    By: nico.b
    By:...
nevergone’s picture

Status: Needs review » Fixed

Thanks, committed.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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