Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Steps to reproduce:
- Login to Drupal 8 administration
- Go to Structure > Views (admin/structure/views)
- Enable Glossary view
- Go to /glossary
- Delete Glossary view
- Go to /glossary link tab and reload your tab.
- Fatal error:
Unsupported operand types in .../core/modules/views/src/Element/View.php on line 54
The problem disappears after clearing the cache.
Proposed resolution
As stated in the title, deleting a view should rebuild the routes...
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#37 | deleting_a_view_should-2596345-37-interdiff.txt | 800 bytes | mbovan |
#37 | deleting_a_view_should-2596345-37.patch | 2.17 KB | mbovan |
#37 | deleting_a_view_should-2596345-37-TEST-ONLY.patch | 1.07 KB | mbovan |
#33 | deleting_a_view_should-2596345-33-interdiff.txt | 1.38 KB | mbovan |
#33 | deleting_a_view_should-2596345-33.patch | 1.95 KB | mbovan |
Comments
Comment #2
lhuria94 CreditAttribution: lhuria94 commentedHi
Followed your steps to generate the issue:
On Drupal 8.0.0-dev, I am not able to generate it.
Thoughts?
Comment #3
lhuria94 CreditAttribution: lhuria94 commentedComment #4
Nitesh Pawar CreditAttribution: Nitesh Pawar at Trigyn Technologies Ltd commentedActually we need to clear cache programetically after deletion of any view.
@lhuria94 - Please follow below steps.
1. Open /glossary in new tab.
2. Delete Glossary view.
3. Go to /glossary link tab and reload your tab.
Comment #5
lhuria94 CreditAttribution: lhuria94 commentedokay, I checked again.
Its shows WSOD on the page when I go to /glossary link after the deletion of the view.
Comment #6
Nitesh Pawar CreditAttribution: Nitesh Pawar at Trigyn Technologies Ltd commentedComment #7
mbovan CreditAttribution: mbovan at MD Systems GmbH commented@lhuria94, missed the reload step in the issue summary. Changed now.
@Nitesh Pawar, thanks for clarifying. :)
Comment #9
dawehnerIsn't it enough to call
\Drupal::service('router.builder')->setRebuildNeeded();
?Comment #10
Shreya Shetty CreditAttribution: Shreya Shetty at Trigyn Technologies Ltd commentedComment #11
Shreya Shetty CreditAttribution: Shreya Shetty at Trigyn Technologies Ltd commentedThanks @dawehner changes done as you suggested.
Comment #12
Shreya Shetty CreditAttribution: Shreya Shetty at Trigyn Technologies Ltd commentedComment #13
Shreya Shetty CreditAttribution: Shreya Shetty at Trigyn Technologies Ltd commentedComment #14
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedI guess we should add tests here...
Comment #16
dawehnerYeah we need
Comment #17
Nitesh Pawar CreditAttribution: Nitesh Pawar at Trigyn Technologies Ltd commentedComment #18
Nitesh Pawar CreditAttribution: Nitesh Pawar at Trigyn Technologies Ltd commentedAdded test
Comment #19
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedHah, I was trying to upload the patch, but got the form notification that @Nitesh Pawar already uploaded different patch. :)
Anyway, I'm providing my (test) patch here. The interdiff is against #11.
Comment #20
Shreya Shetty CreditAttribution: Shreya Shetty at Trigyn Technologies Ltd commentedComment #22
Nitesh Pawar CreditAttribution: Nitesh Pawar at Trigyn Technologies Ltd commentedComment #23
dawehnerIdeally we would add a drupalGet('/glossary') with assertResponse(200) to ensure that really this state changed.
Comment #24
BerdirLets add that then, first check that /glossary is indeed a 200, then delete, then check 404.
Comment #25
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedOk, added the check.
Comment #26
dawehnerThank you for expanding the test coverage!
Comment #30
Nitesh Pawar CreditAttribution: Nitesh Pawar at Trigyn Technologies Ltd commentedComment #32
alexpottI discussed this with @dawehner and we concluded that views should implement the delete hook and do it there - because when hooks become events, or something else OO then we'll do the injection properly.
Comment #33
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedMoved to the hook_entity_type_delete().
Comment #34
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedComment #35
dawehnerWe could check whether the view has any routes and just in that particular case rebuild the router ...
Comment #37
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedAdded the check if there is a routed display on a view before calling rebuild, as discussed with @dawehner here at Drupal Camp Vienna 2015.
Comment #39
dawehnerAwesome, thank you!
Comment #40
alexpottCommitted b6b7891 and pushed to 8.0.x and 8.1.x. Thanks!
Comment #43
edurenye CreditAttribution: edurenye at MD Systems GmbH commentedNow we have to remove the rebuilds in PastDBTest::testViews and the @todo messages, not sure if here or in a followup.
Comment #44
edurenye CreditAttribution: edurenye at MD Systems GmbH commentedSorry for that, I thougt that it was in the module.
Comment #45
dawehnerIf you find any in views, feel free to open a follow up!