[COMPONENT][Tag] Do not perform DB::flush in an event
This commit is contained in:
parent
8cd703d68b
commit
10e7c71b6e
@ -74,7 +74,6 @@ class Tag extends Component
|
|||||||
public function onProcessNoteContent(Note $note, string $content, string $content_type, array $extra_args): bool
|
public function onProcessNoteContent(Note $note, string $content, string $content_type, array $extra_args): bool
|
||||||
{
|
{
|
||||||
$matched_tags = [];
|
$matched_tags = [];
|
||||||
$processed_tags = false;
|
|
||||||
preg_match_all(self::TAG_REGEX, $content, $matched_tags, \PREG_SET_ORDER);
|
preg_match_all(self::TAG_REGEX, $content, $matched_tags, \PREG_SET_ORDER);
|
||||||
$matched_tags = array_unique(F\map($matched_tags, fn ($m) => $m[2]));
|
$matched_tags = array_unique(F\map($matched_tags, fn ($m) => $m[2]));
|
||||||
foreach ($matched_tags as $match) {
|
foreach ($matched_tags as $match) {
|
||||||
@ -87,14 +86,10 @@ class Tag extends Component
|
|||||||
'use_canonical' => $extra_args['tag_use_canonical'] ?? false,
|
'use_canonical' => $extra_args['tag_use_canonical'] ?? false,
|
||||||
]));
|
]));
|
||||||
Cache::pushList("tag-{$canonical_tag}", $note);
|
Cache::pushList("tag-{$canonical_tag}", $note);
|
||||||
$processed_tags = true;
|
|
||||||
foreach (self::cacheKeys($canonical_tag) as $key) {
|
foreach (self::cacheKeys($canonical_tag) as $key) {
|
||||||
Cache::delete($key);
|
Cache::delete($key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($processed_tags) {
|
|
||||||
DB::flush();
|
|
||||||
}
|
|
||||||
return Event::next;
|
return Event::next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user