- Issue created by @hoffismo
- 🇦🇺Australia hoffismo Brisbane, Queensland
Adding initial patch but requires tests.
- First commit to issue fork.
- Status changed to Needs review
7 months ago 10:58am 30 May 2024 - Status changed to Postponed: needs info
7 months ago 1:22pm 30 May 2024 - 🇺🇸United States smustgrave
The steps appear to require contrib modules. Is this reproducible in core?
- Status changed to Needs review
7 months ago 9:27pm 4 June 2024 - 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
larowlan → changed the visibility of the branch 3450635-numeric-content-inside to hidden.
- Status changed to Needs work
7 months ago 9:36pm 4 June 2024 - 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
@hoffismo can you provide the stack trace of the error you're seeing here?
I'm guessing you've got a hook_tokens somewhere that is using strict types and that's the issue - core isn't strict-typed yet.
We can't make the current change in the MR as it has BC implications.
The correct way to do this would be to check the type of the $type and if it's not a string, then trigger a deprecation error and cast it.
That would allow callers to be notified and updated before the next major.
However, I think the fact its getting called with an integer type might be a mistake - I think the correct fix would likely be in `\Drupal\Core\Utility\Token::doReplace` where it is iterating
foreach ($text_tokens as $type => $tokens) { $replacements += $this->generate($type, $tokens, $data, $options, $bubbleable_metadata); if (!empty($options['clear'])) { $replacements += array_fill_keys($tokens, ''); } }
I think here
$type
should be checked against valid types.E.g something like
$info = $this->getInfo(); foreach (array_intersect_key($text_tokens, $info) as $type => $tokens) {
That should prevent it even being called with `16`
- 🇦🇺Australia hoffismo Brisbane, Queensland
Thanks @larowlan. I've attached a stack trace. Yes that's correct, we do have a hook_tokens() in a custom module declaring the $type as string. I can confirm removing that does work to align it with core, since it's not strict typed as yet.
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
Thanks @hoffismo - I think that probably unblocks you for now too 👍️
- 🇳🇿New Zealand quietone
This needs to be committed to 11.x (which is main) first and then applied to branches.