-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ShortCodeParser: A parameter value of 0 is ignored by the parser and fails. #2382
Comments
I'd be interested to see the custom-logic you had written that requires something with an id of '0' in it. I'm not being dismissive, but need to ascertain if this is going potentially be a problem for other devs. FYI I can replicate simply by linking to another page in the CMS, manually updating the ID to be '0' and viewing that page's front-end, just not sure at this point, what other scenarios would result in the same issue. FYI the observed behaviour is a direct result of running |
Am unsure at the moment on what to do here. On the one hand there is no evidence (yet) of how other's may be affected by this. On the other hand the logic itself isn't the best - allowing assignment via the |
$attrrx has three possible options (value surrounded by ', by " or bare), and the array_filter was supposed to cut that down to just the one actually provided, but I had forgotten about false-ish values. Just pass in a callback that doesn't convert type (so |
@hafriedlander yup, experimenting with the callback as I write. |
@hafriedlander when you get time (!!) please review the two tests in c154bbf, particularly Many thanks. |
@hafriedlander I 've tried setting the value to '0' or "0", but does not work . Produces the same problem. In my system, specifically, the values assigned by an end user to custom descriptions take values from 1..., and the value 0 is the default description. But this kind of problem can be presented to any user who has to use a parameter with value 0. This is clearly a bug. I do not think that other users have many problems with this issue because of SilverStripe shortcodes system is too limited to do more complex things and I do not think that many people are using it. Ideally, future Silverstripe versions would do a better system shortcodes. Thank you for your efforts to solve this problem. Regards, |
@Josua2012 it's OK, I think it's a bug too :-) The simple fix in |
- Errors are thrown in front-end should the parser encounter a shortcode with a value of '0' - Added test
@hafriedlander Does this look good to you? |
Yeah sorry guys, am right in the middle of a mini home-reno to get the house on the market. I will follow up with any edge cases, if still required next week. FWIW the specific issue raised here is fixed by the related PR. |
This issue is still around in 3.1.15: the fix in #2417 works for me. |
This is an issue for me still also |
#2417 still needs a fix before it can be merged - as it is, it fixes a subset of the larger issue ( |
I'll see about fixing this up for the 2.2.2 release (and 3.3.0) |
Bump |
I'm not gonna have time I think. :) Too late to get this into 3.3.0. |
I'll have a look for SS4, seems to be the too broad empty check. |
It was fixed with 8ae794e#diff-419fde14ad0518fd3b25838354c25674L265 in 4.x. |
Fixed in 3.2+ with #5761 Note that @hafriedlander's example edgecase of |
This type of shortcode:
[SendaContent id='0']
produces the following error:
This occurs for this code:
function extractTags($content) (ShortcodeParser.php)
since the variable $attr contains the following array:
And the following code modifies the array
Now the array contains only two elements:
which makes the error occurs when assigned to
Please, fix this problem as soon as possible.
Thanks,
Regards,
Jose A.
The text was updated successfully, but these errors were encountered: