- Issue created by @ro-no-lo
- 🇩🇪Germany ro-no-lo
I might have found the cause, and "yay" it's a PHP fault.
In the
site_settings.token.inc
is this line:// Break apart name. $name_parts = explode('--', $name); $group = $name_parts[0]; $type = $name_parts[1] ?? NULL; // We may be deep into a multidimensional array. if (isset($name_parts[2]) && !empty($name_parts[2])) {
but if the
$name_parts[2]
is a string with the number 0 in it like"0"
, PHP will say that !empty($name_parts[2]) is false. With the number "1" it says true.See https://onlinephp.io?s=s7EvyCjg5VJJLCpKrFSwVYjm5eJUKs4sSY0vTi0pycxLL1bSA...
So I think the condition could be updated to this:
if (isset($name_parts[2]) && (!empty($name_parts[2]) || $name_parts[2] === "0")) {
after that change it worked for me as expected.
- First commit to issue fork.
- 🇬🇧United Kingdom scott_euser
Thanks for the details! Yes I can see that being an issue. Can you try out this merge request and see if it solves for you. I did a tiny bit of code cleanup as well in there, but essentially took a slightly different approach checking if its got any string length otherwise also things like 0.0 would result in empty being true.
- Status changed to Needs review
5 months ago 9:28am 24 July 2024 - 🇬🇧United Kingdom scott_euser
If you can confirm it also sorts it then I'll get this into the next release. We don't really use the token functionality on our sites at my agency so I don't have a good way to test.
-
scott_euser →
committed c9a8cabd on 2.0.x
Issue #3462623 by scott_euser, ro-no-lo: Token gets replaced with "Array...
-
scott_euser →
committed c9a8cabd on 2.0.x
- Status changed to Fixed
5 months ago 1:30pm 24 July 2024 - 🇬🇧United Kingdom scott_euser
Added better test coverage to confirm. Feel free to raise follow-up if any further issues.
Automatically closed - issue fixed for 2 weeks with no activity.