Closed (fixed)
Project:
Translatable menu link uri
Version:
2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
1 Sep 2020 at 10:34 UTC
Updated:
8 Jul 2026 at 00:36 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sophie.skWe're seeing this on our sites too, when using the TMGMT Smartling module. For some translation jobs that we request, there's an error:
The website encountered an unexpected error. Please try again later. InvalidArgumentException: Invalid values given. Values must be represented as an associative array. in Drupal\Core\TypedData\Plugin\DataType\Map->setValue() (line 76 of core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php). Drupal\Core\TypedData\TypedDataManager->getPropertyInstance(Object, 'options', ) (Line: 116) Drupal\Core\TypedData\Plugin\DataType\Map->get('options') (Line: 160) Drupal\Core\TypedData\Plugin\DataType\Map->getProperties() (Line: 28) Drupal\tmgmt_content\DefaultFieldProcessor->extractTranslatableData(Object) (Line: 17) Drupal\tmgmt_content\LinkFieldProcessor->extractTranslatableData(Object) (Line: 182) Drupal\tmgmt_content\Plugin\tmgmt\Source\ContentEntitySource->extractTranslatableData(Object) (Line: 100) Drupal\tmgmt_content\Plugin\tmgmt\Source\ContentEntitySource->getData(Object) (Line: 395) Drupal\tmgmt\Entity\JobItem->getSourceData() (Line: 999) Drupal\tmgmt\Entity\JobItem->recalculateStatistics() (Line: 925) Drupal\tmgmt\Entity\Job->getSuggestions() (Line: 804) Drupal\tmgmt\Form\JobForm->buildSuggestions(Array, Object) (Line: 348) Drupal\tmgmt\Form\JobForm->form(Array, Object) (Line: 149) Drupal\Core\Entity\EntityForm->buildForm(Array, Object) call_user_func_array(Array, Array) (Line: 532) Drupal\Core\Form\FormBuilder->retrieveForm('tmgmt_job_edit_form', Object) (Line: 278) Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 91) Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39) Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object) call_user_func_array(Array, Array) (Line: 123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 166) Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)It looks like the error comes from the
optionsvalue in the link override. In some cases, it's set toFALSErather thanNULL, so it tries to set the value incorrectly.In the database I can see three different values for the override options:
MySQL [database]> select distinct(link_override__options) from menu_link_content_data; +------------------------+ | link_override__options | +------------------------+ | NULL | | N; | | a:0:{} | +------------------------+ 3 rows in set (0.004 sec)I wonder which it should be ... probably
NULL! I'm doing more digging.Comment #3
sophie.skI can't quite figure out what's causing it, but it seems that if a link is empty then the original link options get added into an overridden options array, which has a
FALSEkey rather thanNULL.Attaching a patch - it fixes the issue by by switching the options around, and adds a crude update hook to make all of the overridden option values the same as the parent options. The update checks whether the overridden value is a serialized array (which suggests that it's had values set) and, if not, it sets the value to the same as the parent link's.
It is really crude and it works for our use case but hopefully it can provide some steer on how to fix more widely :)
Comment #4
sophie.skI can't wait for the day when I upload the right patch the first time around. I made manual changes to it before uploading it so it was failing to apply. Duh.
Comment #5
jsobiecki commentedHello @Sophie.SK, thanks for patch. I had quite busy time recently, but I'll do my best to take a look on this over this weekend.
Best,
Jarek
Comment #6
nwom commentedThe patch fixed an issue I was having, however it results in the following error when attempting to update the db via
drush updatedb:Comment #9
maacl commentedAfter applying the patch, the file "translatable_menu_link_uri.install" was missing a "}", so I uploaded the patch again in an issue fork. Although the diff looks the same, I now have a working patch.
The patch solves the problem in tmgmt for me.
Comment #10
stefan.butura commentedAttached patch with closing brackets in translatable_menu_link_uri.install
Comment #11
stefan.butura commentedUpdated patch to make it so that the hook_update also fixes the menu_link_content_field_revision table.
Comment #12
stefan.butura commentedComment #13
kmontyWe encountered the same issue after installing this module using TMGMT patched to work with layout_builder_st. Confirming the patch in #11 resolved our issue.
Noting that our `menu_link_content_data` DB table matched that of #2 prior to running the database update command. After running it, it was cleaned up.
Comment #14
anybodyComment #15
qusai taha commentedPatch #11 working fine and fixing an issue with the TMGMT module.
Thank you
Comment #16
qusai taha commentedComment #17
jsobiecki commentedHi All, thank you for reviewing patch and providing patches. I'm working on final review as part of GlobalContributionWeekend2023.
Comment #18
jsobiecki commented1. I believe that 8.x is not supported anymore, so I decided to skip this version
2. I tested on D10, with newest version of default content module - PASS
3. I tried to reproduce problem with TMGMT - PASS
I wasn't able to create NULL value at database, but I agree that fixing serialization is good thing.
Patch looks ok, decided to commit it.
Thanks all for contributing!
Comment #19
jsobiecki commentedComment #21
jsobiecki commentedComment #23
snehauskoim commentedCould this patch also be reworked for Drupal 9?
Because for some older sites this problem still exists and requires database updates
Comment #24
carma03 commentedAs per @SnehauskoiM's comment and request, this is the patch for Drupal 9.
Comment #25
carma03 commentedAs per @SnehauskoiM's comment and request, this is the right patch for Drupal 9.
Comment #26
damondt commentedThere may have been a regression, I'm getting this error on D10 and translatable_menu_link_uri 2.1
The options value is null in the db if not overridden which gets unserialized as false which throws an error when using tmgmt.
The attached patch sets options to [] when null on menu_link_content load, I don't know weather this is the ideal solve.