If you have a Views Page that has a Views Attachment, the attachment has to be deleted first before you delete the page or the views interface will cause a fatal error and you will not be able to make any more edits to the view. If you delete the page first and leave the attachment orphaned, you will not be able to save any additional edits to the view. Any attempt to save the view from this point on will result in the following error:
Recoverable fatal error: Argument 1 passed to Drupal\Core\Config\Entity\ConfigEntityBase::calculatePluginDependencies() must implement interface Drupal\Component\Plugin\PluginInspectionInterface, null given, called in /path/to/drupal8/core/modules/views/src/Entity/View.php on line 281 and defined in Drupal\Core\Config\Entity\ConfigEntityBase->calculatePluginDependencies() (line 27 of core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php).
If you keep trying to work with and save the view, eventually the entire Views interface will stop working entirely. You won't even be able to view the index of Views at Admin > Structure > Views.
To reproduce
- Create a view with a page. Let's just name it Views Page Test (views_page_test).
- Save the view.
- Create an attachment in the view. Attach the attachment to the Views Page that we just created.
- Delete the page.
- Save the view.
- Click on the Attachments tab in the Views UI.
- Notice that there's a warning saying "Plugin ID 'page_1' was not found."
- The Attach To setting will show either "Broken Handler" or "Not Defined". Clicking on it will do nothing. The edit panel will not come up because it's causing a fatal error.
- Save the view
- The view will fail to save and result in the error as described above.
Expected Behavior
I expected either for a warning to stop me from deleting the page first or for a cleanup process to run to remove the association between the attachment and the page that it was attached to.
| Comment | File | Size | Author |
|---|---|---|---|
| #32 | interdiff-2843787-28-32.txt | 1.24 KB | asghar |
| #32 | deleting-views-attachments-fatal-error-2843787-32.patch | 3.28 KB | asghar |
| #28 | interdiff-2843787-25-28.txt | 589 bytes | asghar |
| #28 | deleting-views-attachments-fatal-error-2843787-28.patch | 3.17 KB | asghar |
| #25 | interdiff-2843787-19-25.txt | 1.39 KB | asghar |
Comments
Comment #2
hyperlinkedComment #3
asghar commentedHi
I have followed the above steps but could not produce the error as mentioned in post. Here is further details
Drupal Version: 8.25(fresh)
PHP: PHP 5.6.27
Comment #4
hyperlinkedHmmm, thanks. I'll double check it and report back.
Comment #5
asghar commentedHi
Now I have produced the error but little bit different steps:
Comment #6
hyperlinkedAre you running 8.2.5 in "Production" mode? Is it possible that you were getting a cached UI?
Comment #7
hyperlinkedBy the way, a useful workaround in case you run into this issue and you don't have a DB or a features backup of your view, you can still duplicate the view and you'll be able to edit the duplicate version of your view. It'll copy the orphan into the new view, but you'll be able to select the Attached To setting and change it.
Comment #8
asghar commentedHi
I have fixed the issue on local and created the patch. Please try with the attached patch. Thanks
Comment #9
asghar commentedComment #10
cilefen commentedComment #11
cilefen commentedBased on the patch this should be the component.
Comment #12
asghar commentedHi @cilefen
Sorry I did not get your point *Based on the patch this should be the component.* ?.
Comment #13
asghar commentedHi @cilefen gotcha. No clarification needed. Thanks
Comment #14
hyperlinkedI can confirm that this patch fixed the issue for me.
Comment #15
dawehnerThe patch looks pretty solid, but we need to write some tests that's for sure :)
In general it would be great to expand the documentation to something, which explains WHY we do something specific.
Comment #16
asghar commentedHi @dawehner
Do you want I add more details in code comments ?.
Comment #17
asghar commentedHi
I have updated the previous patch. I added the following changes in new one.
1- Extended the previous comments
2- Corrected the variable name from $display_hander to $display_handler.
Comment #18
asghar commentedHi
New patch contains the following things
1- Modified the comment
2- Added the Test code.
Comment #19
asghar commentedComment #20
dawehnerThank you @asghar!
Note:
getAttachedDisplaysreturns an array, so we can skip theifhere.Nitpick: The CS requires a space after the
foreachComment #21
asghar commentedHi @dawehner
Thanks for your comment.
1-
Yes return the array but I am also assigning the return output to the $attachments which I am using in *if block* condition. If deleting view display is not attached to the any attachment code then condition will be false.
2- I update that. Thanks
Comment #22
lendudeYeah looking really nice! Just a little more nitpicking:
Tests the attachment working after the attached page was deleted.
can we rename this to something describing the test? Like testRemoveAttachedDisplay or something along those lines?
Not needed is it? We are not doing anything with the delete button at this point.
It this really needed? The test fails fine without the extra saved, so seems a little superfluous.
Over 80 characters.
Comment #23
asghar commentedHi @Lendude
Thanks for your comment. You can find my feedback against each point
1- Done
2- Done
3- Done
4- Yes at-least two times save needed for test. If we use one time then test pass and we cannot produce the error.
5- Done
I have attached the new patch file. Thanks
Comment #24
lendude@asghar thanks for the rerolls, almost there I think, just a couple of things left for me:
Instead of saving X number of times and waiting for a fatal to show up, why not just test for the error that is shown?
Why not take out the extra saves and replace it with:
$this->assertNoText("Plugin ID 'page_1' was not found.");Then we are actually testing for this specific bug.
trailing whitespace snuck in
Also, could you add an interdiff when rerolling? Makes reviewing much easier.
Comment #25
asghar commentedHi @Lendude
Thanks for your help. I have modified the requested changes.
Comment #26
asghar commentedComment #27
lendude@asghar nice, one last nitpick in the new comment and then I think this is ready
Typo in warning and missing 'if', maybe "Check that there is no warning for the removed page display.", or something like that.
Comment #28
asghar commentedThanks much appreciated. I have updated the patch.
Comment #29
lendude@asghar nice work, many thanks.
Comment #30
asghar commentedThanks @Lendude, Try to find the next issue and fix that.
Comment #31
catchThere should be some kind of positive assertion after this, the next page could be a blank screen and assertNoText would still pass.
This doesn't need the link back to the issue, git blame handles that OK.
Comment #32
asghar commentedHi @catch
Thanks for guidance. I have updated the patch. Thanks
Comment #33
lendudeNitpicks:
Whitespace got in.
And the comment doesn't match what the assertion does, maybe change it to something like 'Check that the attachment is no longer linked to the removed display.'
Comment #34
asghar commentedThanks updated.
Comment #35
dawehnerThis can be totally fixed on commit.
This is a good assertion to be used here!
Comment #36
catchCommitted/pushed to 8.3.x and 8.4.x, thanks!
Comment #40
tepelena commentedWe are having this exact problem on 8.7.9
The views UI can not be accessed at all. Plus warning Plugin ID 'page_1' was not found. on admin pages.