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.
Issue fork forum_access-3311661
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
Comment #2
pompetardo commentedNew finding:
I exported the config with drush and in forum_access.settings.yml under forum_access_roles_gids: the deleted roles are still there.
Comment #3
junaidpvFacing same issue.
Comment #4
salvisSo, this results in the following query:
I don't see how this could produce an error message like
Comment #5
salvisI'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.
Comment #6
nico.b commentedI 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
Comment #7
nico.b commentedNow that I've looked at the code, I think I've also identified the issue. In the query you (@salvis) have already shown above
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.
Comment #9
nico.b commentedComment #10
dillix commentedMR needs rebase for 2.0.x
Comment #11
nico.b commentedMerged 2.0.x into the branch and changed the target of the MR.
Comment #12
nevergoneComment #14
nico.b commented@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).
Comment #15
nevergoneDrupal 10.5.6, 10.6.2 and 11.3.2 tested and affected.
Comment #16
nevergoneMySQL is affected, but MariaDB not.
Comment #17
nevergoneManually tested and works well.
Comment #19
nevergoneThanks, committed.