[wp-trac] [WordPress Trac] #59206: PHP warning/error when using `[caption]` shortcode without attributes

WordPress Trac noreply at wordpress.org
Wed Aug 30 11:30:57 UTC 2023


#59206: PHP warning/error when using `[caption]` shortcode without attributes
--------------------------+---------------------
 Reporter:  maltfield     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  6.4
Component:  Media         |     Version:  6.3
 Severity:  normal        |  Resolution:  fixed
 Keywords:  has-patch     |     Focuses:
--------------------------+---------------------

Comment (by SergeyBiryukov):

 Replying to [comment:5 aslamdoctor]:
 > The error appeared whenever there were no arguments passed to the
 [caption] shortcode. Which ended up $attr to be undefined variable.

 It appears that `$attr` is still defined, but as an empty string. Tracked
 this down to `shortcode_parse_atts()` returning an empty string instead of
 an array if the shortcode does not have any attributes, see #59249.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59206#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list