From 39448160f16d89b107fe2a32d55450c33f1e8f85 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 13 Jan 2025 09:51:46 +0000 Subject: [PATCH] Replace Logger with DI::logger() in Model Post classes --- src/Model/Post.php | 17 ++++---- src/Model/Post/Delayed.php | 7 ++-- src/Model/Post/Engagement.php | 15 ++++--- src/Model/Post/History.php | 9 ++-- src/Model/Post/Link.php | 11 +++-- src/Model/Post/Media.php | 65 ++++++++++++++--------------- src/Model/Post/SearchIndex.php | 3 +- src/Model/Post/UserNotification.php | 7 ++-- 8 files changed, 63 insertions(+), 71 deletions(-) diff --git a/src/Model/Post.php b/src/Model/Post.php index 3118e2e84c..765ad023ac 100644 --- a/src/Model/Post.php +++ b/src/Model/Post.php @@ -8,7 +8,6 @@ namespace Friendica\Model; use BadMethodCallException; -use Friendica\Core\Logger; use Friendica\Database\Database; use Friendica\Database\DBA; use Friendica\DI; @@ -621,7 +620,7 @@ class Post { $affected = 0; - Logger::info('Start Update', ['fields' => $fields, 'condition' => $condition, 'uid' => DI::userSession()->getLocalUserId()]); + DI::logger()->info('Start Update', ['fields' => $fields, 'condition' => $condition, 'uid' => DI::userSession()->getLocalUserId()]); // Don't allow changes to fields that are responsible for the relation between the records unset($fields['id']); @@ -647,7 +646,7 @@ class Post $puids = array_column($rows, 'post-user-id'); if (!DBA::update('post-user', $update_fields, ['id' => $puids])) { DBA::rollback(); - Logger::warning('Updating post-user failed', ['fields' => $update_fields, 'condition' => $condition]); + DI::logger()->warning('Updating post-user failed', ['fields' => $update_fields, 'condition' => $condition]); return false; } $affected_count += DBA::affectedRows(); @@ -664,7 +663,7 @@ class Post $uriids = array_column($rows, 'uri-id'); if (!DBA::update('post-content', $update_fields, ['uri-id' => $uriids])) { DBA::rollback(); - Logger::warning('Updating post-content failed', ['fields' => $update_fields, 'condition' => $condition]); + DI::logger()->warning('Updating post-content failed', ['fields' => $update_fields, 'condition' => $condition]); return false; } $affected_count += DBA::affectedRows(); @@ -687,7 +686,7 @@ class Post if (!DBA::update('post', $update_fields, ['uri-id' => $uriids])) { DBA::rollback(); - Logger::warning('Updating post failed', ['fields' => $update_fields, 'condition' => $condition]); + DI::logger()->warning('Updating post failed', ['fields' => $update_fields, 'condition' => $condition]); return false; } $affected_count += DBA::affectedRows(); @@ -704,7 +703,7 @@ class Post $uriids = array_column($rows, 'uri-id'); if (!DBA::update('post-delivery-data', $update_fields, ['uri-id' => $uriids])) { DBA::rollback(); - Logger::warning('Updating post-delivery-data failed', ['fields' => $update_fields, 'condition' => $condition]); + DI::logger()->warning('Updating post-delivery-data failed', ['fields' => $update_fields, 'condition' => $condition]); return false; } $affected_count += DBA::affectedRows(); @@ -721,7 +720,7 @@ class Post $uriids = array_column($rows, 'uri-id'); if (!DBA::update('post-thread', $update_fields, ['uri-id' => $uriids])) { DBA::rollback(); - Logger::warning('Updating post-thread failed', ['fields' => $update_fields, 'condition' => $condition]); + DI::logger()->warning('Updating post-thread failed', ['fields' => $update_fields, 'condition' => $condition]); return false; } $affected_count += DBA::affectedRows(); @@ -738,7 +737,7 @@ class Post $thread_puids = array_column($rows, 'post-user-id'); if (!DBA::update('post-thread-user', $update_fields, ['post-user-id' => $thread_puids])) { DBA::rollback(); - Logger::warning('Updating post-thread-user failed', ['fields' => $update_fields, 'condition' => $condition]); + DI::logger()->warning('Updating post-thread-user failed', ['fields' => $update_fields, 'condition' => $condition]); return false; } $affected_count += DBA::affectedRows(); @@ -749,7 +748,7 @@ class Post DBA::commit(); - Logger::info('Updated posts', ['rows' => $affected]); + DI::logger()->info('Updated posts', ['rows' => $affected]); return $affected; } diff --git a/src/Model/Post/Delayed.php b/src/Model/Post/Delayed.php index 666e55c3d4..2e30ba1a59 100644 --- a/src/Model/Post/Delayed.php +++ b/src/Model/Post/Delayed.php @@ -7,7 +7,6 @@ namespace Friendica\Model\Post; -use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\Core\Worker; use Friendica\Database\Database; @@ -45,7 +44,7 @@ class Delayed public static function add(string $uri, array $item, int $notify = 0, int $preparation_mode = self::PREPARED, string $delayed = '', array $taglist = [], array $attachments = []) { if (empty($item['uid']) || self::exists($uri, $item['uid'])) { - Logger::notice('No uid or already found'); + DI::logger()->notice('No uid or already found'); return 0; } @@ -58,7 +57,7 @@ class Delayed DI::pConfig()->set($item['uid'], 'system', 'last_publish', $next_publish); } - Logger::notice('Adding post for delayed publishing', ['uid' => $item['uid'], 'delayed' => $delayed, 'uri' => $uri]); + DI::logger()->notice('Adding post for delayed publishing', ['uid' => $item['uid'], 'delayed' => $delayed, 'uri' => $uri]); $wid = Worker::add(['priority' => Worker::PRIORITY_HIGH, 'delayed' => $delayed], 'DelayedPublish', $item, $notify, $taglist, $attachments, $preparation_mode, $uri); if (!$wid) { @@ -181,7 +180,7 @@ class Delayed $id = Item::insert($item, $notify, $preparation_mode == self::PREPARED); - Logger::notice('Post stored', ['id' => $id, 'uid' => $item['uid'], 'cid' => $item['contact-id'] ?? 'N/A']); + DI::logger()->notice('Post stored', ['id' => $id, 'uid' => $item['uid'], 'cid' => $item['contact-id'] ?? 'N/A']); if (empty($uri) && !empty($item['uri'])) { $uri = $item['uri']; diff --git a/src/Model/Post/Engagement.php b/src/Model/Post/Engagement.php index b48818437c..621d3ee9ec 100644 --- a/src/Model/Post/Engagement.php +++ b/src/Model/Post/Engagement.php @@ -9,7 +9,6 @@ namespace Friendica\Model\Post; use Friendica\Content\Text\BBCode; use Friendica\Core\L10n; -use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\DI; @@ -48,7 +47,7 @@ class Engagement public static function storeFromItem(array $item): int { if (in_array($item['verb'], [Activity::FOLLOW, Activity::VIEW, Activity::READ])) { - Logger::debug('Technical activities are not stored', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'verb' => $item['verb']]); + DI::logger()->debug('Technical activities are not stored', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'verb' => $item['verb']]); return 0; } @@ -59,7 +58,7 @@ class Engagement ['uri-id' => $item['parent-uri-id']]); if ($parent['created'] < self::getCreationDateLimit(false)) { - Logger::debug('Post is too old', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'created' => $parent['created']]); + DI::logger()->debug('Post is too old', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'created' => $parent['created']]); return 0; } @@ -114,16 +113,16 @@ class Engagement ]) ]; if (!$store && ($engagement['comments'] == 0) && ($engagement['activities'] == 0)) { - Logger::debug('No media, follower, subscribed tags, comments or activities. Engagement not stored', ['fields' => $engagement]); + DI::logger()->debug('No media, follower, subscribed tags, comments or activities. Engagement not stored', ['fields' => $engagement]); return 0; } $exists = DBA::exists('post-engagement', ['uri-id' => $engagement['uri-id']]); if ($exists) { $ret = DBA::update('post-engagement', $engagement, ['uri-id' => $engagement['uri-id']]); - Logger::debug('Engagement updated', ['uri-id' => $engagement['uri-id'], 'ret' => $ret]); + DI::logger()->debug('Engagement updated', ['uri-id' => $engagement['uri-id'], 'ret' => $ret]); } else { $ret = DBA::insert('post-engagement', $engagement); - Logger::debug('Engagement inserted', ['uri-id' => $engagement['uri-id'], 'ret' => $ret]); + DI::logger()->debug('Engagement inserted', ['uri-id' => $engagement['uri-id'], 'ret' => $ret]); } return ($ret && !$exists) ? $engagement['uri-id'] : 0; } @@ -369,11 +368,11 @@ class Engagement { $limit = self::getCreationDateLimit(true); if (empty($limit)) { - Logger::notice('Expiration limit not reached'); + DI::logger()->notice('Expiration limit not reached'); return; } DBA::delete('post-engagement', ["`created` < ?", $limit]); - Logger::notice('Cleared expired engagements', ['limit' => $limit, 'rows' => DBA::affectedRows()]); + DI::logger()->notice('Cleared expired engagements', ['limit' => $limit, 'rows' => DBA::affectedRows()]); } private static function getCreationDateLimit(bool $forDeletion): string diff --git a/src/Model/Post/History.php b/src/Model/Post/History.php index 03b6da19d0..192a82996c 100644 --- a/src/Model/Post/History.php +++ b/src/Model/Post/History.php @@ -7,7 +7,6 @@ namespace Friendica\Model\Post; -use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\Database\Database; use Friendica\DI; @@ -28,12 +27,12 @@ class History $post = Post::selectFirstPost($fields, ['uri-id' => $uri_id]); if (empty($post)) { - Logger::warning('Post not found', ['uri-id' => $uri_id]); + DI::logger()->warning('Post not found', ['uri-id' => $uri_id]); return; } if ($item['edited'] <= $post['edited']) { - Logger::info('New edit date is not newer than the old one', ['uri-id' => $uri_id, 'old' => $post['edited'], 'new' => $item['edited']]); + DI::logger()->info('New edit date is not newer than the old one', ['uri-id' => $uri_id, 'old' => $post['edited'], 'new' => $item['edited']]); return; } @@ -49,9 +48,9 @@ class History if ($update) { DBA::insert('post-history', $post, Database::INSERT_IGNORE); - Logger::info('Added history', ['uri-id' => $uri_id, 'edited' => $post['edited']]); + DI::logger()->info('Added history', ['uri-id' => $uri_id, 'edited' => $post['edited']]); } else { - Logger::info('No content fields had been changed', ['uri-id' => $uri_id, 'edited' => $post['edited']]); + DI::logger()->info('No content fields had been changed', ['uri-id' => $uri_id, 'edited' => $post['edited']]); } } } diff --git a/src/Model/Post/Link.php b/src/Model/Post/Link.php index 64901c2c28..2315928186 100644 --- a/src/Model/Post/Link.php +++ b/src/Model/Post/Link.php @@ -7,7 +7,6 @@ namespace Friendica\Model\Post; -use Friendica\Core\Logger; use Friendica\Database\Database; use Friendica\Database\DBA; use Friendica\DI; @@ -53,14 +52,14 @@ class Link } if (!in_array(parse_url($url, PHP_URL_SCHEME), ['http', 'https'])) { - Logger::info('Bad URL, quitting', ['uri-id' => $uriId, 'url' => $url]); + DI::logger()->info('Bad URL, quitting', ['uri-id' => $uriId, 'url' => $url]); return $url; } $link = DBA::selectFirst('post-link', ['id'], ['uri-id' => $uriId, 'url' => $url]); if (!empty($link['id'])) { $id = $link['id']; - Logger::info('Found', ['id' => $id, 'uri-id' => $uriId, 'url' => $url]); + DI::logger()->info('Found', ['id' => $id, 'uri-id' => $uriId, 'url' => $url]); } else { $fields = self::fetchMimeType($url); $fields['uri-id'] = $uriId; @@ -68,7 +67,7 @@ class Link DBA::insert('post-link', $fields, Database::INSERT_IGNORE); $id = DBA::lastInsertId(); - Logger::info('Inserted', $fields); + DI::logger()->info('Inserted', $fields); } if (empty($id)) { @@ -114,12 +113,12 @@ class Link try { $curlResult = HTTPSignature::fetchRaw($url, 0, [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => $accept]); } catch (\Exception $exception) { - Logger::notice('Error fetching url', ['url' => $url, 'exception' => $exception]); + DI::logger()->notice('Error fetching url', ['url' => $url, 'exception' => $exception]); return []; } if (!$curlResult->isSuccess()) { - Logger::notice('Fetching unsuccessful', ['url' => $url]); + DI::logger()->notice('Fetching unsuccessful', ['url' => $url]); return []; } diff --git a/src/Model/Post/Media.php b/src/Model/Post/Media.php index f05b5e0016..7384f71ca5 100644 --- a/src/Model/Post/Media.php +++ b/src/Model/Post/Media.php @@ -9,7 +9,6 @@ namespace Friendica\Model\Post; use Friendica\Content\PageInfo; use Friendica\Content\Text\BBCode; -use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Database\Database; use Friendica\Database\DBA; @@ -67,12 +66,12 @@ class Media public static function insert(array $media, bool $force = false): bool { if (empty($media['url']) || empty($media['uri-id']) || !isset($media['type'])) { - Logger::warning('Incomplete media data', ['media' => $media]); + DI::logger()->warning('Incomplete media data', ['media' => $media]); return false; } if (DBA::exists('post-media', ['uri-id' => $media['uri-id'], 'preview' => $media['url']])) { - Logger::info('Media already exists as preview', ['uri-id' => $media['uri-id'], 'url' => $media['url']]); + DI::logger()->info('Media already exists as preview', ['uri-id' => $media['uri-id'], 'url' => $media['url']]); return false; } @@ -80,12 +79,12 @@ class Media // and embedded as picture then we only store the picture or replace the document $found = DBA::selectFirst('post-media', ['type'], ['uri-id' => $media['uri-id'], 'url' => $media['url']]); if (!$force && !empty($found) && (!in_array($found['type'], [self::UNKNOWN, self::DOCUMENT]) || ($media['type'] == self::DOCUMENT))) { - Logger::info('Media already exists', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'found' => $found['type'], 'new' => $media['type']]); + DI::logger()->info('Media already exists', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'found' => $found['type'], 'new' => $media['type']]); return false; } if (!ItemURI::exists($media['uri-id'])) { - Logger::info('Media referenced URI ID not found', ['uri-id' => $media['uri-id'], 'url' => $media['url']]); + DI::logger()->info('Media referenced URI ID not found', ['uri-id' => $media['uri-id'], 'url' => $media['url']]); return false; } @@ -97,7 +96,7 @@ class Media // We are storing as fast as possible to avoid duplicated network requests // when fetching additional information for pictures and other content. $result = DBA::insert('post-media', $media, Database::INSERT_UPDATE); - Logger::info('Stored media', ['result' => $result, 'media' => $media]); + DI::logger()->info('Stored media', ['result' => $result, 'media' => $media]); $stored = $media; $media = self::fetchAdditionalData($media); @@ -106,9 +105,9 @@ class Media if (array_diff_assoc($media, $stored)) { $result = DBA::insert('post-media', $media, Database::INSERT_UPDATE); - Logger::info('Updated media', ['result' => $result, 'media' => $media]); + DI::logger()->info('Updated media', ['result' => $result, 'media' => $media]); } else { - Logger::info('Nothing to update', ['media' => $media]); + DI::logger()->info('Nothing to update', ['media' => $media]); } return $result; } @@ -183,7 +182,7 @@ class Media return $media; } if (empty($media['mimetype']) || empty($media['size'])) { - Logger::debug('Unknown local link', ['url' => $media['url']]); + DI::logger()->debug('Unknown local link', ['url' => $media['url']]); } } @@ -205,10 +204,10 @@ class Media $media['size'] = (int)($curlResult->getHeader('Content-Length')[0] ?? strlen($curlResult->getBodyString() ?? '')); } } else { - Logger::notice('Could not fetch head', ['media' => $media, 'code' => $curlResult->getReturnCode()]); + DI::logger()->notice('Could not fetch head', ['media' => $media, 'code' => $curlResult->getReturnCode()]); } } catch (\Throwable $th) { - Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); } } @@ -216,7 +215,7 @@ class Media $media = self::addType($media); } - Logger::debug('Got type for url', ['type' => $media['type'], 'mimetype' => $media['mimetype'] ?? '', 'url' => $media['url']]); + DI::logger()->debug('Got type for url', ['type' => $media['type'], 'mimetype' => $media['mimetype'] ?? '', 'url' => $media['url']]); if ($media['type'] == self::IMAGE) { $imagedata = Images::getInfoFromURLCached($media['url'], empty($media['description'])); @@ -228,10 +227,10 @@ class Media $media['blurhash'] = $imagedata['blurhash'] ?? null; if (!empty($imagedata['description']) && empty($media['description'])) { $media['description'] = $imagedata['description']; - Logger::debug('Detected text for image', $media); + DI::logger()->debug('Detected text for image', $media); } } else { - Logger::notice('No image data', ['media' => $media]); + DI::logger()->notice('No image data', ['media' => $media]); } } @@ -309,13 +308,13 @@ class Media $item = Post::selectFirst([], ['id' => $id, 'network' => Protocol::FEDERATED]); if (empty($item['id'])) { - Logger::debug('Not a federated activity', ['id' => $id, 'uri-id' => $media['uri-id'], 'url' => $media['url']]); + DI::logger()->debug('Not a federated activity', ['id' => $id, 'uri-id' => $media['uri-id'], 'url' => $media['url']]); $media['type'] = $media['type'] == self::ACTIVITY ? self::JSON : $media['type']; return $media; } if ($item['uri-id'] == $media['uri-id']) { - Logger::info('Media-Uri-Id is identical to Uri-Id', ['uri-id' => $media['uri-id']]); + DI::logger()->info('Media-Uri-Id is identical to Uri-Id', ['uri-id' => $media['uri-id']]); $media['type'] = $media['type'] == self::ACTIVITY ? self::JSON : $media['type']; return $media; } @@ -324,7 +323,7 @@ class Media !empty($item['plink']) && Strings::compareLink($item['plink'], $media['url']) && parse_url($item['plink'], PHP_URL_HOST) != parse_url($item['uri'], PHP_URL_HOST) ) { - Logger::debug('Not a link to an activity', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]); + DI::logger()->debug('Not a link to an activity', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]); $media['type'] = $media['type'] == self::ACTIVITY ? self::JSON : $media['type']; return $media; } @@ -357,7 +356,7 @@ class Media $media['publisher-name'] = $gserver['site_name'] ?? null; $media['publisher-image'] = null; - Logger::debug('Activity detected', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]); + DI::logger()->debug('Activity detected', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]); return $media; } @@ -399,7 +398,7 @@ class Media $media['publisher-name'] = $gserver['site_name'] ?? null; $media['publisher-image'] = null; - Logger::debug('Account detected', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'uri' => $contact['url']]); + DI::logger()->debug('Account detected', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'uri' => $contact['url']]); return $media; } @@ -415,7 +414,7 @@ class Media if (empty($data['images'][0]['src']) && empty($data['text']) && empty($data['title'])) { if (!empty($media['preview'])) { $media = self::addPreviewData($media); - Logger::debug('Detected site data is empty, use suggested media data instead', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'type' => $data['type']]); + DI::logger()->debug('Detected site data is empty, use suggested media data instead', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'type' => $data['type']]); } } else { $media['preview'] = $data['images'][0]['src'] ?? null; @@ -489,7 +488,7 @@ class Media public static function addType(array $data): array { if (empty($data['mimetype'])) { - Logger::info('No MimeType provided', ['media' => $data]); + DI::logger()->info('No MimeType provided', ['media' => $data]); return $data; } @@ -501,7 +500,7 @@ class Media { $type = explode('/', current(explode(';', $mimeType))); if (count($type) < 2) { - Logger::info('Unknown MimeType', ['type' => $type, 'media' => $mimeType]); + DI::logger()->info('Unknown MimeType', ['type' => $type, 'media' => $mimeType]); return self::UNKNOWN; } @@ -536,10 +535,10 @@ class Media $type = self::APPLICATION; } else { $type = self::UNKNOWN; - Logger::info('Unknown type', ['filetype' => $filetype, 'subtype' => $subtype, 'media' => $mimeType]); + DI::logger()->info('Unknown type', ['filetype' => $filetype, 'subtype' => $subtype, 'media' => $mimeType]); } - Logger::debug('Detected type', ['type' => $type, 'filetype' => $filetype, 'subtype' => $subtype, 'media' => $mimeType]); + DI::logger()->debug('Detected type', ['type' => $type, 'filetype' => $filetype, 'subtype' => $subtype, 'media' => $mimeType]); return $type; } @@ -777,15 +776,15 @@ class Media // Search for pure links if (preg_match_all("/\[url\](https?:.*?)\[\/url\]/ism", $body, $matches)) { foreach ($matches[1] as $url) { - Logger::info('Got page url (link without description)', ['uri-id' => $uriid, 'url' => $url]); + DI::logger()->info('Got page url (link without description)', ['uri-id' => $uriid, 'url' => $url]); $result = self::insert(['uri-id' => $uriid, 'type' => self::UNKNOWN, 'url' => $url], false); if ($result && !in_array($network, [Protocol::ACTIVITYPUB, Protocol::DIASPORA])) { self::revertHTMLType($uriid, $url, $fullbody); - Logger::debug('Revert HTML type', ['uri-id' => $uriid, 'url' => $url]); + DI::logger()->debug('Revert HTML type', ['uri-id' => $uriid, 'url' => $url]); } elseif ($result) { - Logger::debug('Media had been added', ['uri-id' => $uriid, 'url' => $url]); + DI::logger()->debug('Media had been added', ['uri-id' => $uriid, 'url' => $url]); } else { - Logger::debug('Media had not been added', ['uri-id' => $uriid, 'url' => $url]); + DI::logger()->debug('Media had not been added', ['uri-id' => $uriid, 'url' => $url]); } } } @@ -793,15 +792,15 @@ class Media // Search for links with descriptions if (preg_match_all("/\[url\=(https?:.*?)\].*?\[\/url\]/ism", $body, $matches)) { foreach ($matches[1] as $url) { - Logger::info('Got page url (link with description)', ['uri-id' => $uriid, 'url' => $url]); + DI::logger()->info('Got page url (link with description)', ['uri-id' => $uriid, 'url' => $url]); $result = self::insert(['uri-id' => $uriid, 'type' => self::UNKNOWN, 'url' => $url], false); if ($result && !in_array($network, [Protocol::ACTIVITYPUB, Protocol::DIASPORA])) { self::revertHTMLType($uriid, $url, $fullbody); - Logger::debug('Revert HTML type', ['uri-id' => $uriid, 'url' => $url]); + DI::logger()->debug('Revert HTML type', ['uri-id' => $uriid, 'url' => $url]); } elseif ($result) { - Logger::debug('Media has been added', ['uri-id' => $uriid, 'url' => $url]); + DI::logger()->debug('Media has been added', ['uri-id' => $uriid, 'url' => $url]); } else { - Logger::debug('Media has not been added', ['uri-id' => $uriid, 'url' => $url]); + DI::logger()->debug('Media has not been added', ['uri-id' => $uriid, 'url' => $url]); } } } @@ -838,7 +837,7 @@ class Media return; } - Logger::info('Adding attachment data', ['data' => $data]); + DI::logger()->info('Adding attachment data', ['data' => $data]); $attachment = [ 'uri-id' => $uriid, 'type' => self::HTML, diff --git a/src/Model/Post/SearchIndex.php b/src/Model/Post/SearchIndex.php index 61410871e2..1c57f77942 100644 --- a/src/Model/Post/SearchIndex.php +++ b/src/Model/Post/SearchIndex.php @@ -8,7 +8,6 @@ namespace Friendica\Model\Post; use Friendica\Core\L10n; -use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Database\Database; use Friendica\Database\DBA; @@ -74,7 +73,7 @@ class SearchIndex return; } DBA::delete('post-searchindex', ["`created` < ?", $limit]); - Logger::notice('Cleared expired searchindex entries', ['limit' => $limit, 'rows' => DBA::affectedRows()]); + DI::logger()->notice('Cleared expired searchindex entries', ['limit' => $limit, 'rows' => DBA::affectedRows()]); } public static function searchAgeDateLimit(): string diff --git a/src/Model/Post/UserNotification.php b/src/Model/Post/UserNotification.php index 35c3d7891c..e72d3ac353 100644 --- a/src/Model/Post/UserNotification.php +++ b/src/Model/Post/UserNotification.php @@ -10,7 +10,6 @@ namespace Friendica\Model\Post; use BadMethodCallException; use Exception; use Friendica\Core\Hook; -use Friendica\Core\Logger; use Friendica\Database\Database; use Friendica\Database\DBA; use Friendica\DI; @@ -174,14 +173,14 @@ class UserNotification continue; } if (Contact\User::isBlocked($author_id, $uid) || Contact\User::isIgnored($author_id, $uid) || Contact\User::isCollapsed($author_id, $uid)) { - Logger::debug('Author is blocked/ignored/collapsed by user', ['uid' => $uid, 'author' => $author_id, 'uri-id' => $item['uri-id']]); + DI::logger()->debug('Author is blocked/ignored/collapsed by user', ['uid' => $uid, 'author' => $author_id, 'uri-id' => $item['uri-id']]); return; } } foreach (array_unique([$parent['author-gsid'], $parent['owner-gsid'], $parent['causer-gsid'], $item['author-gsid'], $item['owner-gsid'], $item['causer-gsid']]) as $gsid) { if ($gsid && DI::userGServer()->isIgnoredByUser($uid, $gsid)) { - Logger::debug('Server is ignored by user', ['uid' => $uid, 'gsid' => $gsid, 'uri-id' => $item['uri-id']]); + DI::logger()->debug('Server is ignored by user', ['uid' => $uid, 'gsid' => $gsid, 'uri-id' => $item['uri-id']]); return; } } @@ -313,7 +312,7 @@ class UserNotification return; } - Logger::info('Set notification', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'notification-type' => $notification_type]); + DI::logger()->info('Set notification', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'notification-type' => $notification_type]); $fields = ['notification-type' => $notification_type]; Post\User::update($item['uri-id'], $uid, $fields);