[post_tags] avoid DB call if not needed
This commit is contained in:
parent
b97827a6af
commit
5c4b7c1284
1 changed files with 8 additions and 4 deletions
|
@ -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
|
||||||
|
|
Reference in a new issue