I'm currently porting the force_password_change module to D8. I found a bug with the following code:
force_password_change.admin:
path: "/admin/config/people/force_password_change"
defaults:
_controller: "Drupal\force_password_change\Controller\ForcePasswordChangeController::adminPage"
I was getting the following error:
ReflectionException: Class \Drupal
orce_password_change\Controller\ForcePasswordChangeController does not exist in /Users/jay/websites/d8/core/lib/Drupal/Core/Entity/EntityResolverManager.php:123
Note the line break after Drupal, and before orce_password_change.
The system is treating the backslash-f as a linebreak when inside quotes.
Comments
Comment #2
cilefen commentedCould this be #2792877: Symfony YAML parser fails on some strings when running PHP 7?
Comment #3
cspitzlayNo, I do not think the two issues are related.
#2792877: Symfony YAML parser fails on some strings when running PHP 7 is about an exceeded stack limit in the pcre jit implementation of PHP7.
This issue (#2838533: *.routing.yml - using \f (backslash f) inside quotes in for _controller results in an error) is about backslash-f being erroneously decoded into a form feed character if I am not mistaken (see https://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/backslash_co... ).
Comment #4
cilefen commentedFair enough - you definitely did more reading than I. But given that, I feel this is miscategorized in the routing system. Ostensibly, it could happen in any YAML file. Is that correct?
Comment #5
cilefen commentedSo this seems fundamental to YAML itself and not a Drupal bug.
Comment #6
cilefen commentedYou must single-quote or escape backslashes:
Comment #7
cspitzlayYes, I have just come to the same conclusion.
I think it would also work with the original string if single quotes were used:
'Drupal\force_password_change\Controller\ForcePasswordChangeController::adminPage'
edit: Oops, that's what you already stated. :)
Comment #8
cilefen commentedYes, and I should have realized the solution sooner, but I had just seen updates on #2792877: Symfony YAML parser fails on some strings when running PHP 7 and made wrong assumptions.
Comment #9
jaypanThanks guys. I added a note to one of the documentation pages mentioning to use single quotes instead of double quotes: https://www.drupal.org/docs/8/api/routing-system/introductory-drupal-8-r...