- Issue created by @andrei.vesterli
- π²π©Moldova andrei.vesterli Chisinau
Here is the attached patch with the fix
- last update
about 1 year ago Composer require failure - Open in Jenkins β Open on Drupal.org βCore: 10.1.4 + Environment: PHP 8.1 & MySQL 5.7 w/Bullseye Upgradeslast update
about 1 year ago 1 pass - Merge request !12Fix the warning issue after menu item saving. β (Closed) created by andrei.vesterli
- last update
about 1 year ago Composer require failure - Issue was unassigned.
- Status changed to Needs review
about 1 year ago 9:30pm 3 November 2023 - last update
about 1 year ago Composer require failure - π¦πΉAustria agoradesign
With the given patch from #2, there's the risk of running into an error:
TypeError: array_merge(): Argument #2 must be of type array, null given in array_merge() (line 191
This seems to happen, when the user does not have the 'use menu link attributes' permission set
I've updated the patch to ensure an empty array, if the value is not set
- π¨πΏCzech Republic milos.kroulik
Based on the patch in #6 it looks like this is actually a duplicate of https://www.drupal.org/project/menu_link_attributes/issues/3331630 π Compatibility with other modules, options being overwritten. Fixed , which is already RTBC. Can we close this one?
- Status changed to Closed: duplicate
9 months ago 9:21am 14 May 2024 - π©πͺGermany Anybody Porta Westfalica
π Compatibility with other modules, options being overwritten. Fixed has already been fixed. Closing this as duplicate.
- π§π¬Bulgaria alexrayu
Sadly the other mentioned issue did not resolve this specific error - variables passed to NestedArray::MergeDeep() can still be NULL, which causes a warning. Reworked the previous patch to also check the second variable passed. If someone still has this error in ^1.5.0, you can check this patch.
- First commit to issue fork.
- π§πͺBelgium dtfabio Ninove
Hi Anybody,
I am also still experiencing the same problem that the code gives a warning if the arrays passed to NestedArray::mergeDeep() contain a NULL value.
In my case, this happened logged in as webmaster, given the webmaster had no permissions to add attributes to the menu link item.
I have included alexrayu's code in an MR with one more check in case the user has no attribute add permissions, given that at this place a NULL was still passed to the mergeDeep function later in the code.
Behaviour without patch:
After adding the patch:
Would it be possible to review the change, so that a solution to this problem can be included in a future release?
Greetings,
Fabio
- Merge request !32Resolve #3399153 "Fix warning on nested array merge deep array" β (Merged) created by dtfabio
-
anybody β
committed bd3e791f on 8.x-1.x authored by
dtfabio β
Issue #3399153: Fix: Warning: foreach() argument must be of type array|...
-
anybody β
committed bd3e791f on 8.x-1.x authored by
dtfabio β
Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
16 days ago 5:17pm 11 January 2025 - πΊπΈUnited States alphex Atlanta, GA USA
Drupal 10.4, applying this to the stable release, I'm still seeing the errors...
Warning: foreach() argument must be of type array|object, null given in menu_link_attributes_menu_link_content_form_entity_builder() (line 155 of /app/web/modules/contrib/menu_link_attributes/menu_link_attributes.module) #0 /app/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real(2, 'foreach() argum...', '/app/web/module...', 155) #1 /app/web/modules/contrib/menu_link_attributes/menu_link_attributes.module(155): _drupal_error_handler(2, 'foreach() argum...', '/app/web/module...', 155) #2 [internal function]: menu_link_attributes_menu_link_content_form_entity_builder('menu_link_conte...', Object(Drupal\menu_link_content\Entity\MenuLinkContent), Array, Object(Drupal\Core\Form\FormState)) #3 /app/web/core/lib/Drupal/Core/Entity/EntityForm.php(307): call_user_func_array('menu_link_attri...', Array) #4 /app/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(155): Drupal\Core\Entity\EntityForm->buildEntity(Array, Object(Drupal\Core\Form\FormState)) #5 /app/web/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php(130): Drupal\Core\Entity\ContentEntityForm->buildEntity(Array, Object(Drupal\Core\Form\FormState)) #6 /app/web/core/lib/Drupal/Core/Entity/EntityForm.php(286): Drupal\menu_link_content\Form\MenuLinkContentForm->buildEntity(Array, Object(Drupal\Core\Form\FormState)) #7 /app/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(145): Drupal\Core\Entity\EntityForm->submitForm(Array, Object(Drupal\Core\Form\FormState)) #8 [internal function]: Drupal\Core\Entity\ContentEntityForm->submitForm(Array, Object(Drupal\Core\Form\FormState)) #9 /app/web/core/lib/Drupal/Core/Form/FormSubmitter.php(129): call_user_func_array(Array, Array) #10 /app/web/core/lib/Drupal/Core/Form/FormSubmitter.php(67): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState)) #11 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(597): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState)) #12 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm('menu_link_conte...', Array, Object(Drupal\Core\Form\FormState)) #13 /app/web/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\menu_link_content\Form\MenuLinkContentForm), Object(Drupal\Core\Form\FormState)) #14 /app/web/modules/contrib/menu_item_extras/src/Controller/MenuController.php(62): Drupal\Core\Entity\EntityFormBuilder->getForm(Object(Drupal\menu_link_content\Entity\MenuLinkContent)) #15 [internal function]: Drupal\menu_item_extras\Controller\MenuController->addLink(Object(Drupal\system\Entity\Menu)) #16 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #17 /app/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #18 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #19 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #20 /app/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #21 /app/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #22 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /app/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #26 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #27 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #28 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #29 /app/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #30 /app/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #31 /app/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #32 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #33 {main}
Warning: foreach() argument must be of type array|object, null given in menu_link_attributes_menu_link_content_form_entity_builder() (line 173 of /app/web/modules/contrib/menu_link_attributes/menu_link_attributes.module) #0 /app/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real(2, 'foreach() argum...', '/app/web/module...', 173) #1 /app/web/modules/contrib/menu_link_attributes/menu_link_attributes.module(173): _drupal_error_handler(2, 'foreach() argum...', '/app/web/module...', 173) #2 [internal function]: menu_link_attributes_menu_link_content_form_entity_builder('menu_link_conte...', Object(Drupal\menu_link_content\Entity\MenuLinkContent), Array, Object(Drupal\Core\Form\FormState)) #3 /app/web/core/lib/Drupal/Core/Entity/EntityForm.php(307): call_user_func_array('menu_link_attri...', Array) #4 /app/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(155): Drupal\Core\Entity\EntityForm->buildEntity(Array, Object(Drupal\Core\Form\FormState)) #5 /app/web/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php(130): Drupal\Core\Entity\ContentEntityForm->buildEntity(Array, Object(Drupal\Core\Form\FormState)) #6 /app/web/core/lib/Drupal/Core/Entity/EntityForm.php(286): Drupal\menu_link_content\Form\MenuLinkContentForm->buildEntity(Array, Object(Drupal\Core\Form\FormState)) #7 /app/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(145): Drupal\Core\Entity\EntityForm->submitForm(Array, Object(Drupal\Core\Form\FormState)) #8 [internal function]: Drupal\Core\Entity\ContentEntityForm->submitForm(Array, Object(Drupal\Core\Form\FormState)) #9 /app/web/core/lib/Drupal/Core/Form/FormSubmitter.php(129): call_user_func_array(Array, Array) #10 /app/web/core/lib/Drupal/Core/Form/FormSubmitter.php(67): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState)) #11 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(597): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState)) #12 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm('menu_link_conte...', Array, Object(Drupal\Core\Form\FormState)) #13 /app/web/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\menu_link_content\Form\MenuLinkContentForm), Object(Drupal\Core\Form\FormState)) #14 /app/web/modules/contrib/menu_item_extras/src/Controller/MenuController.php(62): Drupal\Core\Entity\EntityFormBuilder->getForm(Object(Drupal\menu_link_content\Entity\MenuLinkContent)) #15 [internal function]: Drupal\menu_item_extras\Controller\MenuController->addLink(Object(Drupal\system\Entity\Menu)) #16 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #17 /app/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #18 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #19 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #20 /app/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #21 /app/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #22 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /app/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #26 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #27 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #28 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #29 /app/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #30 /app/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #31 /app/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #32 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #33 {main} .