Opened 4 weeks ago
Last modified 4 weeks ago
#62454 new enhancement
[ wp-includes/shortcodes.php - do_shortcode() ] - fallback in case content is not a string
Reported by: | riccardodicurti | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | trivial | Version: | |
Component: | Shortcodes | Keywords: | has-patch dev-feedback |
Focuses: | Cc: |
Description
Good morning everyone, while working on a project on php 8, I found that a plugin was passing content to do_shortcode() that was not a string and this led to an error.
In my opinion, it would therefore be better to add a check, like
if(! is_string($content) ) { return $content; }
, in order to check what is then passed str_contains().
Thanks in advance.
Change History (5)
This ticket was mentioned in PR #7816 on WordPress/wordpress-develop by @umeshsinghin.
4 weeks ago
#1
- Keywords has-patch added
#2
@
4 weeks ago
Hi,
As per the suggested changes, I have implemented the fixes. Please review and confirm.
#3
@
4 weeks ago
Ciao @umeshsinghin, thanks for the pull request. I have tested it with a couple of shortcodes and see no problems.
#5
@
4 weeks ago
Hi there, thanks for the ticket!
This looks similar to the discussions in #17299, #18927, #23767, #27489, and #48035 (those tickets are unrelated to this particular function, but they suggest a similar enhancement for other functions). The consensus was that we should not hide warnings caused by developer errors, unless there is a strong reason. It would just make debugging harder.
If a valid parameter generates a warning, we should certainly fix that. However, in case of an invalid parameter, I think the warning (or an error on PHP 8.0+) is to be expected.
https://core.trac.wordpress.org/ticket/62454