#1043198: Convert view modes to ConfigEntity converted view modes to entities. By virtue of the magic that is Drupal\Core\ParamConverter\EntityConverter
, this implies that any route that uses {view_mode}
will receive an upcasted view mode entity object instead of a view mode string identifier (like full
or teaser
).
edit.routing.yml
contains
edit_field_form:
pattern: '/edit/form/{entity_type}/{entity}/{field_name}/{langcode}/{view_mode}'
Hence upcasting is also applied to this route. But it's not expected nor needed by EditController::fieldForm(…, $view_mode)
. So the solution is to do a simple s/view_mode/view_mode_id/
in both the function arguments and the routing yml file.
The patch at #1043198: Convert view modes to ConfigEntity forgot to update this part. But that's forgivable, because there should have been test coverage for this. That's my fault.
However, this was extremely hard to track down because it was not EditController::fieldForm()
that failed. It was the routing system itself that failed. Presumably because there's two different entities that are being upcasted in a single route: {entity}
and {view_mode}
. The result was an extremely unhelpful HTTP 404 status and A fatal error occurred:
, without any additional information, nor a watchdog entry.
This issue is solely about fixing Edit module, not about the above problem(s) in the routing system.
The exception itself is available at https://gist.github.com/wimleers/5591825.
Comment | File | Size | Author |
---|---|---|---|
#6 | 1996378-6.patch | 5.85 KB | Wim Leers |
#6 | interdiff.txt | 950 bytes | Wim Leers |
#5 | 1996378-5.patch | 5.29 KB | Wim Leers |
#5 | interdiff.txt | 790 bytes | Wim Leers |
#2 | 1996378-2.patch | 5.03 KB | Wim Leers |
Comments
Comment #1
Wim Leers.
Comment #2
Wim LeersComment #2.0
Wim LeersLink to https://gist.github.com/wimleers/5591825.
Comment #3
Gábor HojtsyGreat added test coverage :)
phpdoc not updated!
Comment #4
fubhy CreditAttribution: fubhy commentedThanks Wim, RTBC if green. This is really a problem introduced by routing/entityconverter and how it functions in general. We are trying to fix that over at #1943846: Improve ParamConverterManager and developer experience for ParamConverters
Comment #5
Wim Leers#3: d'oh :/
#4: thanks!
Comment #6
Wim LeersD'oh… forgot to update the place where the
$view_mode
variable was being used :/Comment #7
fubhy CreditAttribution: fubhy commentedComment #8
chx CreditAttribution: chx commentedalternatively, just rip out the whole routing system. it'd be much better. (Ceterum censeo Carthaginem esse delendam)
Comment #9
Crell CreditAttribution: Crell commentedWhy are we using curlExec directly in Simpletest? I thought Simpletest had access to Guzzle now...
Comment #10
Wim Leers#9: Because I'm copy/pasting from earlier code that I wrote to do this (and which was extremely painful to write BTW), in the same file.
WebTestBase
should have a utility method to build custom AJAX requests, but it does not.We can convert to Guzzle later on. It's out of scope to deal with that in this issue. Also, if it were required to use Guzzle, then all existing tests that use
curlExec()
should have been converted.Comment #11
Crell CreditAttribution: Crell commentedSigh, Simpletest.
We should convert most/all curlExec() to Guzzle, but if this is an existing pattern we don't need to do it here. No sense blocking a critical on that when it could happen at any time, as it's not an API change.
Comment #12
alexpottCommitted 3076bee and pushed to 8.x. Thanks!
Comment #13
Wim LeersThanks for your understanding, Crell :)
And thanks, Alex!
Comment #14
Wim LeersOops.
Comment #15.0
(not verified) CreditAttribution: commented.