The Needs Review Queue Bot → tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide → to find step-by-step guides for working with issues.
- Status changed to Needs review
over 1 year ago 6:43pm 23 March 2023 - Status changed to Needs work
over 1 year ago 10:53pm 23 March 2023 - Status changed to Needs review
over 1 year ago 6:58am 24 March 2023 - 🇮🇳India mrinalini9 New Delhi
Rerolled patch for 10.1.x branch, please review it.
Thanks!
- Status changed to RTBC
over 1 year ago 11:42pm 25 March 2023 - 🇺🇸United States smustgrave
Issue summary lines up with the solution in the patch
#5 shows that the test case covers the issue. - Status changed to Needs work
over 1 year ago 1:25am 29 March 2023 - Status changed to Needs review
over 1 year ago 7:09pm 29 March 2023 - 🇺🇸United States tim bozeman
Sorry about that! 😅
Here's the test and patch against10.0.7
. The last submitted patch, 18: test-only.patch, failed testing. View results →
- Status changed to RTBC
over 1 year ago 1:12am 31 March 2023 - 🇺🇸United States smustgrave
#16 that was my mistake. See the tests have been added back.
- Status changed to Needs work
over 1 year ago 2:38am 31 March 2023 - 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
I'm not convinced this is the right fix.
If we look at
\Drupal\Core\Routing\RouteMatch::getParameterNames
raw parameters should include defaults.However, the
_raw_variables
set in\Drupal\Core\Routing\Enhancer\ParamConversionEnhancer::copyRawVariables
doesn't give the same treatment to defaults as\Drupal\Core\Routing\RouteMatch::getParameterNames
I think the fix should live in
\Drupal\Core\Routing\Enhancer\ParamConversionEnhancer::copyRawVariables
instead, to make the two of them consistent.This should then render the change in this patch unnecessary and make the two internally consistent.
Thoughts?
- Status changed to Needs review
over 1 year ago 12:51pm 4 April 2023 - 🇺🇸United States tim bozeman
Ah yes, that's the right place to fix this! When we change it in
ParamConversionEnhancer->copyRawVariables()
I no longer need the patch from #2743303-22: EntityForm::getEntityFromRouteMatch() does not support route-level parameters → . Thanks for figuring that out @larowlan! The last submitted patch, 22: test-only.patch, failed testing. View results →
- Status changed to RTBC
over 1 year ago 2:30pm 4 April 2023 - 🇺🇸United States smustgrave
Thanks for updating issue summary too @Tim Bozeman
See the change suggested by @larowlan has been implemented and test-only patch shows the test coverage is still good.
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
🔥 Love it when we get to a simpler solution
This is on my list to commit once we get out of the freeze - which ends at 10pm Thursday in my timezone. There is a four day weekend here, so it likely won't be until Tuesday next week.
-
larowlan →
committed ca0a26d2 on 10.1.x
Issue #3277784 by Tim Bozeman, mrinalini9, larowlan: copyRawVariables...
-
larowlan →
committed ca0a26d2 on 10.1.x
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
Committed to 10.1.x, so this is just awaiting backport post freeze
- 🇺🇸United States tim.plunkett Philadelphia
Glad @larowlan's comment in #21 happened
- 🇺🇸United States tim bozeman
Me too! Here's a back port to 9.5
Thanks again! 🚀
-
larowlan →
committed 7e48dd85 on 10.0.x
Issue #3277784 by Tim Bozeman, mrinalini9, larowlan: copyRawVariables...
-
larowlan →
committed 7e48dd85 on 10.0.x
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
Backported to 10.0.x
Requeued tests on 9.5.x as HEAD had a random fail
-
larowlan →
committed a894a04b on 9.5.x
Issue #3277784 by Tim Bozeman, mrinalini9, larowlan: copyRawVariables...
-
larowlan →
committed a894a04b on 9.5.x
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
Backported to 9.5.x after green test run - thanks all
- Status changed to Fixed
over 1 year ago 2:04am 20 April 2023 Automatically closed - issue fixed for 2 weeks with no activity.
- 🇩🇪Germany jensschuppe
Sorry for posting in a closed issue, just want to be sure this didn't introduce a regression in some form ...
The CiviCRM module has been doing this in a
route_callbacks
callback:$route = new Route( '/' . $path . '/{extra}', [ '_title' => isset($item['title']) ? $item['title'] : 'CiviCRM', '_controller' => 'Drupal\civicrm\Controller\CivicrmController::main', 'args' => explode('/', $path), 'extra' => '', ], [ '_access' => 'TRUE', 'extra' => '.+', ] );
Notice the
args
key within the second argument ($defaults
) passed to theRoute
constructor - all keys not starting with a_
inside that parameter are now (due to this change) eventually being treated as translation parameters (inDrupal/Core/Controller/TitleResolver.php:67
), causing an array being considered a string and eventually resulting in aTypeError: htmlspecialchars(): Argument #1 ($string) must be of type string, array given in htmlspecialchars() (Line 432 in /path/to/drupal/web/core/lib/Drupal/Component/Utility/Html.php)
.Is this
args
key being an array just wrong here or did this issue introduce a regression? Is there documentation on what is allowed to be passed into aRoute
's defaults? - 🇺🇸United States tim bozeman
hmm, I don't know. 😬 The only documentation → I could find didn't really specify if a default can be an array.
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
@jensschuppe can you open a followup for that - I think default arguments can totally be arrays and as such that automagic '@arg' '%arg' should be checking if $value is a scalar - i.e. that sounds like a bug in TitleResolver in my book
- 🇩🇪Germany jensschuppe
@larowlan There's a new issue for the problem: #3352384 ✨ Add Exception for TypeError Argument must be String in \Drupal\Component\Utility\Html escape{} Needs work
I also think that the bug is in
TitleResolver
, at least in conjunction with the new behavior of Drupal 9.5.9 that all route defaults whose keys do not start with an underscore_
are now automatically considered route parameters and thus get copied as arguments for title translation. - 🇩🇪Germany jensschuppe
#3352384 seems to cover another issue, see #3358402 🐛 [regression] route defaults are now automatically route parameters Fixed instead.