mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Performance/reliability improvement for leaving unrecognised tags.
error_behaviour = self::LEAVE is the default behaviour. In this case, we don’t even need to bother recognising such tags. Rather than replacing with marker images and re-inserting the original text after we’re done, we can leave them alone. This should make the code faster and more reliable.
This commit is contained in:
parent
6d05c57881
commit
d7241958ff
@ -320,7 +320,18 @@ class ShortcodeParser extends Object {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Step 3: remove any tags that don't have handlers registered
|
||||
// Only do this if self::$error_behavior == self::LEAVE
|
||||
// This is optional but speeds things up.
|
||||
if(self::$error_behavior == self::LEAVE) {
|
||||
foreach($tags as $i => $tag) {
|
||||
if(empty($this->shortcodes[$tag['open']])) {
|
||||
unset($tags[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($tags);
|
||||
}
|
||||
|
||||
@ -550,7 +561,7 @@ class ShortcodeParser extends Object {
|
||||
|
||||
// Find the parents. Do this before DOM modification, since SPLIT might cause parents to move otherwise
|
||||
$parents = $this->findParentsForMarkers($shortcodes);
|
||||
|
||||
|
||||
foreach($shortcodes as $shortcode) {
|
||||
$tag = $tags[$shortcode->getAttribute('data-tagid')];
|
||||
$parent = $parents[$shortcode->getAttribute('data-parentid')];
|
||||
|
Loading…
Reference in New Issue
Block a user