- Issue created by @deciphered
- π³πΏNew Zealand quietone
If this problem was discovered on a version of Drupal that is not 11.x, add that information in the issue summary and leave the version at 11.x. In Drupal core changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies β . Also mentioned on the version β section of the list of issue fields documentation. Thanks.
What are the details of the error? Can you get the stack trace?
- π¦πΊAustralia deciphered
I can confirm that the issue does not occur with MariaDB or MySQL. PostgreSQL seems to be required to replicate the issue.
The point of origin of the issue appears to be in line 510 of /core/modules/media_library/src/Form/AddFormBase.php: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/media...
$media = $this->entityTypeManager->getStorage('media') ->loadMultiple(explode(',', $form_state->getValue('current_selection')));
An example of the error is:
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type bigint: "" LINE 4: ..._entity_type_id" = 'media') AND ("target_entity_id" IN ('')) ^: SELECT "workspace_association"."target_entity_type_id" AS "target_entity_type_id", "workspace_association"."target_entity_id" AS "target_entity_id", "workspace_association"."target_entity_id_string" AS "target_entity_id_string", "workspace_association"."target_entity_revision_id" AS "target_entity_revision_id" FROM "workspace_association" "workspace_association" WHERE ("workspace" = :db_condition_placeholder_0) AND ("target_entity_type_id" = :db_condition_placeholder_1) AND ("target_entity_id" IN (:db_condition_placeholder_2)) ORDER BY "target_entity_revision_id" ASC NULLS FIRST; Array ( [:db_condition_placeholder_0] => embargo_ctg [:db_condition_placeholder_1] => media [:db_condition_placeholder_2] => ) in Drupal\workspaces\WorkspaceAssociation->getTrackedEntities() (line 152 of /opt/drupal/web/web/core/modules/workspaces/src/WorkspaceAssociation.php).
Understood. I am attaching an issue with the same error, in case there is useful information there. Also, I am moving this to Workspaces because that is where the exception throws.
- π¦πΊAustralia deciphered
Call stack as requested:
PDOStatement->execute (/web/core/lib/Drupal/Core/Database/Statement/PdoTrait.php:115) Drupal\Core\Database\Statement\StatementBase->clientExecute (/web/core/lib/Drupal/Core/Database/Statement/PdoTrait.php:115) Drupal\Core\Database\StatementWrapperIterator->execute (/web/core/lib/Drupal/Core/Database/StatementWrapperIterator.php:70) Drupal\Core\Database\Connection->query (/web/core/lib/Drupal/Core/Database/Connection.php:666) Drupal\pgsql\Driver\Database\pgsql\Connection->query (/web/core/modules/pgsql/src/Driver/Database/pgsql/Connection.php:241) Drupal\Core\Database\Query\Select->execute (/web/core/lib/Drupal/Core/Database/Query/Select.php:521) Drupal\pgsql\Driver\Database\pgsql\Select->execute (/web/core/modules/pgsql/src/Driver/Database/pgsql/Select.php:148) Drupal\workspaces\WorkspaceAssociation->getTrackedEntities (/web/core/modules/workspaces/src/WorkspaceAssociation.php:152) Drupal\workspaces\Hook\EntityOperations->entityPreload (/web/core/modules/workspaces/src/Hook/EntityOperations.php:57) call_user_func_array:{/var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php:404} (/web/core/lib/Drupal/Core/Extension/ModuleHandler.php:404) Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure:/var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php:403-411} (/web/core/lib/Drupal/Core/Extension/ModuleHandler.php:404) Drupal\Core\Extension\ModuleHandler->invokeAllWith (/web/core/lib/Drupal/Core/Extension/ModuleHandler.php:357) Drupal\Core\Extension\ModuleHandler->invokeAll (/web/core/lib/Drupal/Core/Extension/ModuleHandler.php:403) Drupal\Core\Entity\ContentEntityStorageBase->preLoad (/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:606) Drupal\Core\Entity\EntityStorageBase->loadMultiple (/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:296) Drupal\media_library\Form\AddFormBase->processInputValues (/web/core/modules/media_library/src/Form/AddFormBase.php:511) Drupal\media_library\Form\FileUploadForm->uploadButtonSubmit (/web/core/modules/media_library/src/Form/FileUploadForm.php:318) call_user_func_array:{/var/www/html/web/core/lib/Drupal/Core/Form/FormSubmitter.php:105} (/web/core/lib/Drupal/Core/Form/FormSubmitter.php:105) Drupal\Core\Form\FormSubmitter->executeSubmitHandlers (/web/core/lib/Drupal/Core/Form/FormSubmitter.php:105) Drupal\Core\Form\FormSubmitter->doSubmitForm (/web/core/lib/Drupal/Core/Form/FormSubmitter.php:43) Drupal\Core\Form\FormBuilder->processForm (/web/core/lib/Drupal/Core/Form/FormBuilder.php:589) Drupal\Core\Form\FormBuilder->buildForm (/web/core/lib/Drupal/Core/Form/FormBuilder.php:321) Drupal\media_library\MediaLibraryUiBuilder->buildMediaTypeAddForm (/web/core/modules/media_library/src/MediaLibraryUiBuilder.php:311) Drupal\media_library\MediaLibraryUiBuilder->buildLibraryContent (/web/core/modules/media_library/src/MediaLibraryUiBuilder.php:162) Drupal\media_library\MediaLibraryUiBuilder->buildUi (/web/core/modules/media_library/src/MediaLibraryUiBuilder.php:128) call_user_func_array:{/var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123} (/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure:/var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:121-124} (/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123) Drupal\Core\Render\Renderer->executeInRenderContext (/web/core/lib/Drupal/Core/Render/Renderer.php:627) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext (/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:121) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure:/var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:96-98} (/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:97) Symfony\Component\HttpKernel\HttpKernel->handleRaw (/vendor/symfony/http-kernel/HttpKernel.php:183) Symfony\Component\HttpKernel\HttpKernel->handle (/vendor/symfony/http-kernel/HttpKernel.php:76) Drupal\Core\StackMiddleware\Session->handle (/web/core/lib/Drupal/Core/StackMiddleware/Session.php:53) Drupal\Core\StackMiddleware\KernelPreHandle->handle (/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php:48) Drupal\Core\StackMiddleware\ContentLength->handle (/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php:28) Drupal\big_pipe\StackMiddleware\ContentLength->handle (/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php:32) Drupal\page_cache\StackMiddleware\PageCache->pass (/web/core/modules/page_cache/src/StackMiddleware/PageCache.php:116) Drupal\page_cache\StackMiddleware\PageCache->handle (/web/core/modules/page_cache/src/StackMiddleware/PageCache.php:90) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle (/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php:48) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle (/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php:51) Drupal\Core\StackMiddleware\AjaxPageState->handle (/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php:53) Drupal\Core\StackMiddleware\StackedHttpKernel->handle (/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php:51) Drupal\Core\DrupalKernel->handle (/web/core/lib/Drupal/Core/DrupalKernel.php:715) {main} (/web/index.php:19)
- π¦πΊAustralia deciphered
As a potential solution I've added a conditional check to the Media Library AddFormBase.php so as not to trigger the offending code if
$form_state->getValue('current_selection')
is empty.https://git.drupalcode.org/issue/drupal-3543053/-/compare/11.x...feature...
Patch attached.
- πΊπΈUnited States smustgrave
Thanks for reporting
First fixes should be in MRs vs patches as tests don't run on patches. Also will need test coverage as a bug.
Thanks!
- π¦πΊAustralia deciphered
The fix is in both in a feature branch rather than a MR, as I suspect it'll still need work, and as a Patch because my client needs the fix to apply to their code base. Unfortunately they aren't currently funding the test coverage, so hopefully someone else can help with that, or I will get to it if I ever have that sort of free time.