Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
Noticed this while trying to write a test for #2396253: Respect format configuration on REST views display.
When creating a REST display the preview button is not reacting.
PHP error being thrown in ajax callback:
PHP Fatal error: Method Drupal\Core\Url::__toString() must not throw an exception in /var/www/html/d8.local/drupal/core/modules/views_ui/src/ViewUI.php on line 0
When I apply the patch in #2416971: Remove Url::__toString() a more helpful error is thrown:
Uncaught PHP Exception Symfony\Component\Routing\Exception\RouteNotFoundException: "Route "views.testrest.rest_export_1" does not exist." at /var/www/html/d8.local/drupal/core/lib/Drupal/Core/Routing/RouteProvider.php line 145
Steps to reproduce
- Enable REST module
- Create a new content view
- Add a rest display
- Hit the Preview button
Proposed resolution
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#12 | update-preview-before-patch.png | 157.11 KB | koence |
#12 | update-preview-after-patch.png | 320.69 KB | koence |
#10 | 2443119-10-complete.patch | 2.9 KB | geertvd |
#10 | 2443119-10-test.patch | 2.2 KB | geertvd |
Comments
Comment #1
geertvd CreditAttribution: geertvd commentedComment #2
dawehnerCan you please apply the patch from #2416971: Remove Url::__toString() and have a look what the thrown exception then looks like?
Comment #3
geertvd CreditAttribution: geertvd commentedAfter applying the patch from #2416971: Remove Url::__toString():
Comment #4
geertvd CreditAttribution: geertvd commentedComment #5
geertvd CreditAttribution: geertvd commentedSomething like this fixes that, no idea if this is going to break something else. Let's see what the testbot says.
Comment #6
geertvd CreditAttribution: geertvd commentedAh, seems like a mistake in the committed patch in #2409209: Replace all _url() calls beside the one in _l(). So this is the right way to fix it.
I guess this will definitely need test coverage since this broke once and it might break again. I'll try to pick that up together with #2396253: Respect format configuration on REST views display
Comment #7
geertvd CreditAttribution: geertvd commentedComment #9
dawehnerGreat catch! It would be great if you could write some unit tests on top of that, see
core/modules/views/src/Plugin/views/display/PathPluginBase.php
Comment #10
geertvd CreditAttribution: geertvd commentedFirst time writing one of those. Is something like this ok?
Comment #12
koence CreditAttribution: koence commentedTests were added for getRouteName and views interface for rest export
test result before patch
test result after patch
side note: I did notice that the views preview function for a new display only works AFTER the new display is saved.
I will log this issue if it hasn't been logged already.
Comment #13
koence CreditAttribution: koence commentedComment #14
Sutharsan CreditAttribution: Sutharsan commentedComment #15
alexpottCan we get a followup to prefix all the dynamic routes with views.view instead of view and fix RouteSubscriber::alterRoutes() - it does not need to remove the route from the collection since this is already handled by PathPluginBase::alterRoutes. Plus I think we should introduce a route prefix constant somewhere so that this is easier to maintain. Once the followup exists, I'll commit.
Comment #16
geertvd CreditAttribution: geertvd commentedFollowup created #2450055: Add constant for prefix for views dynamic routes
Comment #17
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 7f4abc7 and pushed to 8.0.x. Thanks!