Performance: Reuse list of disallowed tags

This commit is contained in:
Toby Zerner 2017-11-11 22:43:07 +10:30
parent 910ddc9f55
commit 6f07aef206

View File

@ -29,7 +29,11 @@ class TagPolicy extends AbstractPolicy
*/
public function addToDiscussion(User $actor, Tag $tag)
{
$disallowedTags = Tag::getIdsWhereCannot($actor, 'discussion.startWithoutApproval');
static $disallowedTags;
if (! $disallowedTags) {
$disallowedTags = Tag::getIdsWhereCannot($actor, 'discussion.startWithoutApproval');
}
if (in_array($tag->id, $disallowedTags)) {
return false;