[post_tags] avoid DB call if not needed

This commit is contained in:
Shish 2024-02-16 16:41:00 +00:00
parent b97827a6af
commit 5c4b7c1284

View file

@ -186,10 +186,14 @@ class PostTags extends Extension
public function onParseLinkTemplate(ParseLinkTemplateEvent $event): void
{
$tags = $event->image->get_tag_list();
$tags = str_replace("/", "", $tags);
$tags = ltrim($tags, ".");
$event->replace('$tags', $tags);
// get_tag_list can trigger a database query,
// so we only want to do it if we need to
if (str_contains($event->link, '$tags')) {
$tags = $event->image->get_tag_list();
$tags = str_replace("/", "", $tags);
$tags = ltrim($tags, ".");
$event->replace('$tags', $tags);
}
}
private function mass_tag_edit(string $search, string $replace, bool $commit): void