]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Individual callstacks are removed from the logger
[friendica.git] / src / Model / Item.php
index 55884a802eeef1099c096434a9dff21f17ae74d0..04853314f5b90adf34659439982307c53ac6ef36 100644 (file)
@@ -49,7 +49,6 @@ use Friendica\Util\Proxy;
 use Friendica\Util\Strings;
 use Friendica\Util\Temporal;
 use GuzzleHttp\Psr7\Uri;
-use IntlChar;
 use LanguageDetection\Language;
 
 class Item
@@ -331,7 +330,7 @@ class Item
         */
        public static function markForDeletionById(int $item_id, int $priority = Worker::PRIORITY_HIGH): bool
        {
-               Logger::info('Mark item for deletion by id', ['id' => $item_id, 'callstack' => System::callstack()]);
+               Logger::info('Mark item for deletion by id', ['id' => $item_id]);
                // locate item to be deleted
                $fields = [
                        'id', 'uri', 'uri-id', 'uid', 'parent', 'parent-uri-id', 'origin',
@@ -796,7 +795,7 @@ class Item
                }
 
                if (!DBA::isResult($parent)) {
-                       Logger::notice('item parent was not found - ignoring item', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid'], 'callstack' => System::callstack(20)]);
+                       Logger::notice('item parent was not found - ignoring item', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
                        return [];
                }
 
@@ -1184,7 +1183,7 @@ class Item
                        if (!empty($quote_id)) {
                                // This is one of these "should not happen" situations.
                                // The protocol implementations should already have done this job.
-                               Logger::notice('Quote-uri-id detected in post', ['id' => $quote_id, 'guid' => $item['guid'], 'uri-id' => $item['uri-id'], 'callstack' => System::callstack(20)]);
+                               Logger::notice('Quote-uri-id detected in post', ['id' => $quote_id, 'guid' => $item['guid'], 'uri-id' => $item['uri-id']]);
                                $item['quote-uri-id'] = $quote_id;
                        }
                }
@@ -2064,6 +2063,10 @@ class Item
         */
        private static function splitByBlocks(string $body): array
        {
+               if (!class_exists('IntlChar')) {
+                       return [$body];
+               }
+
                $blocks         = [];
                $previous_block = 0;
 
@@ -2072,12 +2075,12 @@ class Item
                        $previous  = ($i > 0) ? mb_substr($body, $i - 1, 1) : '';
                        $next      = ($i < mb_strlen($body)) ? mb_substr($body, $i + 1, 1) : '';
 
-                       if (!IntlChar::isalpha($character)) {
-                               if (($previous != '') && (IntlChar::isalpha($previous))) {
+                       if (!\IntlChar::isalpha($character)) {
+                               if (($previous != '') && (\IntlChar::isalpha($previous))) {
                                        $previous_block = self::getBlockCode($previous);
                                }
 
-                               $block = (($next != '') && IntlChar::isalpha($next)) ? self::getBlockCode($next) : $previous_block;
+                               $block = (($next != '') && \IntlChar::isalpha($next)) ? self::getBlockCode($next) : $previous_block;
                                $blocks[$block] = ($blocks[$block] ?? '') . $character;
                        } else {
                                $block = self::getBlockCode($character);
@@ -2103,7 +2106,7 @@ class Item
         */
        private static function getBlockCode(string $character): int
        {
-               if (!IntlChar::isalpha($character)) {
+               if (!\IntlChar::isalpha($character)) {
                        return 0;
                }
                return self::isLatin($character) ? 1 : 2;
@@ -2117,11 +2120,11 @@ class Item
         */
        private static function isLatin(string $character): bool
        {
-               return in_array(IntlChar::getBlockCode($character), [
-                       IntlChar::BLOCK_CODE_BASIC_LATIN, IntlChar::BLOCK_CODE_LATIN_1_SUPPLEMENT,
-                       IntlChar::BLOCK_CODE_LATIN_EXTENDED_A, IntlChar::BLOCK_CODE_LATIN_EXTENDED_B,
-                       IntlChar::BLOCK_CODE_LATIN_EXTENDED_C, IntlChar::BLOCK_CODE_LATIN_EXTENDED_D,
-                       IntlChar::BLOCK_CODE_LATIN_EXTENDED_E, IntlChar::BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL
+               return in_array(\IntlChar::getBlockCode($character), [
+                       \IntlChar::BLOCK_CODE_BASIC_LATIN, \IntlChar::BLOCK_CODE_LATIN_1_SUPPLEMENT,
+                       \IntlChar::BLOCK_CODE_LATIN_EXTENDED_A, \IntlChar::BLOCK_CODE_LATIN_EXTENDED_B,
+                       \IntlChar::BLOCK_CODE_LATIN_EXTENDED_C, \IntlChar::BLOCK_CODE_LATIN_EXTENDED_D,
+                       \IntlChar::BLOCK_CODE_LATIN_EXTENDED_E, \IntlChar::BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL
                ]);
        }
 
@@ -2131,7 +2134,7 @@ class Item
 
                $used_languages = '';
                foreach (json_decode($item['language'], true) as $language => $reliability) {
-                       $used_languages .= $iso639->languageByCode1($language) . ' (' . $language . "): " . number_format($reliability, 5) . '\n';
+                       $used_languages .= $iso639->nativeByCode1(substr($language, 0, 2)) . ' (' . $iso639->languageByCode1(substr($language, 0, 2)) . ' - ' . $language . "): " . number_format($reliability, 5) . '\n';
                }
                $used_languages = DI::l10n()->t('Detected languages in this post:\n%s', $used_languages);
                return $used_languages;
@@ -2159,7 +2162,7 @@ class Item
 
                $hostPart = $host ?: $parsed['host'] ?? '';
                if (!$hostPart) {
-                       Logger::warning('Empty host GUID part', ['uri' => $uri, 'host' => $host, 'parsed' => $parsed, 'callstack' => System::callstack(10)]);
+                       Logger::warning('Empty host GUID part', ['uri' => $uri, 'host' => $host, 'parsed' => $parsed]);
                }
 
                // Glue it together to be able to make a hash from it
@@ -3480,11 +3483,8 @@ class Item
                                continue;
                        }
 
-                       if ($PostMedia->mimetype->type == 'image') {
-                               $preview_size = $PostMedia->width > $PostMedia->height ? Proxy::SIZE_MEDIUM : Proxy::SIZE_LARGE;
-                               $preview_url = DI::baseUrl() . $PostMedia->getPreviewPath($preview_size);
-                       } elseif ($PostMedia->preview) {
-                               $preview_size = Proxy::SIZE_LARGE;
+                       if ($PostMedia->mimetype->type == 'image' || $PostMedia->preview) {
+                               $preview_size = Proxy::SIZE_MEDIUM;
                                $preview_url = DI::baseUrl() . $PostMedia->getPreviewPath($preview_size);
                        } else {
                                $preview_size = 0;