]> git.mxchange.org Git - friendica.git/commitdiff
Performance: Moved filter call after content generation
authorMichael <heluecht@pirati.ca>
Tue, 27 Jul 2021 12:24:22 +0000 (12:24 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 27 Jul 2021 12:24:22 +0000 (12:24 +0000)
src/Model/Item.php

index 5cf6f5432f4d341c87d67ac5aa595bb29b751154..7cda359003c8c31cb5d2eb9d7dc88bc85e3a4033 100644 (file)
@@ -2726,22 +2726,6 @@ class Item
                $item['hashtags'] = $tags['hashtags'];
                $item['mentions'] = $tags['mentions'];
 
-               // Compile eventual content filter reasons
-               $filter_reasons = [];
-               if (!$is_preview && public_contact() != $item['author-id']) {
-                       if (!empty($item['content-warning']) && (!local_user() || !DI::pConfig()->get(local_user(), 'system', 'disable_cw', false))) {
-                               $filter_reasons[] = DI::l10n()->t('Content warning: %s', $item['content-warning']);
-                       }
-
-                       $hook_data = [
-                               'item' => $item,
-                               'filter_reasons' => $filter_reasons
-                       ];
-                       Hook::callAll('prepare_body_content_filter', $hook_data);
-                       $filter_reasons = $hook_data['filter_reasons'];
-                       unset($hook_data);
-               }
-
                $body = $item['body'] ?? '';
                $shared = BBCode::fetchShareAttributes($body);
                if (!empty($shared['guid'])) {
@@ -2765,6 +2749,22 @@ class Item
                $item['body'] = $body;
                $s = $item["rendered-html"];
 
+               // Compile eventual content filter reasons
+               $filter_reasons = [];
+               if (!$is_preview && public_contact() != $item['author-id']) {
+                       if (!empty($item['content-warning']) && (!local_user() || !DI::pConfig()->get(local_user(), 'system', 'disable_cw', false))) {
+                               $filter_reasons[] = DI::l10n()->t('Content warning: %s', $item['content-warning']);
+                       }
+
+                       $hook_data = [
+                               'item' => $item,
+                               'filter_reasons' => $filter_reasons
+                       ];
+                       Hook::callAll('prepare_body_content_filter', $hook_data);
+                       $filter_reasons = $hook_data['filter_reasons'];
+                       unset($hook_data);
+               }
+
                $hook_data = [
                        'item' => $item,
                        'html' => $s,