Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294288

Can't change "Attach to" setting when attached to broken machine name

$
0
0
  1. I had a view with a block display and an attachment.
  2. I changed the machine name on the block display.
  3. The attachment now lists "Attach to: Broken field" and I have the error "Plugin ID 'block_1' was not found."
  4. So far, this is expected behavior. However, I when I click on "broken field" to reattach to the block, nothing happens in the UI and I get the following error in the log:
    Error: Call to a member function acceptAttachments() on null in Drupal\views\Plugin\views\display\Attachment->buildOptionsForm() (line 193 of /app/web/core/modules/views/src/Plugin/views/display/Attachment.php) 
    #0 /app/web/core/modules/views_ui/src/Form/Ajax/Display.php(74): Drupal\views\Plugin\views\display\Attachment->buildOptionsForm(Array, Object(Drupal\Core\Form\FormState)) 
    #1 [internal function]: Drupal\views_ui\Form\Ajax\Display->buildForm(Array, Object(Drupal\Core\Form\FormState)) 
    #2 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(518): call_user_func_array(Array, Array) 
    #3 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(275): Drupal\Core\Form\FormBuilder->retrieveForm('views_ui_edit_d...', Object(Drupal\Core\Form\FormState)) 
    #4 /app/web/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php(214): Drupal\Core\Form\FormBuilder->buildForm('views_ui_edit_d...', Object(Drupal\Core\Form\FormState)) 
    #5 /app/web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\views_ui\Form\Ajax\ViewsFormBase->Drupal\views_ui\Form\Ajax\{closure}() 
    #6 /app/web/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php(216): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) 
    #7 /app/web/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php(125): Drupal\views_ui\Form\Ajax\ViewsFormBase->ajaxFormWrapper('Drupal\\views_ui...', Object(Drupal\Core\Form\FormState)) 
    #8 /app/web/core/modules/views_ui/src/Form/Ajax/Display.php(46): Drupal\views_ui\Form\Ajax\ViewsFormBase->getForm(Object(Drupal\views_ui\ViewUI), 'attachment_1', 'ajax') 
    #9 [internal function]: Drupal\views_ui\Form\Ajax\Display->getForm(Object(Drupal\views_ui\ViewUI), 'attachment_1', 'ajax', 'displays') 
    #10 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) 
    #11 /app/web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() 
    #12 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) 
    #13 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) 
    #14 /app/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() 
    #15 /app/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) 
    #16 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
    #17 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
    #18 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
    #19 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
    #20 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
    #21 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
    #22 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
    #23 /app/web/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
    #24 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) 
    #25 {main}.

So then I was stuck in a state where:

  • I could not change the attachment to the correct block
  • I could not set the block back to its prior machine name because that throws the error "Machine name must be unique."
  • I could delete the affected attachment but attempting to save the view throws the error:
    TypeError: Argument 1 passed to Drupal\Core\Config\Entity\ConfigEntityBase::calculatePluginDependencies() must implement interface Drupal\Component\Plugin\PluginInspectionInterface, null given, called in /app/web/core/modules/views/src/Entity/View.php on line 290 in Drupal\Core\Config\Entity\ConfigEntityBase->calculatePluginDependencies() (line 68 of core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php).
    
    Drupal\Core\Config\Entity\ConfigEntityBase->calculatePluginDependencies(NULL) (Line: 290)
    Drupal\views\Entity\View->calculateDependencies() (Line: 341)
    Drupal\Core\Config\Entity\ConfigEntityBase->preSave(Object) (Line: 300)
    Drupal\views\Entity\View->preSave(Object) (Line: 471)
    Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 426)
    Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 263)
    Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object) (Line: 390)
    Drupal\Core\Entity\Entity->save() (Line: 635)
    Drupal\Core\Config\Entity\ConfigEntityBase->save() (Line: 989)
    Drupal\views_ui\ViewUI->save() (Line: 326)
    Drupal\views_ui\ViewEditForm->save(Array, Object)
    call_user_func_array(Array, Array) (Line: 111)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
    Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 589)
    Drupal\Core\Form\FormBuilder->processForm('view_edit_form', Array, Object) (Line: 318)
    Drupal\Core\Form\FormBuilder->buildForm('view_edit_form', Object) (Line: 48)
    Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'edit', Array) (Line: 226)
    Drupal\views_ui\Controller\ViewsUIController->edit(Object, 'block_home')
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
    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: 99)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
    Drupal\page_cache\StackMiddleware\PageCache->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: 693)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    

So I was stuck in this broken state.

I attempted to get out of this bind using the workaround in #3035949: Plugin ID was not found. Error: Call to a member function getPluginDefinition() (which seems like the same issue, although they didn't report changing the machine name on the block, only on the attachment. But at any rate, I can't reopen it so had to create a new issue.) I exported the view configuration and replaced all references to the original machine name ("block_1") with the new machine name ("block_home"), then reimported, cleared the cache, and ran cron. But this resulted in error messages for both "Plugin ID 'block_1' was not found" and "Plugin ID 'block_home' was not found." So I was only able to resolve this by deleting both the renamed block and attachment from the config and reimporting.

My problem is now solved, but I'd think we'd want to put in some kind of safeguard to prevent other people from getting caught in this. The UI should allow you to edit the broken "Attach to" setting to reattach to an existing block if the original one is deleted or renamed.


Viewing all articles
Browse latest Browse all 294288

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>