[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 public function onParseLinkTemplate(ParseLinkTemplateEvent $event): void
{ {
$tags = $event->image->get_tag_list(); // get_tag_list can trigger a database query,
$tags = str_replace("/", "", $tags); // so we only want to do it if we need to
$tags = ltrim($tags, "."); if (str_contains($event->link, '$tags')) {
$event->replace('$tags', $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 private function mass_tag_edit(string $search, string $replace, bool $commit): void