[wp-trac] [WordPress Trac] #33517: Crash After Registering 500+ Shortcodes
WordPress Trac
noreply at wordpress.org
Thu Oct 1 21:23:06 UTC 2015
#33517: Crash After Registering 500+ Shortcodes
-----------------------------------------------+--------------------------
Reporter: thepolishlad | Owner: miqrogroove
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 4.4
Component: Shortcodes | Version:
Severity: normal | Resolution: fixed
Keywords: roadmap needs-testing wptexturize | Focuses:
-----------------------------------------------+--------------------------
Comment (by gitlost):
The `$matches[1]` would be better wrapped in an `array_unique()` to avoid
duplicates. Also I think it would be nice to put this logic in a function
as apart from DRY it's generally useful and would be one small step to
reduce references to the global shortcodes array and to APIize shortcodes,
eg
{{{
/**
* Return registered shortcode tagnames, reduced to those in $text if
given.
*/
function get_shortcode_tagnames( $text = null ) {
global $shortcode_tags;
if ( ! $shortcode_tags || ! is_array( $shortcode_tags ) ) {
return array();
}
if ( null === $text ) {
return array_keys( $shortcode_tags );
}
if ( false === strpos( $text, '[' ) || ! preg_match_all(
'@\[/?\K[^<>&/\[\]\x00-\x20]++@', $text, $matches ) ) {
return array();
}
return array_values( array_intersect( array_unique( $matches[0] ),
array_keys( $shortcode_tags ) ) );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33517#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list