I haven't been able to find an exact pattern for when this happens, but sometimes when reordering blocks in LB I get an AJAX error printed in the browser console. It most recently happened with a views block but I don' t know if that specifically is causing the issue.
Drupal.AjaxError {message: "↵An AJAX HTTP error occurred.↵HTTP Result Code: 20…uilderRestriction/EntityViewModeRestriction.php).", name: "AjaxError"}message: "↵An AJAX HTTP error occurred.↵HTTP Result Code: 200↵Debugging information follows.↵Path: /layout_builder/move/block/overrides/node.3156/1/content/a7fc9ef6-5bd2-4194-9f48-82be3b49953a?destination=/node/3156/layout&_wrapper_format=drupal_dialog.off_canvas&ajax_form=1↵StatusText: OK↵ResponseText: Error: Call to a member function __tostring() on string in Drupal\layout_builder_restrictions\Plugin\LayoutBuilderRestriction\EntityViewModeRestriction->blockAllowedinContext() (line 133 of /var/www/hrnih/docroot/modules/contrib/layout_builder_restrictions/src/Plugin/LayoutBuilderRestriction/EntityViewModeRestriction.php)."name: "AjaxError"__proto__: Error
at http://local.hrnih.com/core/misc/ajax.js?v=8.7.5:98:32
at http://local.hrnih.com/core/misc/ajax.js?v=8.7.5:640:3constructor: ƒ (xmlhttp, uri, customMessage)stack: "Error↵ at http://local.hrnih.com/core/misc/ajax.js?v=8.7.5:98:32↵ at http://local.hrnih.com/core/misc/ajax.js?v=8.7.5:640:3"__proto__: constructor: ƒ Error()message: ""name: "Error"toString: ƒ toString()__proto__: Object
Drupal.Ajax.error @ ajax.js?v=8.7.5:500
complete @ ajax.js?v=8.7.5:239
t.complete @ jquery.form.js:298
i @ jquery.min.js?v=3.2.1:2
fireWith @ jquery.min.js?v=3.2.1:2
A @ jquery.min.js?v=3.2.1:4
(anonymous) @ jquery.min.js?v=3.2.1:4
load (async)
send @ jquery.min.js?v=3.2.1:4
ajax @ jquery.min.js?v=3.2.1:4
e.fn.ajaxSubmit @ jquery.form.js:337
Drupal.Ajax.eventResponse @ ajax.js?v=8.7.5:330
(anonymous) @ ajax.js?v=8.7.5:269
dispatch @ jquery.min.js?v=3.2.1:3
q.handle @ jquery.min.js?v=3.2.1:3The block appears to move, but when I save the layout it's position doesn't in fact save and the following is printed in the watchdog log:
Error: Call to a member function __tostring() on string in Drupal\layout_builder_restrictions\Plugin\LayoutBuilderRestriction\EntityViewModeRestriction->blockAllowedinContext() (line 133 of /var/www/hrnih/docroot/modules/contrib/layout_builder_restrictions/src/Plugin/LayoutBuilderRestriction/EntityViewModeRestriction.php) #0 /var/www/hrnih/docroot/modules/contrib/layout_builder_restrictions/src/Form/MoveBlockForm.php(34): Drupal\layout_builder_restrictions\Plugin\LayoutBuilderRestriction\EntityViewModeRestriction->blockAllowedinContext(Object(Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage), '1', 1, 'content', 'a7fc9ef6-5bd2-4...', NULL) #1 [internal function]: Drupal\layout_builder_restrictions\Form\MoveBlockForm->validateForm(Array, Object(Drupal\Core\Form\FormState)) #2 /var/www/hrnih/docroot/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array(Array, Array) #3 /var/www/hrnih/docroot/core/lib/Drupal/Core/Form/FormValidator.php(275): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState)) #4 /var/www/hrnih/docroot/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'layout_builder_...') #5 /var/www/hrnih/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(576): Drupal\Core\Form\FormValidator->validateForm('layout_builder_...', Array, Object(Drupal\Core\Form\FormState)) #6 /var/www/hrnih/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(319): Drupal\Core\Form\FormBuilder->processForm('layout_builder_...', Array, Object(Drupal\Core\Form\FormState)) #7 /var/www/hrnih/docroot/core/lib/Drupal/Core/Controller/FormController.php(93): Drupal\Core\Form\FormBuilder->buildForm('layout_builder_...', Object(Drupal\Core\Form\FormState)) #8 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #9 /var/www/hrnih/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #10 /var/www/hrnih/docroot/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #11 /var/www/hrnih/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #12 /var/www/hrnih/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #13 /var/www/hrnih/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #14 /var/www/hrnih/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #15 /var/www/hrnih/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #16 /var/www/hrnih/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #17 /var/www/hrnih/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #18 /var/www/hrnih/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /var/www/hrnih/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /var/www/hrnih/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /var/www/hrnih/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /var/www/hrnih/docroot/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /var/www/hrnih/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #24 {main}.
When I try and re-order the block via the "move" contextual menu option the settings tray form won't work when clicking the "update" submit button.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | tostring-error-3068781-3.patch | 908 bytes | andkar |
Comments
Comment #2
mark_fullmerThanks for reporting this and for posting the traceback. We'll look into this in short order!
Comment #3
andkar commentedFor me, the problem arises when I edit the ‘Block category’ in the view. After I have updated the view the category field is a string and no longer a TranslatableMarkup object. Thats way I can’t call __tostring() and see the error ”Error: Call to a member function __tostring()…”
I've done a patch that fixes the problem.
Comment #4
mark_fullmerThanks for outlining the cause succinctly, AndKar! The patch looks perfectly sufficient for fixing this edge case. I'll plan to commit it later today.
Comment #6
mark_fullmerFix committed -- thanks AndKar and PCate!
The 8.x-2.2 release includes this fix: https://www.drupal.org/project/layout_builder_restrictions/releases/8.x-2.2