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
The default Taxonomy view preview is broken.
Proposed resolution
Steps to reproduce
- Do a standard install.
- Tag some content with a taxonomy term.
- Be sure you can browse the tagged content at taxonomy/term/1, assuming the term you tagged is the first one.
- Edit the Taxonomy term view at admin/structure/views/view/taxonomy_term
- An 500 error is returned on the Ajax call for the preview.
- Type 1 in the "Preview with contextual filters" in the preview box.
- No content is shown in the preview.
Errors
When the view editor loads, this PHP fatal occurs:
PHP Fatal error: Call to a member function getRouteByName() on a non-object in /Library/WebServer/Documents/drupal8x/core/modules/views/src/ViewExecutable.php on line 1818, referer: http://localhost/drupal8x/admin/structure/views/view/taxonomy_term
The browser console error is:
Uncaught AjaxError:
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /drupal8x/admin/structure/views/view/taxonomy_term/preview/page_1
StatusText: Internal Server Error
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#9 | taxonomy_term_view-2452659-9.patch | 2.23 KB | cilefen |
#9 | taxonomy_term_view-2452659-9-test.patch | 770 bytes | cilefen |
#9 | interdiff-8-9.txt | 1.79 KB | cilefen |
#8 | taxonomy_term_view-2452659-8.patch | 1.47 KB | cilefen |
#8 | interdiff-6-8.txt | 675 bytes | cilefen |
Comments
Comment #1
cilefen CreditAttribution: cilefen commentedComment #2
cilefen CreditAttribution: cilefen commentedComment #3
cilefen CreditAttribution: cilefen commentedComment #4
cilefen CreditAttribution: cilefen commentedThe problem is that ViewExecutable::routeProvider has not been set in this case.
Line 1818
Comment #5
cilefen CreditAttribution: cilefen commentedIn this patch, I save the route provider before $executable is destroyed, then re-set it.
Comment #6
cilefen CreditAttribution: cilefen commentedHere is a simpler way to get the same result: Do not strip the routeProvider from ViewExecutable when it is destroyed.
Comment #8
cilefen CreditAttribution: cilefen commentedComment #9
cilefen CreditAttribution: cilefen commentedComment #11
olli CreditAttribution: olli commentedComment #12
dawehnerGood point!
Comment #13
webchickCommitted and pushed to 8.0.x. Thanks!