Hey,
When I try to save my menu it's showing me Error. Error: Cannot use object of type stdClass as array in Drupal\we_megamenu\WeMegaMenuBuilder::dragDropMenuItems() (line 584 of /var/www/elementis/docroot/modules/contrib/we_megamenu/src/WeMegaMenuBuilder.php) #0 /var/www/elementis/docroot/modules/contrib/we_megamenu/we_megamenu.module(743): Drupal\we_megamenu\WeMegaMenuBuilder::dragDropMenuItems('main', 'elementis', Object(stdClass), Array) #1 [internal function]: we_megamenu_entity_presave(Object(Drupal\system\Entity\Menu), 'menu') #2 /var/www/elementis/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php(403): call_user_func_array('we_megamenu_ent...', Array) #3 /var/www/elementis/docroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(349): Drupal\Core\Extension\ModuleHandler->invokeAll('entity_presave', Array) #4 /var/www/elementis/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(491): Drupal\Core\Config\Entity\ConfigEntityStorage->invokeHook('presave', Object(Drupal\system\Entity\Menu)) #5 /var/www/elementis/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(445): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\system\Entity\Menu)) #6 /var/www/elementis/docroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(263): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\system\Entity\Menu)) #7 /var/www/elementis/docroot/core/lib/Drupal/Core/Entity/EntityBase.php(394): Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\system\Entity\Menu)) #8 /var/www/elementis/docroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(613): Drupal\Core\Entity\EntityBase->save() #9 /var/www/elementis/docroot/core/modules/system/src/Entity/Menu.php(99): Drupal\Core\Config\Entity\ConfigEntityBase->save() #10 /var/www/elementis/docroot/core/modules/menu_ui/src/MenuForm.php(179): Drupal\system\Entity\Menu->save() #11 [internal function]: Drupal\menu_ui\MenuForm->save(Array, Object(Drupal\Core\Form\FormState)) #12 /var/www/elementis/docroot/core/lib/Drupal/Core/Form/FormSubmitter.php(111): call_user_func_array(Array, Array) #13 /var/www/elementis/docroot/core/lib/Drupal/Core/Form/FormSubmitter.php(51): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState)) #14 /var/www/elementis/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(590): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState)) #15 /var/www/elementis/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(319): Drupal\Core\Form\FormBuilder->processForm('menu_edit_form', Array, Object(Drupal\Core\Form\FormState)) #16 /var/www/elementis/docroot/core/lib/Drupal/Core/Controller/FormController.php(93): Drupal\Core\Form\FormBuilder->buildForm('menu_edit_form', Object(Drupal\Core\Form\FormState)) #17 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #18 /var/www/elementis/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #19 /var/www/elementis/docroot/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #20 /var/www/elementis/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #21 /var/www/elementis/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #22 /var/www/elementis/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #23 /var/www/elementis/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #24 /var/www/elementis/docroot/modules/contrib/simple_oauth/src/HttpMiddleware/BasicAuthSwap.php(67): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /var/www/elementis/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #26 /var/www/elementis/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #27 /var/www/elementis/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #28 /var/www/elementis/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #29 /var/www/elementis/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #30 /var/www/elementis/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #31 /var/www/elementis/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #32 /var/www/elementis/docroot/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #33 /var/www/elementis/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #34 {main}.
Anyone help me to solve this issue.
Thank you
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3083757-8.patch | 6.86 KB | marthinal |
| #2 | 3083757-2.patch | 6.82 KB | marthinal |
Issue fork we_megamenu-3083757
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
marthinal commentedI have the same error. It works with this patch
Comment #3
marthinal commentedComment #4
marthinal commentedComment #5
marthinal commentedI can reproduce it when I try to change the order of the menus.
Comment #6
jwilson3Patch in #2 works. Thanks @Marthinal
Comment #7
jwilson3Comment #8
marthinal commentedRerolled
Comment #9
marthinal commentedComment #10
jwilson3Comment #11
jwilson3Comment #12
roland.molnar commentedI applied the patch in #8, but now I get this error for some menu items:
Comment #13
roland.molnar commentedI'm debugging the code and it looks like
is sometimes an Array, sometimes a Class.
As I'm not familiar whith what this code does, I'm not sure if the solution is simply wrap the code segment in another if
else skip these
or do something like
Comment #15
xaviemirmonHi @roland.molnar
I've debugged this issue to see why some instances of
rows_contentwere stored as objects versus an array as intended. This is caused by various unsets removing items in arrays and not resetting the index. When themenu_configdata is then passed through the json_encode() function, it's perceiving that attribute as an object.is being encoded as
I've created an issue fork which fixing the problem by correctly re-indexing the array if items are removed to that the first index is 0.
Comment #18
rjjakes commentedI merged the fix by xaviemirmon to 8-x.1-x as this fixed the underlying issue instead of working around it.