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
@ -321,6 +321,17 @@ 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);
|
return array_values($tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user