From 0965a84929362a9b6ce8c6a89601a937e572a2ac Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 2 Nov 2024 22:24:10 +0100 Subject: [PATCH 01/38] install PHPStan for static code analysis --- .phpstan.neon | 9 ++++++++ composer.json | 2 ++ composer.lock | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 .phpstan.neon diff --git a/.phpstan.neon b/.phpstan.neon new file mode 100644 index 0000000000..d69bb2f99c --- /dev/null +++ b/.phpstan.neon @@ -0,0 +1,9 @@ +parameters: + level: 0 + + paths: + - src/ + + scanDirectories: + - mod + - vendor diff --git a/composer.json b/composer.json index 0280409716..706ee3f0e4 100644 --- a/composer.json +++ b/composer.json @@ -152,10 +152,12 @@ "mikey179/vfsstream": "^1.6", "mockery/mockery": "^1.3", "php-mock/php-mock-phpunit": "^2.10", + "phpstan/phpstan": "^1.12", "phpunit/phpunit": "^9" }, "scripts": { "test": "phpunit", + "phpstan": "phpstan analyze --memory-limit 1024M --configuration .phpstan.neon", "lint": "find . -name \\*.php -not -path './vendor/*' -not -path './view/asset/*' -print0 | xargs -0 -n1 php -l", "docker:translate": "docker run --rm -v $PWD:/data -w /data friendicaci/transifex bin/run_xgettext.sh", "cs:install": "@composer install --working-dir=bin/dev/php-cs-fixer", diff --git a/composer.lock b/composer.lock index fae42ffe16..7d1e831b14 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d51158b9593011921144e90af146a86a", + "content-hash": "11175d4e9806e8a5069d010140431af1", "packages": [ { "name": "asika/simple-console", @@ -4832,6 +4832,64 @@ ], "time": "2024-02-11T07:24:16+00:00" }, + { + "name": "phpstan/phpstan", + "version": "1.12.7", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", + "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2024-10-18T11:12:07+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.31", From adb1bd2ad002a662c0a0f63507d9ae943b8ec7c2 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sun, 3 Nov 2024 11:24:15 +0100 Subject: [PATCH 02/38] Add license note an scan directory for PHPStan --- .phpstan.neon | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.phpstan.neon b/.phpstan.neon index d69bb2f99c..ab1b5e1dc2 100644 --- a/.phpstan.neon +++ b/.phpstan.neon @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2010 - 2024 the Friendica project +# +# SPDX-License-Identifier: CC0-1.0 + parameters: level: 0 @@ -7,3 +11,4 @@ parameters: scanDirectories: - mod - vendor + - view From c5dac44c8f2b8a0c1c8892fdf57f26ef15604590 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sun, 3 Nov 2024 15:49:44 +0100 Subject: [PATCH 03/38] add missing return statement --- src/Util/Temporal.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index 0ce59bfaf0..d3ed346908 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -359,6 +359,8 @@ class Temporal return sprintf($format, $r, (($r == 1) ? $str[0] : $str[1])); } } + + return ''; } /** From e984057ceb0f7e037c6e20d3fdc32f9787330649 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sun, 3 Nov 2024 15:52:46 +0100 Subject: [PATCH 04/38] Extract visible_whitespace() into separate method --- src/Module/Debug/Babel.php | 68 +++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/Module/Debug/Babel.php b/src/Module/Debug/Babel.php index 8a7c5230dc..794068962a 100644 --- a/src/Module/Debug/Babel.php +++ b/src/Module/Debug/Babel.php @@ -29,11 +29,6 @@ class Babel extends BaseModule protected function content(array $request = []): string { - function visible_whitespace($s) - { - return '
' . htmlspecialchars($s) . '
'; - } - $results = []; if (!empty($request['text'])) { self::checkFormSecurityTokenForbiddenOnError('babel'); @@ -42,24 +37,24 @@ class Babel extends BaseModule $bbcode = $request['text']; $results[] = [ 'title' => DI::l10n()->t('Source input'), - 'content' => visible_whitespace($bbcode) + 'content' => $this->visible_whitespace($bbcode) ]; $plain = Text\BBCode::toPlaintext($bbcode, false); $results[] = [ 'title' => DI::l10n()->t('BBCode::toPlaintext'), - 'content' => visible_whitespace($plain) + 'content' => $this->visible_whitespace($plain) ]; $html = Text\BBCode::convertForUriId(0, $bbcode); $results[] = [ 'title' => DI::l10n()->t('BBCode::convert (raw HTML)'), - 'content' => visible_whitespace($html) + 'content' => $this->visible_whitespace($html) ]; $results[] = [ 'title' => DI::l10n()->t('BBCode::convert (hex)'), - 'content' => visible_whitespace(bin2hex($html)), + 'content' => $this->visible_whitespace(bin2hex($html)), ]; $results[] = [ @@ -70,19 +65,19 @@ class Babel extends BaseModule $bbcode2 = Text\HTML::toBBCode($html); $results[] = [ 'title' => DI::l10n()->t('BBCode::convert => HTML::toBBCode'), - 'content' => visible_whitespace($bbcode2) + 'content' => $this->visible_whitespace($bbcode2) ]; $markdown = Text\BBCode::toMarkdown($bbcode); $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown'), - 'content' => visible_whitespace($markdown) + 'content' => $this->visible_whitespace($markdown) ]; $html2 = Text\Markdown::convert($markdown); $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::convert (raw HTML)'), - 'content' => visible_whitespace($html2) + 'content' => $this->visible_whitespace($html2) ]; $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::convert'), @@ -92,13 +87,13 @@ class Babel extends BaseModule $bbcode3 = Text\Markdown::toBBCode($markdown); $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::toBBCode'), - 'content' => visible_whitespace($bbcode3) + 'content' => $this->visible_whitespace($bbcode3) ]; $bbcode4 = Text\HTML::toBBCode($html2); $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::convert => HTML::toBBCode'), - 'content' => visible_whitespace($bbcode4) + 'content' => $this->visible_whitespace($bbcode4) ]; $tags = Text\BBCode::getTags($bbcode); @@ -106,22 +101,22 @@ class Babel extends BaseModule $body = Item::setHashtags($bbcode); $results[] = [ 'title' => DI::l10n()->t('Item Body'), - 'content' => visible_whitespace($body) + 'content' => $this->visible_whitespace($body) ]; $results[] = [ 'title' => DI::l10n()->t('Item Tags'), - 'content' => visible_whitespace(var_export($tags, true)), + 'content' => $this->visible_whitespace(var_export($tags, true)), ]; $body2 = PageInfo::searchAndAppendToBody($bbcode, true); $results[] = [ 'title' => DI::l10n()->t('PageInfo::appendToBody'), - 'content' => visible_whitespace($body2) + 'content' => $this->visible_whitespace($body2) ]; $html3 = Text\BBCode::convertForUriId(0, $body2); $results[] = [ 'title' => DI::l10n()->t('PageInfo::appendToBody => BBCode::convert (raw HTML)'), - 'content' => visible_whitespace($html3) + 'content' => $this->visible_whitespace($html3) ]; $results[] = [ 'title' => DI::l10n()->t('PageInfo::appendToBody => BBCode::convert'), @@ -132,7 +127,7 @@ class Babel extends BaseModule $diaspora = trim($request['text']); $results[] = [ 'title' => DI::l10n()->t('Source input (Diaspora format)'), - 'content' => visible_whitespace($diaspora), + 'content' => $this->visible_whitespace($diaspora), ]; $markdown = XML::unescape($diaspora); @@ -141,13 +136,13 @@ class Babel extends BaseModule $results[] = [ 'title' => DI::l10n()->t('Source input (Markdown)'), - 'content' => visible_whitespace($markdown), + 'content' => $this->visible_whitespace($markdown), ]; $html = Text\Markdown::convert($markdown); $results[] = [ 'title' => DI::l10n()->t('Markdown::convert (raw HTML)'), - 'content' => visible_whitespace($html), + 'content' => $this->visible_whitespace($html), ]; $results[] = [ @@ -158,14 +153,14 @@ class Babel extends BaseModule $bbcode = Text\Markdown::toBBCode($markdown); $results[] = [ 'title' => DI::l10n()->t('Markdown::toBBCode'), - 'content' => visible_whitespace($bbcode), + 'content' => $this->visible_whitespace($bbcode), ]; break; case 'html' : $html = trim($request['text']); $results[] = [ 'title' => DI::l10n()->t('Raw HTML input'), - 'content' => visible_whitespace($html), + 'content' => $this->visible_whitespace($html), ]; $results[] = [ @@ -177,12 +172,12 @@ class Babel extends BaseModule $results[] = [ 'title' => DI::l10n()->t('HTML Purified (raw)'), - 'content' => visible_whitespace($purified), + 'content' => $this->visible_whitespace($purified), ]; $results[] = [ 'title' => DI::l10n()->t('HTML Purified (hex)'), - 'content' => visible_whitespace(bin2hex($purified)), + 'content' => $this->visible_whitespace(bin2hex($purified)), ]; $results[] = [ @@ -193,7 +188,7 @@ class Babel extends BaseModule $bbcode = Text\HTML::toBBCode($html); $results[] = [ 'title' => DI::l10n()->t('HTML::toBBCode'), - 'content' => visible_whitespace($bbcode) + 'content' => $this->visible_whitespace($bbcode) ]; $html2 = Text\BBCode::convertForUriId(0, $bbcode); @@ -210,25 +205,25 @@ class Babel extends BaseModule $bbcode2plain = Text\BBCode::toPlaintext($bbcode); $results[] = [ 'title' => DI::l10n()->t('HTML::toBBCode => BBCode::toPlaintext'), - 'content' => visible_whitespace($bbcode2plain), + 'content' => $this->visible_whitespace($bbcode2plain), ]; $markdown = Text\HTML::toMarkdown($html); $results[] = [ 'title' => DI::l10n()->t('HTML::toMarkdown'), - 'content' => visible_whitespace($markdown) + 'content' => $this->visible_whitespace($markdown) ]; $text = Text\HTML::toPlaintext($html, 0); $results[] = [ 'title' => DI::l10n()->t('HTML::toPlaintext'), - 'content' => visible_whitespace($text), + 'content' => $this->visible_whitespace($text), ]; $text = Text\HTML::toPlaintext($html, 0, true); $results[] = [ 'title' => DI::l10n()->t('HTML::toPlaintext (compact)'), - 'content' => visible_whitespace($text), + 'content' => $this->visible_whitespace($text), ]; break; case 'twitter': @@ -246,7 +241,7 @@ class Babel extends BaseModule $results[] = [ 'title' => DI::l10n()->t('Decoded post'), - 'content' => visible_whitespace(var_export($status, true)), + 'content' => $this->visible_whitespace(var_export($status, true)), ]; $postarray = []; @@ -267,19 +262,19 @@ class Babel extends BaseModule $results[] = [ 'title' => DI::l10n()->t('Post array before expand entities'), - 'content' => visible_whitespace(var_export($postarray, true)), + 'content' => $this->visible_whitespace(var_export($postarray, true)), ]; $converted = \twitter_expand_entities($postarray['body'], $status, $picture); $results[] = [ 'title' => DI::l10n()->t('Post converted'), - 'content' => visible_whitespace(var_export($converted, true)), + 'content' => $this->visible_whitespace(var_export($converted, true)), ]; $results[] = [ 'title' => DI::l10n()->t('Converted body'), - 'content' => visible_whitespace($converted['body']), + 'content' => $this->visible_whitespace($converted['body']), ]; } else { $results[] = [ @@ -309,4 +304,9 @@ class Babel extends BaseModule return $o; } + + private function visible_whitespace($s): string + { + return '
' . htmlspecialchars($s) . '
'; + } } From 3a8058ec09e205aaff21eab4554ee614cdf5ed82 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sun, 3 Nov 2024 15:54:37 +0100 Subject: [PATCH 05/38] Extract visible_whitespace() into separate method in ActivityPubConversion --- src/Module/Debug/ActivityPubConversion.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Module/Debug/ActivityPubConversion.php b/src/Module/Debug/ActivityPubConversion.php index 251b9ad26e..ac0a0b664e 100644 --- a/src/Module/Debug/ActivityPubConversion.php +++ b/src/Module/Debug/ActivityPubConversion.php @@ -23,10 +23,7 @@ class ActivityPubConversion extends BaseModule protected function content(array $request = []): string { - function visible_whitespace($s) - { - return '
' . htmlspecialchars($s) . '
'; - } + $results = []; if (!empty($_REQUEST['source'])) { @@ -43,11 +40,11 @@ class ActivityPubConversion extends BaseModule $formatted = json_encode($source, JSON_PRETTY_PRINT); $results[] = [ 'title' => DI::l10n()->t('Formatted'), - 'content' => visible_whitespace(trim(var_export($formatted, true), "'")), + 'content' => $this->visible_whitespace(trim(var_export($formatted, true), "'")), ]; $results[] = [ 'title' => DI::l10n()->t('Source'), - 'content' => visible_whitespace(var_export($source, true)) + 'content' => $this->visible_whitespace(var_export($source, true)) ]; $activity = JsonLD::compact($source); if (!$activity) { @@ -55,7 +52,7 @@ class ActivityPubConversion extends BaseModule } $results[] = [ 'title' => DI::l10n()->t('Activity'), - 'content' => visible_whitespace(var_export($activity, true)) + 'content' => $this->visible_whitespace(var_export($activity, true)) ]; $type = JsonLD::fetchElement($activity, '@type'); @@ -107,14 +104,14 @@ class ActivityPubConversion extends BaseModule $results[] = [ 'title' => DI::l10n()->t('Object data'), - 'content' => visible_whitespace(var_export($object_data, true)) + 'content' => $this->visible_whitespace(var_export($object_data, true)) ]; $item = ActivityPub\Processor::createItem($object_data, true); $results[] = [ 'title' => DI::l10n()->t('Result Item'), - 'content' => visible_whitespace(var_export($item, true)) + 'content' => $this->visible_whitespace(var_export($item, true)) ]; } catch (\Throwable $e) { $results[] = [ @@ -134,4 +131,9 @@ class ActivityPubConversion extends BaseModule return $o; } + + private function visible_whitespace(string $s): string + { + return '
' . htmlspecialchars($s) . '
'; + } } From 9ae7b9cf01e86578bf6550dcccc37b90297dbb64 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 4 Nov 2024 11:58:08 +0000 Subject: [PATCH 06/38] Fix warnings in Receiver.php --- src/Protocol/ActivityPub/Receiver.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 12fd91b7cf..e31b8fb3d6 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -1896,8 +1896,14 @@ class Receiver } $object_data['unlisted'] = in_array(-1, $object_data['receiver']); - unset($object_data['receiver'][-1]); - unset($object_data['reception_type'][-1]); + + if (array_key_exists(-1, $object_data['receiver'])) { + unset($object_data['receiver'][-1]); + } + + if (array_key_exists(-1, $object_data['reception_type'])) { + unset($object_data['reception_type'][-1]); + } return $object_data; } From 0bb8e3af806b7fc580d672735a65698976da9010 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 4 Nov 2024 13:22:26 +0100 Subject: [PATCH 07/38] add test for Preferences class --- .../Object/Api/Mastodon/PreferencesTest.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/src/Object/Api/Mastodon/PreferencesTest.php diff --git a/tests/src/Object/Api/Mastodon/PreferencesTest.php b/tests/src/Object/Api/Mastodon/PreferencesTest.php new file mode 100644 index 0000000000..01cdea13be --- /dev/null +++ b/tests/src/Object/Api/Mastodon/PreferencesTest.php @@ -0,0 +1,46 @@ + 'visibility', + 'posting:default:sensitive' => true, + 'posting:default:language' => 'language', + 'reading:expand:media' => 'media', + 'reading:expand:spoilers' => false, + ], + $preferences->toArray(), + ); + } + + public function testJsonSerializeReturnsArray(): void + { + $preferences = new Preferences('visibility',true, 'language', 'media', false); + + self::assertSame( + [ + 'posting:default:visibility' => 'visibility', + 'posting:default:sensitive' => true, + 'posting:default:language' => 'language', + 'reading:expand:media' => 'media', + 'reading:expand:spoilers' => false, + ], + $preferences->jsonSerialize(), + ); + } +} From 979468e7fb5b23d089652711b4df3ca265748405 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 4 Nov 2024 13:30:26 +0100 Subject: [PATCH 08/38] refactor of Friendica\Object\Api\Mastodon\Preferences class --- src/Object/Api/Mastodon/Preferences.php | 60 ++++++++++++++++++------- 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/src/Object/Api/Mastodon/Preferences.php b/src/Object/Api/Mastodon/Preferences.php index 7447f5fa74..68f3c922a8 100644 --- a/src/Object/Api/Mastodon/Preferences.php +++ b/src/Object/Api/Mastodon/Preferences.php @@ -17,16 +17,30 @@ use Friendica\BaseDataTransferObject; */ class Preferences extends BaseDataTransferObject { -// /** @var string (Enumerable, oneOf) */ -// protected $posting_default_visibility; -// /** @var bool */ -// protected $posting_default_sensitive; -// /** @var string (ISO 639-1 language two-letter code), or null*/ -// protected $posting_default_language; -// /** @var string (Enumerable, oneOf) */ -// protected $reading_expand_media; -// /** @var bool */ -// protected $reading_expand_spoilers; + /** + * @var string (Enumerable, oneOf) + */ + private $visibility; + + /** + * @var bool + */ + private $sensitive; + + /** + * @var string (ISO 639-1 language two-letter code), or null + */ + private $language; + + /** + * @var string (Enumerable, oneOf) + */ + private $media; + + /** + * @var bool + */ + private $spoilers; /** * Creates a preferences record. @@ -39,10 +53,26 @@ class Preferences extends BaseDataTransferObject */ public function __construct(string $visibility, bool $sensitive, string $language, string $media, bool $spoilers) { - $this->{'posting:default:visibility'} = $visibility; - $this->{'posting:default:sensitive'} = $sensitive; - $this->{'posting:default:language'} = $language; - $this->{'reading:expand:media'} = $media; - $this->{'reading:expand:spoilers'} = $spoilers; + $this->visibility = $visibility; + $this->sensitive = $sensitive; + $this->language = $language; + $this->media = $media; + $this->spoilers = $spoilers; + } + + /** + * Returns the current entity as an array + * + * @return array + */ + public function toArray(): array + { + return [ + 'posting:default:visibility' => $this->visibility, + 'posting:default:sensitive' => $this->sensitive, + 'posting:default:language' => $this->language, + 'reading:expand:media' => $this->media, + 'reading:expand:spoilers' => $this->spoilers, + ]; } } From b5c2cbc597e98508015d6ee41230025af552262a Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 4 Nov 2024 13:36:57 +0100 Subject: [PATCH 09/38] Refactor Friendica\Module\Debug\ItemBody class --- src/Module/Debug/ItemBody.php | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/Module/Debug/ItemBody.php b/src/Module/Debug/ItemBody.php index fe07f51b8f..204a0dd5a8 100644 --- a/src/Module/Debug/ItemBody.php +++ b/src/Module/Debug/ItemBody.php @@ -11,36 +11,43 @@ use Friendica\BaseModule; use Friendica\Core\System; use Friendica\DI; use Friendica\Model\Post; -use Friendica\Network\HTTPException; +use Friendica\Network\HTTPException\NotFoundException; +use Friendica\Network\HTTPException\UnauthorizedException; /** * Print the body of an Item */ class ItemBody extends BaseModule { + /** + * @throws NotFoundException|UnauthorizedException + * + * @return string|never + */ protected function content(array $request = []): string { if (!DI::userSession()->getLocalUserId()) { - throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.')); + throw new UnauthorizedException(DI::l10n()->t('Access denied.')); } if (empty($this->parameters['item'])) { - throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.')); + throw new NotFoundException(DI::l10n()->t('Item not found.')); } $itemId = intval($this->parameters['item']); $item = Post::selectFirst(['body'], ['uid' => [0, DI::userSession()->getLocalUserId()], 'uri-id' => $itemId]); - if (!empty($item)) { - if (DI::mode()->isAjax()) { - echo str_replace("\n", '
', $item['body']); - System::exit(); - } else { - return str_replace("\n", '
', $item['body']); - } - } else { - throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.')); + if (empty($item)) { + throw new NotFoundException(DI::l10n()->t('Item not found.')); } + + // TODO: Extract this code into controller + if (DI::mode()->isAjax()) { + echo str_replace("\n", '
', $item['body']); + System::exit(); + } + + return str_replace("\n", '
', $item['body']); } } From 4a9c7d2f30e87ed97090b0c58e946007e2ca5003 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 4 Nov 2024 13:56:04 +0100 Subject: [PATCH 10/38] Remove call of non-existing functions This functions were removed in commit a97b3f690c9e4476ba638236897507100f77af6f - twitter_statuses_show() - twitter_media_entities() - twitter_expand_entities() see https://github.com/friendica/friendica-addons/commit/a97b3f690c9e4476ba638236897507100f77af6f --- src/Module/Debug/Babel.php | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/Module/Debug/Babel.php b/src/Module/Debug/Babel.php index 794068962a..10b424850b 100644 --- a/src/Module/Debug/Babel.php +++ b/src/Module/Debug/Babel.php @@ -232,12 +232,7 @@ class Babel extends BaseModule if (file_exists('addon/twitter/twitter.php')) { require_once 'addon/twitter/twitter.php'; - if (parse_url($json) !== false) { - preg_match('#^https?://(?:mobile\.|www\.)?twitter.com/[^/]+/status/(\d+).*#', $json, $matches); - $status = twitter_statuses_show($matches[1]); - } else { - $status = json_decode($json); - } + $status = json_decode($json); $results[] = [ 'title' => DI::l10n()->t('Decoded post'), @@ -258,24 +253,10 @@ class Babel extends BaseModule $postarray['object-type'] = Activity\ObjectType::BOOKMARK; } - $picture = \twitter_media_entities($status, $postarray); - $results[] = [ 'title' => DI::l10n()->t('Post array before expand entities'), 'content' => $this->visible_whitespace(var_export($postarray, true)), ]; - - $converted = \twitter_expand_entities($postarray['body'], $status, $picture); - - $results[] = [ - 'title' => DI::l10n()->t('Post converted'), - 'content' => $this->visible_whitespace(var_export($converted, true)), - ]; - - $results[] = [ - 'title' => DI::l10n()->t('Converted body'), - 'content' => $this->visible_whitespace($converted['body']), - ]; } else { $results[] = [ 'title' => DI::l10n()->tt('Error', 'Errors', 1), From 57c188d01d2647b915a416ab55432ca10a9c5b5f Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 4 Nov 2024 13:46:33 +0000 Subject: [PATCH 11/38] Fix wrong use of static --- src/BaseCollection.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/BaseCollection.php b/src/BaseCollection.php index 407448fc5a..9598b1ae78 100644 --- a/src/BaseCollection.php +++ b/src/BaseCollection.php @@ -89,7 +89,7 @@ class BaseCollection extends \ArrayIterator */ public function map(callable $callback): BaseCollection { - return new static(array_map($callback, $this->getArrayCopy()), $this->getTotalCount()); + return new self(array_map($callback, $this->getArrayCopy()), $this->getTotalCount()); } /** @@ -102,7 +102,7 @@ class BaseCollection extends \ArrayIterator */ public function filter(callable $callback = null, int $flag = 0): BaseCollection { - return new static(array_filter($this->getArrayCopy(), $callback, $flag)); + return new self(array_filter($this->getArrayCopy(), $callback, $flag)); } /** @@ -112,14 +112,14 @@ class BaseCollection extends \ArrayIterator */ public function reverse(): BaseCollection { - return new static(array_reverse($this->getArrayCopy()), $this->getTotalCount()); + return new self(array_reverse($this->getArrayCopy()), $this->getTotalCount()); } /** * Split the collection in smaller collections no bigger than the provided length * * @param int $length - * @return static[] + * @return self[] */ public function chunk(int $length): array { @@ -128,7 +128,7 @@ class BaseCollection extends \ArrayIterator } return array_map(function ($array) { - return new static($array); + return new self($array); }, array_chunk($this->getArrayCopy(), $length)); } From 71add60f592a2ddc1452c23266eac50eda96b088 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 4 Nov 2024 15:04:06 +0000 Subject: [PATCH 12/38] remove unused code this code was never called because $body is never declared and hence the if could never be true --- src/Module/Debug/ActivityPubConversion.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Module/Debug/ActivityPubConversion.php b/src/Module/Debug/ActivityPubConversion.php index ac0a0b664e..9b0465f016 100644 --- a/src/Module/Debug/ActivityPubConversion.php +++ b/src/Module/Debug/ActivityPubConversion.php @@ -23,9 +23,8 @@ class ActivityPubConversion extends BaseModule protected function content(array $request = []): string { - - $results = []; + if (!empty($_REQUEST['source'])) { try { $source = json_decode($_REQUEST['source'], true); @@ -89,10 +88,6 @@ class ActivityPubConversion extends BaseModule throw new \Exception('No trust for activity type "' . $type . '", so we quit now.'); } - if (!empty($body) && empty($object_data['raw'])) { - $object_data['raw'] = $body; - } - // Internal flag for thread completion. See Processor.php if (!empty($activity['thread-completion'])) { $object_data['thread-completion'] = $activity['thread-completion']; From 3535c7c4cd87b62754b61163c4663856732ec485 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 4 Nov 2024 15:09:33 +0000 Subject: [PATCH 13/38] Remove unused code --- src/Module/Api/Mastodon/Search.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Module/Api/Mastodon/Search.php b/src/Module/Api/Mastodon/Search.php index e87c710b09..45556bc3aa 100644 --- a/src/Module/Api/Mastodon/Search.php +++ b/src/Module/Api/Mastodon/Search.php @@ -157,10 +157,6 @@ class Search extends BaseApi $condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $max_id]); } - if (!empty($since_id)) { - $condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $since_id]); - } - if (!empty($min_id)) { $condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $min_id]); From 28f2b7fc81a7335ebecb8a82c231d5058aac699f Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 4 Nov 2024 15:28:10 +0000 Subject: [PATCH 14/38] Fix variable name The variable was renamed but this line was accidently overseen see https://github.com/friendica/friendica/commit/62eb16e9ad9adbd2fa712cccbb40ab53b8b16e5b#diff-785d24b46fdf749363656f33208f941ea0eca809c7c76452180a0bfc16df68a3R2555 --- src/Model/Item.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 06f824e6fe..0a000f8c1e 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -3198,10 +3198,10 @@ class Item } elseif ($remote_user) { // Authenticated visitor - fetch the matching permissionsets $permissionSets = DI::permissionSet()->selectByContactId($remote_user, $owner_id); - if (!empty($set)) { + if (!empty($permissionSets)) { $condition = [ "(`private` != ? OR (`private` = ? AND `wall` - AND `psid` IN (" . implode(', ', array_fill(0, count($set), '?')) . ")))", + AND `psid` IN (" . implode(', ', array_fill(0, count($permissionSets), '?')) . ")))", self::PRIVATE, self::PRIVATE ]; $condition = array_merge($condition, $permissionSets->column('id')); @@ -3247,7 +3247,7 @@ class Item */ $permissionSets = DI::permissionSet()->selectByContactId($remote_user, $owner_id); - if (!empty($set)) { + if (!empty($permissionSets)) { $sql_set = sprintf(" OR (" . $table . "`private` = %d AND " . $table . "`wall` AND " . $table . "`psid` IN (", self::PRIVATE) . implode(',', $permissionSets->column('id')) . "))"; } else { $sql_set = ''; From ad6be21b56902a3dedcbcb5a2651ca5869210a77 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 4 Nov 2024 20:02:44 +0000 Subject: [PATCH 15/38] Fix defaults in Contact model --- src/Model/Contact.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index c6bdba2dc0..de5c50da8f 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -2706,8 +2706,6 @@ class Contact * * @param int $id * @param array $contact - * - * @return boolean */ private static function hasLocalData(int $id, array $contact): bool { @@ -2767,6 +2765,8 @@ class Contact 'network', 'alias', 'baseurl', 'gsid', 'forum', 'prv', 'contact-type', 'pubkey', 'last-item', 'xmpp', 'matrix', 'created', 'last-update' ]; + + /** @var array */ $contact = DBA::selectFirst('contact', $fields, ['id' => $id]); if (!DBA::isResult($contact)) { return false; @@ -2792,22 +2792,22 @@ class Contact $has_local_data = self::hasLocalData($id, $contact); - $uid = $contact['uid']; + $uid = $contact['uid'] ?? null; unset($contact['uid']); - $uriid = $contact['uri-id']; + $uriid = $contact['uri-id'] ?? null; unset($contact['uri-id']); - $pubkey = $contact['pubkey']; + $pubkey = $contact['pubkey'] ?? null; unset($contact['pubkey']); - $created = $contact['created']; + $created = $contact['created'] ?? ''; unset($contact['created']); - $last_update = $contact['last-update']; + $last_update = $contact['last-update'] ?? ''; unset($contact['last-update']); - $contact['photo'] = $contact['avatar']; + $contact['photo'] = $contact['avatar'] ?? null; unset($contact['avatar']); $updated = DateTimeFormat::utcNow(); From 8448d719e7f3f2cc5c92c32fc5d4b8e0ef0e9d3e Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 4 Nov 2024 20:34:32 +0000 Subject: [PATCH 16/38] Remove support for apc apc is deprecated since PHP 5.5 and not compatible with PHP 7 --- src/Core/Cache/Type/APCuCache.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Core/Cache/Type/APCuCache.php b/src/Core/Cache/Type/APCuCache.php index d65ead179a..b0db420b82 100644 --- a/src/Core/Cache/Type/APCuCache.php +++ b/src/Core/Cache/Type/APCuCache.php @@ -122,11 +122,7 @@ class APCuCache extends AbstractCache implements ICanCacheInMemory $prefix = $this->getPrefix(); $prefix = preg_quote($prefix, '/'); - if (class_exists('\APCIterator')) { - $iterator = new \APCIterator('user', '/^' . $prefix . '/', APC_ITER_KEY); - } else { - $iterator = new \APCUIterator('/^' . $prefix . '/', APC_ITER_KEY); - } + $iterator = new \APCUIterator('/^' . $prefix . '/', APC_ITER_KEY); return apcu_delete($iterator); } @@ -149,10 +145,7 @@ class APCuCache extends AbstractCache implements ICanCacheInMemory return false; } elseif (!ini_get('apc.enabled') && !ini_get('apc.enable_cli')) { return false; - } elseif ( - version_compare(phpversion('apc') ?: '0.0.0', '4.0.6') === -1 && - version_compare(phpversion('apcu') ?: '0.0.0', '5.1.0') === -1 - ) { + } elseif (version_compare(phpversion('apcu') ?: '0.0.0', '5.1.0', '<')) { return false; } From 4e49c45021913e2fd57eb146ff7f78119f8a9163 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 5 Nov 2024 07:07:58 +0000 Subject: [PATCH 17/38] Remove support for apc --- src/Core/Cache/Type/APCuCache.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Core/Cache/Type/APCuCache.php b/src/Core/Cache/Type/APCuCache.php index b0db420b82..d9bcfbc60d 100644 --- a/src/Core/Cache/Type/APCuCache.php +++ b/src/Core/Cache/Type/APCuCache.php @@ -7,6 +7,7 @@ namespace Friendica\Core\Cache\Type; +use APCUIterator; use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Cache\Capability\ICanCacheInMemory; use Friendica\Core\Cache\Exception\InvalidCacheDriverException; @@ -41,11 +42,7 @@ class APCuCache extends AbstractCache implements ICanCacheInMemory $ns = $this->getCacheKey($prefix ?? ''); $ns = preg_quote($ns, '/'); - if (class_exists('\APCIterator')) { - $iterator = new \APCIterator('user', '/^' . $ns. '/', APC_ITER_KEY); - } else { - $iterator = new \APCUIterator('/^' . $ns . '/', APC_ITER_KEY); - } + $iterator = new APCUIterator('/^' . $ns . '/', APC_ITER_KEY); $keys = []; foreach ($iterator as $item) { @@ -122,7 +119,7 @@ class APCuCache extends AbstractCache implements ICanCacheInMemory $prefix = $this->getPrefix(); $prefix = preg_quote($prefix, '/'); - $iterator = new \APCUIterator('/^' . $prefix . '/', APC_ITER_KEY); + $iterator = new APCUIterator('/^' . $prefix . '/', APC_ITER_KEY); return apcu_delete($iterator); } From 3c229443e89e15cb5b4473e28a5644e3d80c7632 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 5 Nov 2024 07:14:24 +0000 Subject: [PATCH 18/38] Remove missleading template phpdoc --- src/Content/Widget/ContactBlock.php | 1 - src/Content/Widget/VCard.php | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Content/Widget/ContactBlock.php b/src/Content/Widget/ContactBlock.php index 917f973322..b1d80653d4 100644 --- a/src/Content/Widget/ContactBlock.php +++ b/src/Content/Widget/ContactBlock.php @@ -26,7 +26,6 @@ class ContactBlock /** * Get HTML for contact block * - * @template widget/contacts.tpl * @hook contact_block_end (contacts=>array, output=>string) * @return string Formatted HTML code or empty string */ diff --git a/src/Content/Widget/VCard.php b/src/Content/Widget/VCard.php index 3f89299466..f8d4453c81 100644 --- a/src/Content/Widget/VCard.php +++ b/src/Content/Widget/VCard.php @@ -26,7 +26,6 @@ class VCard /** * Get HTML for vcard block * - * @template widget/vcard.tpl * @param array $contact * @param bool $hide_mention * @param bool $hide_follow From f024de4350fb980175cc06d64503926967a0d56a Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 5 Nov 2024 11:25:35 +0000 Subject: [PATCH 19/38] add missing property in FixAPDeliveryWorkerTaskParameters --- .../FixAPDeliveryWorkerTaskParameters.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Console/FixAPDeliveryWorkerTaskParameters.php b/src/Console/FixAPDeliveryWorkerTaskParameters.php index 9c420a3a68..9cced29dec 100644 --- a/src/Console/FixAPDeliveryWorkerTaskParameters.php +++ b/src/Console/FixAPDeliveryWorkerTaskParameters.php @@ -7,12 +7,11 @@ namespace Friendica\Console; -use Friendica\App; +use Asika\SimpleConsole\CommandArgsException; +use Friendica\App\Mode; +use Friendica\Core\L10n; use Friendica\Database\Database; -use Friendica\Database\DBA; -use Friendica\DI; use Friendica\Model\Contact; -use Friendica\Util\Strings; use RuntimeException; /** @@ -23,13 +22,17 @@ class FixAPDeliveryWorkerTaskParameters extends \Asika\SimpleConsole\Console protected $helpOptions = ['h', 'help', '?']; /** - * @var App\Mode + * @var Mode */ private $appMode; /** * @var Database */ private $dba; + /** + * @var L10n + */ + private $l10n; /** * @var int */ @@ -53,7 +56,7 @@ Usage Description During the 2020.12 RC period some worker task parameters have been corrupted, resulting in the impossibility to execute them. This command restores their expected parameters. - If you didn't run Friendica during the 2020.12 RC period, you do not need to use this command. + If you didn't run Friendica during the 2020.12 RC period, you do not need to use this command. Options -h|--help|-? Show help information @@ -62,7 +65,7 @@ HELP; return $help; } - public function __construct(App\Mode $appMode, Database $dba, \Friendica\Core\L10n $l10n, array $argv = null) + public function __construct(Mode $appMode, Database $dba, L10n $l10n, array $argv = null) { parent::__construct($argv); @@ -80,7 +83,7 @@ HELP; } if (count($this->args) > 0) { - throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments'); + throw new CommandArgsException('Too many arguments'); } if ($this->appMode->isInstall()) { From bf04b3e57d6532a7139ea88d5315dc40a835094a Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 5 Nov 2024 11:27:29 +0000 Subject: [PATCH 20/38] Fix usage of static --- src/Content/Post/Entity/PostMedia.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Content/Post/Entity/PostMedia.php b/src/Content/Post/Entity/PostMedia.php index a856118b80..0dd3309176 100644 --- a/src/Content/Post/Entity/PostMedia.php +++ b/src/Content/Post/Entity/PostMedia.php @@ -228,7 +228,7 @@ class PostMedia extends BaseEntity $newHeight = $dimensionts['height']; } - return new static( + return new self( $this->uriId, $this->url, $this->type, @@ -255,7 +255,7 @@ class PostMedia extends BaseEntity public function withUrl(\GuzzleHttp\Psr7\Uri $url): self { - return new static( + return new self( $this->uriId, $url, $this->type, From 01ba276455b8ce47b67adada7e02f0f5749b9ab8 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 5 Nov 2024 11:52:23 +0000 Subject: [PATCH 21/38] Add missing return This needs some refactoring: returning nothing implicit returns null, thas will be convert to int 0. I return false instead of nothing to keep this behaviour for BC. --- src/Console/User.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Console/User.php b/src/Console/User.php index bdbe7be578..b73311368a 100644 --- a/src/Console/User.php +++ b/src/Console/User.php @@ -512,5 +512,7 @@ HELP; $this->out($this->getHelp()); return false; } + + return false; } } From 4b971f84fd5b7f35d6463a92e5e675bd204aa480 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 5 Nov 2024 12:13:18 +0000 Subject: [PATCH 22/38] Fix returns in Console commands --- src/Console/Addon.php | 2 ++ src/Console/Contact.php | 5 +++-- src/Console/User.php | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Console/Addon.php b/src/Console/Addon.php index fd2093f9f5..43ce7a6be3 100644 --- a/src/Console/Addon.php +++ b/src/Console/Addon.php @@ -144,6 +144,8 @@ HELP; } $this->out($table->getTable()); + + return 0; } /** diff --git a/src/Console/Contact.php b/src/Console/Contact.php index e02f589714..46a26c4a9d 100644 --- a/src/Console/Contact.php +++ b/src/Console/Contact.php @@ -158,9 +158,10 @@ HELP; if ($result['success']) { $this->out('User ' . $user['nickname'] . ' now connected to ' . $url . ', contact ID ' . $result['cid']); - } else { - throw new RuntimeException($result['message']); + return true; } + + throw new RuntimeException($result['message']); } /** diff --git a/src/Console/User.php b/src/Console/User.php index b73311368a..42e85f007d 100644 --- a/src/Console/User.php +++ b/src/Console/User.php @@ -122,7 +122,7 @@ HELP; case 'search': return $this->searchUser(); case 'config': - return $this->configUser(); + return ($this->configUser()) ? 0 : 1; default: throw new \Asika\SimpleConsole\CommandArgsException('Wrong command.'); } @@ -513,6 +513,6 @@ HELP; return false; } - return false; + return true; } } From eff96cc1407910948b38c9d2fb9bea04ad9e7ef6 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 5 Nov 2024 12:17:41 +0000 Subject: [PATCH 23/38] add missing use statement --- src/Console/AutomaticInstallation.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Console/AutomaticInstallation.php b/src/Console/AutomaticInstallation.php index ad0a079d23..cc932f51c4 100644 --- a/src/Console/AutomaticInstallation.php +++ b/src/Console/AutomaticInstallation.php @@ -8,6 +8,7 @@ namespace Friendica\Console; use Asika\SimpleConsole\Console; +use Exception; use Friendica\App; use Friendica\App\BaseURL; use Friendica\Core\Config\Capability\IManageConfigValues; @@ -54,12 +55,12 @@ Options -d|--dbdata The name of the mysql/mariadb database (env MYSQL_DATABASE) -u|--dbuser The username of the mysql/mariadb database login (env MYSQL_USER or MYSQL_USERNAME) -P|--dbpass The password of the mysql/mariadb database login (env MYSQL_PASSWORD) - -U|--url The full base URL of Friendica - f.e. 'https://friendica.local/sub' (env FRIENDICA_URL) + -U|--url The full base URL of Friendica - f.e. 'https://friendica.local/sub' (env FRIENDICA_URL) -B|--phppath The path of the PHP binary (env FRIENDICA_PHP_PATH) -b|--basepath The basepath of Friendica (env FRIENDICA_BASE_PATH) -t|--tz The timezone of Friendica (env FRIENDICA_TZ) -L|--lang The language of Friendica (env FRIENDICA_LANG) - + Environment variables MYSQL_HOST The host of the mysql/mariadb database (mandatory if mysql and environment is used) MYSQL_PORT The port of the mysql/mariadb database @@ -73,7 +74,7 @@ Environment variables FRIENDICA_ADMIN_MAIL The admin email address of Friendica (this email will be used for admin access) FRIENDICA_TZ The timezone of Friendica FRIENDICA_LANG The langauge of Friendica - + Examples bin/console autoinstall -f 'input.config.php Installs Friendica with the prepared 'input.config.php' file From a28a20777483e2d92aed587360dbd603cf5cd500 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 5 Nov 2024 12:20:43 +0000 Subject: [PATCH 24/38] Fix name of Mode class --- src/App/Mode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App/Mode.php b/src/App/Mode.php index 070d67ee4f..ebf9f46163 100644 --- a/src/App/Mode.php +++ b/src/App/Mode.php @@ -210,7 +210,7 @@ class Mode public function isInstall(): bool { return !$this->has(Mode::LOCALCONFIGPRESENT) || - !$this->has(MODE::DBAVAILABLE); + !$this->has(Mode::DBAVAILABLE); } /** From dfb821d3b5d6da6fbce54a1f16d807f64b49e098 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 5 Nov 2024 15:26:24 +0000 Subject: [PATCH 25/38] Ignore false positive PHPStan error see https://github.com/friendica/friendica-addons/pull/1363 --- src/Core/Cache/Type/APCuCache.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Core/Cache/Type/APCuCache.php b/src/Core/Cache/Type/APCuCache.php index d9bcfbc60d..5564a1e793 100644 --- a/src/Core/Cache/Type/APCuCache.php +++ b/src/Core/Cache/Type/APCuCache.php @@ -7,7 +7,6 @@ namespace Friendica\Core\Cache\Type; -use APCUIterator; use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Cache\Capability\ICanCacheInMemory; use Friendica\Core\Cache\Exception\InvalidCacheDriverException; @@ -42,7 +41,8 @@ class APCuCache extends AbstractCache implements ICanCacheInMemory $ns = $this->getCacheKey($prefix ?? ''); $ns = preg_quote($ns, '/'); - $iterator = new APCUIterator('/^' . $ns . '/', APC_ITER_KEY); + /** @phpstan-ignore-next-line see https://github.com/friendica/friendica-addons/pull/1363 */ + $iterator = new \APCUIterator('/^' . $ns . '/', APC_ITER_KEY); $keys = []; foreach ($iterator as $item) { @@ -119,7 +119,8 @@ class APCuCache extends AbstractCache implements ICanCacheInMemory $prefix = $this->getPrefix(); $prefix = preg_quote($prefix, '/'); - $iterator = new APCUIterator('/^' . $prefix . '/', APC_ITER_KEY); + /** @phpstan-ignore-next-line see https://github.com/friendica/friendica-addons/pull/1363 */ + $iterator = new \APCUIterator('/^' . $prefix . '/', APC_ITER_KEY); return apcu_delete($iterator); } From 1c3a33ab491bb22e64df5ec1faaa86ff8a38b959 Mon Sep 17 00:00:00 2001 From: Art4 Date: Fri, 8 Nov 2024 08:01:07 +0000 Subject: [PATCH 26/38] Fix namespace --- tests/src/Object/Api/Mastodon/PreferencesTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Object/Api/Mastodon/PreferencesTest.php b/tests/src/Object/Api/Mastodon/PreferencesTest.php index 01cdea13be..4ee3d8000c 100644 --- a/tests/src/Object/Api/Mastodon/PreferencesTest.php +++ b/tests/src/Object/Api/Mastodon/PreferencesTest.php @@ -5,7 +5,7 @@ // // SPDX-License-Identifier: AGPL-3.0-or-later -namespace Friendica\Test\src\Api\Mastodon; +namespace Friendica\Test\src\Object\Api\Mastodon; use Friendica\Object\Api\Mastodon\Preferences; use PHPUnit\Framework\TestCase; From dc80d350882d151b6e9f6ab7f4d7237facc3b4ed Mon Sep 17 00:00:00 2001 From: Art4 Date: Fri, 8 Nov 2024 08:15:03 +0000 Subject: [PATCH 27/38] Fix cs --- tests/src/Object/Api/Mastodon/PreferencesTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/Object/Api/Mastodon/PreferencesTest.php b/tests/src/Object/Api/Mastodon/PreferencesTest.php index 4ee3d8000c..1f0d4ecb7a 100644 --- a/tests/src/Object/Api/Mastodon/PreferencesTest.php +++ b/tests/src/Object/Api/Mastodon/PreferencesTest.php @@ -14,7 +14,7 @@ class PreferencesTest extends TestCase { public function testToArrayReturnsArray(): void { - $preferences = new Preferences('visibility',true, 'language', 'media', false); + $preferences = new Preferences('visibility', true, 'language', 'media', false); self::assertSame( [ @@ -30,7 +30,7 @@ class PreferencesTest extends TestCase public function testJsonSerializeReturnsArray(): void { - $preferences = new Preferences('visibility',true, 'language', 'media', false); + $preferences = new Preferences('visibility', true, 'language', 'media', false); self::assertSame( [ From 256ed12b5140c83476e9240349262f3f9c31976b Mon Sep 17 00:00:00 2001 From: Art4 Date: Fri, 8 Nov 2024 08:17:27 +0000 Subject: [PATCH 28/38] Move test into Unit test namespace --- tests/{src => Unit}/Object/Api/Mastodon/PreferencesTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename tests/{src => Unit}/Object/Api/Mastodon/PreferencesTest.php (96%) diff --git a/tests/src/Object/Api/Mastodon/PreferencesTest.php b/tests/Unit/Object/Api/Mastodon/PreferencesTest.php similarity index 96% rename from tests/src/Object/Api/Mastodon/PreferencesTest.php rename to tests/Unit/Object/Api/Mastodon/PreferencesTest.php index 1f0d4ecb7a..da7cc64981 100644 --- a/tests/src/Object/Api/Mastodon/PreferencesTest.php +++ b/tests/Unit/Object/Api/Mastodon/PreferencesTest.php @@ -5,7 +5,7 @@ // // SPDX-License-Identifier: AGPL-3.0-or-later -namespace Friendica\Test\src\Object\Api\Mastodon; +namespace Friendica\Test\Unit\Object\Api\Mastodon; use Friendica\Object\Api\Mastodon\Preferences; use PHPUnit\Framework\TestCase; From 35c01b96851699b152edaeba665a01b455ae677b Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 9 Nov 2024 10:08:40 +0000 Subject: [PATCH 29/38] Fix code style --- .../Object/Api/Mastodon/PreferencesTest.php | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/Unit/Object/Api/Mastodon/PreferencesTest.php b/tests/Unit/Object/Api/Mastodon/PreferencesTest.php index da7cc64981..7ec8246f58 100644 --- a/tests/Unit/Object/Api/Mastodon/PreferencesTest.php +++ b/tests/Unit/Object/Api/Mastodon/PreferencesTest.php @@ -12,35 +12,35 @@ use PHPUnit\Framework\TestCase; class PreferencesTest extends TestCase { - public function testToArrayReturnsArray(): void - { - $preferences = new Preferences('visibility', true, 'language', 'media', false); + public function testToArrayReturnsArray(): void + { + $preferences = new Preferences('visibility', true, 'language', 'media', false); - self::assertSame( - [ - 'posting:default:visibility' => 'visibility', - 'posting:default:sensitive' => true, - 'posting:default:language' => 'language', - 'reading:expand:media' => 'media', - 'reading:expand:spoilers' => false, - ], - $preferences->toArray(), - ); - } + self::assertSame( + [ + 'posting:default:visibility' => 'visibility', + 'posting:default:sensitive' => true, + 'posting:default:language' => 'language', + 'reading:expand:media' => 'media', + 'reading:expand:spoilers' => false, + ], + $preferences->toArray(), + ); + } - public function testJsonSerializeReturnsArray(): void - { - $preferences = new Preferences('visibility', true, 'language', 'media', false); + public function testJsonSerializeReturnsArray(): void + { + $preferences = new Preferences('visibility', true, 'language', 'media', false); - self::assertSame( - [ - 'posting:default:visibility' => 'visibility', - 'posting:default:sensitive' => true, - 'posting:default:language' => 'language', - 'reading:expand:media' => 'media', - 'reading:expand:spoilers' => false, - ], - $preferences->jsonSerialize(), - ); - } + self::assertSame( + [ + 'posting:default:visibility' => 'visibility', + 'posting:default:sensitive' => true, + 'posting:default:language' => 'language', + 'reading:expand:media' => 'media', + 'reading:expand:spoilers' => false, + ], + $preferences->jsonSerialize(), + ); + } } From 82a95367aeb7337ad529b0392bd42b857a38d36c Mon Sep 17 00:00:00 2001 From: Art4 Date: Sun, 10 Nov 2024 00:23:35 +0000 Subject: [PATCH 30/38] fix code style --- .../Unit/Object/Api/Mastodon/PreferencesTest.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/Unit/Object/Api/Mastodon/PreferencesTest.php b/tests/Unit/Object/Api/Mastodon/PreferencesTest.php index 7ec8246f58..e77a4272e0 100644 --- a/tests/Unit/Object/Api/Mastodon/PreferencesTest.php +++ b/tests/Unit/Object/Api/Mastodon/PreferencesTest.php @@ -19,10 +19,10 @@ class PreferencesTest extends TestCase self::assertSame( [ 'posting:default:visibility' => 'visibility', - 'posting:default:sensitive' => true, - 'posting:default:language' => 'language', - 'reading:expand:media' => 'media', - 'reading:expand:spoilers' => false, + 'posting:default:sensitive' => true, + 'posting:default:language' => 'language', + 'reading:expand:media' => 'media', + 'reading:expand:spoilers' => false, ], $preferences->toArray(), ); @@ -35,10 +35,10 @@ class PreferencesTest extends TestCase self::assertSame( [ 'posting:default:visibility' => 'visibility', - 'posting:default:sensitive' => true, - 'posting:default:language' => 'language', - 'reading:expand:media' => 'media', - 'reading:expand:spoilers' => false, + 'posting:default:sensitive' => true, + 'posting:default:language' => 'language', + 'reading:expand:media' => 'media', + 'reading:expand:spoilers' => false, ], $preferences->jsonSerialize(), ); From d2151f9cd0dab5d2f80c4765401bd9d9a3ed9417 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sun, 10 Nov 2024 07:44:58 +0000 Subject: [PATCH 31/38] add composer script to recreate lang file --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 12df630ccf..2090075024 100644 --- a/composer.json +++ b/composer.json @@ -161,6 +161,7 @@ "phpstan": "phpstan analyze --memory-limit 1024M --configuration .phpstan.neon", "lint": "find . -name \\*.php -not -path './vendor/*' -not -path './view/asset/*' -print0 | xargs -0 -n1 php -l", "docker:translate": "docker run --rm -v $PWD:/data -w /data friendicaci/transifex bin/run_xgettext.sh", + "lang:recreate": "bin/run_xgettext.sh", "cs:install": "@composer install --working-dir=bin/dev/php-cs-fixer", "cs:check": [ "@cs:install", From 89801f043fb8b5a65db794d302e0ac324b778e9c Mon Sep 17 00:00:00 2001 From: Art4 Date: Sun, 10 Nov 2024 07:45:24 +0000 Subject: [PATCH 32/38] recreate messages.po --- view/lang/C/messages.po | 348 ++++++++++++++++++++-------------------- 1 file changed, 170 insertions(+), 178 deletions(-) diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index 566b5df411..7c69b8d946 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 2024.09-dev\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-07 20:46+0000\n" +"POT-Creation-Date: 2024-11-10 07:44+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -39,8 +39,8 @@ msgid "Empty post discarded." msgstr "" #: mod/item.php:425 src/Module/Admin/Themes/Details.php:31 -#: src/Module/Admin/Themes/Index.php:51 src/Module/Debug/ItemBody.php:28 -#: src/Module/Debug/ItemBody.php:43 src/Module/Item/Feed.php:66 +#: src/Module/Admin/Themes/Index.php:51 src/Module/Debug/ItemBody.php:34 +#: src/Module/Debug/ItemBody.php:42 src/Module/Item/Feed.php:66 msgid "Item not found." msgstr "" @@ -291,9 +291,9 @@ msgstr "" #: mod/photos.php:778 mod/photos.php:1055 mod/photos.php:1096 #: mod/photos.php:1152 mod/photos.php:1232 #: src/Module/Calendar/Event/Form.php:236 src/Module/Contact/Advanced.php:118 -#: src/Module/Contact/Profile.php:370 -#: src/Module/Debug/ActivityPubConversion.php:132 -#: src/Module/Debug/Babel.php:307 src/Module/Debug/Localtime.php:50 +#: src/Module/Contact/Profile.php:371 +#: src/Module/Debug/ActivityPubConversion.php:124 +#: src/Module/Debug/Babel.php:283 src/Module/Debug/Localtime.php:50 #: src/Module/Debug/Probe.php:40 src/Module/Debug/WebFinger.php:37 #: src/Module/FriendSuggest.php:131 src/Module/Install.php:220 #: src/Module/Install.php:260 src/Module/Install.php:295 @@ -792,15 +792,15 @@ msgstr "" msgid "Common" msgstr "" -#: src/Console/Addon.php:161 src/Console/Addon.php:185 +#: src/Console/Addon.php:163 src/Console/Addon.php:187 msgid "Addon not found" msgstr "" -#: src/Console/Addon.php:165 +#: src/Console/Addon.php:167 msgid "Addon already enabled" msgstr "" -#: src/Console/Addon.php:189 +#: src/Console/Addon.php:191 msgid "Addon already disabled" msgstr "" @@ -1065,7 +1065,7 @@ msgstr "" msgid "Email" msgstr "" -#: src/Content/ContactSelector.php:116 src/Module/Debug/Babel.php:301 +#: src/Content/ContactSelector.php:116 src/Module/Debug/Babel.php:277 msgid "Diaspora" msgstr "" @@ -1365,7 +1365,7 @@ msgstr "" msgid "Public post" msgstr "" -#: src/Content/Conversation.php:410 src/Content/Widget/VCard.php:117 +#: src/Content/Conversation.php:410 src/Content/Widget/VCard.php:116 #: src/Model/Profile.php:462 src/Module/Admin/Logs/View.php:80 #: src/Module/Post/Edit.php:167 msgid "Message" @@ -1881,7 +1881,7 @@ msgid "Send PM" msgstr "" #: src/Content/Item.php:421 src/Module/Contact.php:449 -#: src/Module/Contact/Profile.php:518 +#: src/Module/Contact/Profile.php:519 #: src/Module/Moderation/Blocklist/Contact.php:102 #: src/Module/Moderation/Users/Active.php:123 #: src/Module/Moderation/Users/Index.php:138 @@ -1889,7 +1889,7 @@ msgid "Block" msgstr "" #: src/Content/Item.php:422 src/Module/Contact.php:450 -#: src/Module/Contact/Profile.php:526 +#: src/Module/Contact/Profile.php:527 #: src/Module/Notifications/Introductions.php:126 #: src/Module/Notifications/Introductions.php:198 #: src/Module/Notifications/Notification.php:75 @@ -1897,7 +1897,7 @@ msgid "Ignore" msgstr "" #: src/Content/Item.php:423 src/Module/Contact.php:451 -#: src/Module/Contact/Profile.php:534 +#: src/Module/Contact/Profile.php:535 msgid "Collapse" msgstr "" @@ -1969,7 +1969,7 @@ msgstr "" #: src/Content/Nav.php:216 src/Module/BaseProfile.php:35 #: src/Module/BaseSettings.php:84 src/Module/Contact.php:485 -#: src/Module/Contact/Profile.php:425 src/Module/Profile/Profile.php:256 +#: src/Module/Contact/Profile.php:426 src/Module/Profile/Profile.php:256 #: src/Module/Welcome.php:43 view/theme/frio/theme.php:221 msgid "Profile" msgstr "" @@ -2278,8 +2278,8 @@ msgstr "" msgid "The end" msgstr "" -#: src/Content/Text/HTML.php:847 src/Content/Widget/VCard.php:113 -#: src/Model/Profile.php:456 src/Module/Contact/Profile.php:478 +#: src/Content/Text/HTML.php:847 src/Content/Widget/VCard.php:112 +#: src/Model/Profile.php:456 src/Module/Contact/Profile.php:479 msgid "Follow" msgstr "" @@ -2421,18 +2421,18 @@ msgstr "" msgid "Export calendar as csv" msgstr "" -#: src/Content/Widget/ContactBlock.php:65 +#: src/Content/Widget/ContactBlock.php:64 msgid "No contacts" msgstr "" -#: src/Content/Widget/ContactBlock.php:96 +#: src/Content/Widget/ContactBlock.php:95 #, php-format msgid "%d Contact" msgid_plural "%d Contacts" msgstr[0] "" msgstr[1] "" -#: src/Content/Widget/ContactBlock.php:113 +#: src/Content/Widget/ContactBlock.php:112 msgid "View Contacts" msgstr "" @@ -2451,46 +2451,46 @@ msgstr[1] "" msgid "More Trending Tags" msgstr "" -#: src/Content/Widget/VCard.php:91 src/Model/Contact.php:1212 +#: src/Content/Widget/VCard.php:90 src/Model/Contact.php:1212 #: src/Model/Profile.php:441 msgid "Post to group" msgstr "" -#: src/Content/Widget/VCard.php:96 src/Model/Contact.php:1216 +#: src/Content/Widget/VCard.php:95 src/Model/Contact.php:1216 #: src/Model/Profile.php:445 src/Module/Moderation/Item/Source.php:77 msgid "Mention" msgstr "" -#: src/Content/Widget/VCard.php:106 src/Model/Profile.php:360 -#: src/Module/Contact/Profile.php:414 src/Module/Profile/Profile.php:187 +#: src/Content/Widget/VCard.php:105 src/Model/Profile.php:360 +#: src/Module/Contact/Profile.php:415 src/Module/Profile/Profile.php:187 msgid "XMPP:" msgstr "" -#: src/Content/Widget/VCard.php:107 src/Model/Profile.php:361 -#: src/Module/Contact/Profile.php:416 src/Module/Profile/Profile.php:191 +#: src/Content/Widget/VCard.php:106 src/Model/Profile.php:361 +#: src/Module/Contact/Profile.php:417 src/Module/Profile/Profile.php:191 msgid "Matrix:" msgstr "" -#: src/Content/Widget/VCard.php:108 src/Model/Event.php:68 +#: src/Content/Widget/VCard.php:107 src/Model/Event.php:68 #: src/Model/Event.php:95 src/Model/Event.php:457 src/Model/Event.php:946 -#: src/Model/Profile.php:355 src/Module/Contact/Profile.php:412 +#: src/Model/Profile.php:355 src/Module/Contact/Profile.php:413 #: src/Module/Directory.php:134 src/Module/Notifications/Introductions.php:179 #: src/Module/Profile/Profile.php:209 msgid "Location:" msgstr "" -#: src/Content/Widget/VCard.php:111 src/Model/Profile.php:469 +#: src/Content/Widget/VCard.php:110 src/Model/Profile.php:469 #: src/Module/Notifications/Introductions.php:193 msgid "Network:" msgstr "" -#: src/Content/Widget/VCard.php:115 src/Model/Contact.php:1244 +#: src/Content/Widget/VCard.php:114 src/Model/Contact.php:1244 #: src/Model/Contact.php:1256 src/Model/Profile.php:458 -#: src/Module/Contact/Profile.php:470 +#: src/Module/Contact/Profile.php:471 msgid "Unfollow" msgstr "" -#: src/Content/Widget/VCard.php:121 src/Model/Contact.php:1214 +#: src/Content/Widget/VCard.php:120 src/Model/Contact.php:1214 #: src/Model/Profile.php:443 msgid "View group" msgstr "" @@ -3481,7 +3481,7 @@ msgstr "" msgid "Homepage:" msgstr "" -#: src/Model/Profile.php:359 src/Module/Contact/Profile.php:418 +#: src/Model/Profile.php:359 src/Module/Contact/Profile.php:419 #: src/Module/Notifications/Introductions.php:181 msgid "About:" msgstr "" @@ -4198,7 +4198,7 @@ msgid "Data" msgstr "" #: src/Module/Admin/Logs/View.php:86 -#: src/Module/Debug/ActivityPubConversion.php:49 +#: src/Module/Debug/ActivityPubConversion.php:45 msgid "Source" msgstr "" @@ -5175,7 +5175,7 @@ msgstr "" msgid "Can be \"all\" or \"tags\". \"all\" means that every public post should be received. \"tags\" means that only posts with selected tags should be received." msgstr "" -#: src/Module/Admin/Site.php:584 src/Module/Contact/Profile.php:314 +#: src/Module/Admin/Site.php:584 src/Module/Contact/Profile.php:315 #: src/Module/Settings/TwoFactor/Index.php:132 msgid "Disabled" msgstr "" @@ -5628,7 +5628,7 @@ msgstr "" msgid "Babel" msgstr "" -#: src/Module/BaseAdmin.php:97 src/Module/Debug/ActivityPubConversion.php:129 +#: src/Module/BaseAdmin.php:97 src/Module/Debug/ActivityPubConversion.php:121 msgid "ActivityPub Conversion" msgstr "" @@ -5928,8 +5928,8 @@ msgstr "" #: src/Module/Contact/Conversations.php:77 #: src/Module/Contact/Conversations.php:82 src/Module/Contact/Media.php:47 #: src/Module/Contact/Posts.php:64 src/Module/Contact/Posts.php:69 -#: src/Module/Contact/Posts.php:74 src/Module/Contact/Profile.php:145 -#: src/Module/Contact/Profile.php:150 src/Module/Contact/Profile.php:169 +#: src/Module/Contact/Posts.php:74 src/Module/Contact/Profile.php:146 +#: src/Module/Contact/Profile.php:151 src/Module/Contact/Profile.php:170 #: src/Module/Contact/Redir.php:77 src/Module/Contact/Redir.php:131 #: src/Module/FriendSuggest.php:57 src/Module/FriendSuggest.php:95 msgid "Contact not found." @@ -6086,18 +6086,18 @@ msgstr "" msgid "Update" msgstr "" -#: src/Module/Contact.php:449 src/Module/Contact/Profile.php:518 +#: src/Module/Contact.php:449 src/Module/Contact/Profile.php:519 #: src/Module/Moderation/Blocklist/Contact.php:103 #: src/Module/Moderation/Users/Blocked.php:124 #: src/Module/Moderation/Users/Index.php:140 msgid "Unblock" msgstr "" -#: src/Module/Contact.php:450 src/Module/Contact/Profile.php:526 +#: src/Module/Contact.php:450 src/Module/Contact/Profile.php:527 msgid "Unignore" msgstr "" -#: src/Module/Contact.php:451 src/Module/Contact/Profile.php:534 +#: src/Module/Contact.php:451 src/Module/Contact/Profile.php:535 msgid "Uncollapse" msgstr "" @@ -6149,7 +6149,7 @@ msgstr "" msgid "Pending incoming contact request" msgstr "" -#: src/Module/Contact.php:608 src/Module/Contact/Profile.php:377 +#: src/Module/Contact.php:608 src/Module/Contact/Profile.php:378 #, php-format msgid "Visit %s's profile [%s]" msgstr "" @@ -6246,7 +6246,7 @@ msgstr[1] "" #: src/Module/Contact/Follow.php:56 src/Module/Contact/Redir.php:45 #: src/Module/Contact/Redir.php:206 src/Module/Conversation/Community.php:154 -#: src/Module/Debug/ItemBody.php:24 src/Module/Diaspora/Receive.php:45 +#: src/Module/Debug/ItemBody.php:30 src/Module/Diaspora/Receive.php:45 #: src/Module/Item/Display.php:82 src/Module/Item/Feed.php:45 #: src/Module/Item/Follow.php:27 src/Module/Item/Ignore.php:27 #: src/Module/Item/Language.php:39 src/Module/Item/Pin.php:27 @@ -6280,7 +6280,7 @@ msgstr "" msgid "Your Identity Address:" msgstr "" -#: src/Module/Contact/Follow.php:151 src/Module/Contact/Profile.php:408 +#: src/Module/Contact/Follow.php:151 src/Module/Contact/Profile.php:409 #: src/Module/Contact/Unfollow.php:115 #: src/Module/Moderation/Blocklist/Contact.php:117 #: src/Module/Moderation/Reports.php:109 @@ -6289,7 +6289,7 @@ msgstr "" msgid "Profile URL" msgstr "" -#: src/Module/Contact/Follow.php:152 src/Module/Contact/Profile.php:420 +#: src/Module/Contact/Follow.php:152 src/Module/Contact/Profile.php:421 #: src/Module/Notifications/Introductions.php:183 #: src/Module/Profile/Profile.php:222 msgid "Tags:" @@ -6332,297 +6332,297 @@ msgstr "" msgid "Failed to update contact record." msgstr "" -#: src/Module/Contact/Profile.php:195 +#: src/Module/Contact/Profile.php:196 msgid "Contact has been unblocked" msgstr "" -#: src/Module/Contact/Profile.php:199 +#: src/Module/Contact/Profile.php:200 msgid "Contact has been blocked" msgstr "" -#: src/Module/Contact/Profile.php:211 +#: src/Module/Contact/Profile.php:212 msgid "Contact has been unignored" msgstr "" -#: src/Module/Contact/Profile.php:215 +#: src/Module/Contact/Profile.php:216 msgid "Contact has been ignored" msgstr "" -#: src/Module/Contact/Profile.php:227 +#: src/Module/Contact/Profile.php:228 msgid "Contact has been uncollapsed" msgstr "" -#: src/Module/Contact/Profile.php:231 +#: src/Module/Contact/Profile.php:232 msgid "Contact has been collapsed" msgstr "" -#: src/Module/Contact/Profile.php:259 -#, php-format -msgid "You are mutual friends with %s" -msgstr "" - #: src/Module/Contact/Profile.php:260 #, php-format -msgid "You are sharing with %s" +msgid "You are mutual friends with %s" msgstr "" #: src/Module/Contact/Profile.php:261 #, php-format +msgid "You are sharing with %s" +msgstr "" + +#: src/Module/Contact/Profile.php:262 +#, php-format msgid "%s is sharing with you" msgstr "" -#: src/Module/Contact/Profile.php:277 +#: src/Module/Contact/Profile.php:278 msgid "Private communications are not available for this contact." msgstr "" -#: src/Module/Contact/Profile.php:287 +#: src/Module/Contact/Profile.php:288 msgid "This contact is on a server you ignored." msgstr "" -#: src/Module/Contact/Profile.php:290 +#: src/Module/Contact/Profile.php:291 msgid "Never" msgstr "" -#: src/Module/Contact/Profile.php:293 +#: src/Module/Contact/Profile.php:294 msgid "(Update was not successful)" msgstr "" -#: src/Module/Contact/Profile.php:293 +#: src/Module/Contact/Profile.php:294 msgid "(Update was successful)" msgstr "" -#: src/Module/Contact/Profile.php:295 src/Module/Contact/Profile.php:489 +#: src/Module/Contact/Profile.php:296 src/Module/Contact/Profile.php:490 msgid "Suggest friends" msgstr "" -#: src/Module/Contact/Profile.php:299 +#: src/Module/Contact/Profile.php:300 #, php-format msgid "Network type: %s" msgstr "" -#: src/Module/Contact/Profile.php:304 +#: src/Module/Contact/Profile.php:305 msgid "Communications lost with this contact!" msgstr "" -#: src/Module/Contact/Profile.php:310 +#: src/Module/Contact/Profile.php:311 msgid "Fetch further information for feeds" msgstr "" -#: src/Module/Contact/Profile.php:312 +#: src/Module/Contact/Profile.php:313 msgid "Fetch information like preview pictures, title and teaser from the feed item. You can activate this if the feed doesn't contain much text. Keywords are taken from the meta header in the feed item and are posted as hash tags." msgstr "" -#: src/Module/Contact/Profile.php:315 +#: src/Module/Contact/Profile.php:316 msgid "Fetch information" msgstr "" -#: src/Module/Contact/Profile.php:316 +#: src/Module/Contact/Profile.php:317 msgid "Fetch keywords" msgstr "" -#: src/Module/Contact/Profile.php:317 +#: src/Module/Contact/Profile.php:318 msgid "Fetch information and keywords" msgstr "" -#: src/Module/Contact/Profile.php:327 src/Module/Contact/Profile.php:332 -#: src/Module/Contact/Profile.php:337 src/Module/Contact/Profile.php:343 +#: src/Module/Contact/Profile.php:328 src/Module/Contact/Profile.php:333 +#: src/Module/Contact/Profile.php:338 src/Module/Contact/Profile.php:344 msgid "No mirroring" msgstr "" -#: src/Module/Contact/Profile.php:328 src/Module/Contact/Profile.php:338 -#: src/Module/Contact/Profile.php:344 +#: src/Module/Contact/Profile.php:329 src/Module/Contact/Profile.php:339 +#: src/Module/Contact/Profile.php:345 msgid "Mirror as my own posting" msgstr "" -#: src/Module/Contact/Profile.php:333 src/Module/Contact/Profile.php:339 +#: src/Module/Contact/Profile.php:334 src/Module/Contact/Profile.php:340 msgid "Native reshare" msgstr "" -#: src/Module/Contact/Profile.php:359 +#: src/Module/Contact/Profile.php:360 msgid "Contact Information / Notes" msgstr "" -#: src/Module/Contact/Profile.php:360 +#: src/Module/Contact/Profile.php:361 msgid "Contact Settings" msgstr "" -#: src/Module/Contact/Profile.php:368 +#: src/Module/Contact/Profile.php:369 msgid "Contact" msgstr "" -#: src/Module/Contact/Profile.php:372 +#: src/Module/Contact/Profile.php:373 msgid "Their personal note" msgstr "" -#: src/Module/Contact/Profile.php:374 +#: src/Module/Contact/Profile.php:375 msgid "Edit contact notes" msgstr "" -#: src/Module/Contact/Profile.php:378 +#: src/Module/Contact/Profile.php:379 msgid "Block/Unblock contact" msgstr "" -#: src/Module/Contact/Profile.php:379 +#: src/Module/Contact/Profile.php:380 #: src/Module/Moderation/Report/Create.php:279 msgid "Ignore contact" msgstr "" -#: src/Module/Contact/Profile.php:380 +#: src/Module/Contact/Profile.php:381 msgid "View conversations" msgstr "" -#: src/Module/Contact/Profile.php:385 +#: src/Module/Contact/Profile.php:386 msgid "Last update:" msgstr "" -#: src/Module/Contact/Profile.php:387 +#: src/Module/Contact/Profile.php:388 msgid "Update public posts" msgstr "" -#: src/Module/Contact/Profile.php:389 src/Module/Contact/Profile.php:499 +#: src/Module/Contact/Profile.php:390 src/Module/Contact/Profile.php:500 msgid "Update now" msgstr "" -#: src/Module/Contact/Profile.php:391 +#: src/Module/Contact/Profile.php:392 msgid "Awaiting connection acknowledge" msgstr "" -#: src/Module/Contact/Profile.php:392 +#: src/Module/Contact/Profile.php:393 msgid "Currently blocked" msgstr "" -#: src/Module/Contact/Profile.php:393 +#: src/Module/Contact/Profile.php:394 msgid "Currently ignored" msgstr "" -#: src/Module/Contact/Profile.php:394 +#: src/Module/Contact/Profile.php:395 msgid "Currently collapsed" msgstr "" -#: src/Module/Contact/Profile.php:395 +#: src/Module/Contact/Profile.php:396 msgid "Currently archived" msgstr "" -#: src/Module/Contact/Profile.php:398 +#: src/Module/Contact/Profile.php:399 msgid "Manage remote servers" msgstr "" -#: src/Module/Contact/Profile.php:400 +#: src/Module/Contact/Profile.php:401 #: src/Module/Notifications/Introductions.php:184 msgid "Hide this contact from others" msgstr "" -#: src/Module/Contact/Profile.php:400 +#: src/Module/Contact/Profile.php:401 msgid "Replies/likes to your public posts may still be visible" msgstr "" -#: src/Module/Contact/Profile.php:401 +#: src/Module/Contact/Profile.php:402 msgid "Notification for new posts" msgstr "" -#: src/Module/Contact/Profile.php:401 +#: src/Module/Contact/Profile.php:402 msgid "Send a notification of every new post of this contact" msgstr "" -#: src/Module/Contact/Profile.php:403 +#: src/Module/Contact/Profile.php:404 msgid "Keyword Deny List" msgstr "" -#: src/Module/Contact/Profile.php:403 +#: src/Module/Contact/Profile.php:404 msgid "Comma separated list of keywords that should not be converted to hashtags, when \"Fetch information and keywords\" is selected" msgstr "" -#: src/Module/Contact/Profile.php:421 +#: src/Module/Contact/Profile.php:422 #: src/Module/Settings/TwoFactor/Index.php:146 msgid "Actions" msgstr "" -#: src/Module/Contact/Profile.php:423 +#: src/Module/Contact/Profile.php:424 #: src/Module/Settings/TwoFactor/Index.php:126 view/theme/frio/theme.php:220 msgid "Status" msgstr "" -#: src/Module/Contact/Profile.php:429 +#: src/Module/Contact/Profile.php:430 msgid "Mirror postings from this contact" msgstr "" -#: src/Module/Contact/Profile.php:431 +#: src/Module/Contact/Profile.php:432 msgid "Mark this contact as remote_self, this will cause friendica to repost new entries from this contact." msgstr "" -#: src/Module/Contact/Profile.php:434 +#: src/Module/Contact/Profile.php:435 msgid "Channel Settings" msgstr "" -#: src/Module/Contact/Profile.php:435 +#: src/Module/Contact/Profile.php:436 msgid "Frequency of this contact in relevant channels" msgstr "" -#: src/Module/Contact/Profile.php:436 +#: src/Module/Contact/Profile.php:437 msgid "Depending on the type of the channel not all posts from this contact are displayed. By default, posts need to have a minimum amount of interactions (comments, likes) to show in your channels. On the other hand there can be contacts who flood the channel, so you might want to see only some of their posts. Or you don't want to see their content at all, but you don't want to block or hide the contact completely." msgstr "" -#: src/Module/Contact/Profile.php:437 +#: src/Module/Contact/Profile.php:438 msgid "Default frequency" msgstr "" -#: src/Module/Contact/Profile.php:437 +#: src/Module/Contact/Profile.php:438 msgid "Posts by this contact are displayed in the \"for you\" channel if you interact often with this contact or if a post reached some level of interaction." msgstr "" -#: src/Module/Contact/Profile.php:438 +#: src/Module/Contact/Profile.php:439 msgid "Display all posts of this contact" msgstr "" -#: src/Module/Contact/Profile.php:438 +#: src/Module/Contact/Profile.php:439 msgid "All posts from this contact will appear on the \"for you\" channel" msgstr "" -#: src/Module/Contact/Profile.php:439 +#: src/Module/Contact/Profile.php:440 msgid "Display only few posts" msgstr "" -#: src/Module/Contact/Profile.php:439 +#: src/Module/Contact/Profile.php:440 msgid "When a contact creates a lot of posts in a short period, this setting reduces the number of displayed posts in every channel." msgstr "" -#: src/Module/Contact/Profile.php:440 +#: src/Module/Contact/Profile.php:441 msgid "Never display posts" msgstr "" -#: src/Module/Contact/Profile.php:440 +#: src/Module/Contact/Profile.php:441 msgid "Posts from this contact will never be displayed in any channel" msgstr "" -#: src/Module/Contact/Profile.php:441 +#: src/Module/Contact/Profile.php:442 msgid "Channel Only" msgstr "" -#: src/Module/Contact/Profile.php:441 +#: src/Module/Contact/Profile.php:442 msgid "If enabled, posts from this contact will only appear in channels and network streams in circles, but not in the general network stream." msgstr "" -#: src/Module/Contact/Profile.php:509 +#: src/Module/Contact/Profile.php:510 msgid "Refetch contact data" msgstr "" -#: src/Module/Contact/Profile.php:520 +#: src/Module/Contact/Profile.php:521 msgid "Toggle Blocked status" msgstr "" -#: src/Module/Contact/Profile.php:528 +#: src/Module/Contact/Profile.php:529 msgid "Toggle Ignored status" msgstr "" -#: src/Module/Contact/Profile.php:536 +#: src/Module/Contact/Profile.php:537 msgid "Toggle Collapsed status" msgstr "" -#: src/Module/Contact/Profile.php:543 src/Module/Contact/Revoke.php:89 +#: src/Module/Contact/Profile.php:544 src/Module/Contact/Revoke.php:89 msgid "Revoke Follow" msgstr "" -#: src/Module/Contact/Profile.php:545 +#: src/Module/Contact/Profile.php:546 msgid "Revoke the follow from this contact" msgstr "" @@ -6722,207 +6722,199 @@ msgstr "" msgid "Friendica is a community project, that would not be possible without the help of many people. Here is a list of those who have contributed to the code or the translation of Friendica. Thank you all!" msgstr "" -#: src/Module/Debug/ActivityPubConversion.php:45 +#: src/Module/Debug/ActivityPubConversion.php:41 msgid "Formatted" msgstr "" -#: src/Module/Debug/ActivityPubConversion.php:57 +#: src/Module/Debug/ActivityPubConversion.php:53 msgid "Activity" msgstr "" -#: src/Module/Debug/ActivityPubConversion.php:109 +#: src/Module/Debug/ActivityPubConversion.php:101 msgid "Object data" msgstr "" -#: src/Module/Debug/ActivityPubConversion.php:116 +#: src/Module/Debug/ActivityPubConversion.php:108 msgid "Result Item" msgstr "" -#: src/Module/Debug/ActivityPubConversion.php:121 -#: src/Module/Debug/Babel.php:286 src/Module/Moderation/Item/Source.php:79 +#: src/Module/Debug/ActivityPubConversion.php:113 +#: src/Module/Debug/Babel.php:262 src/Module/Moderation/Item/Source.php:79 #: src/Module/Security/TwoFactor/Verify.php:84 msgid "Error" msgid_plural "Errors" msgstr[0] "" msgstr[1] "" -#: src/Module/Debug/ActivityPubConversion.php:130 +#: src/Module/Debug/ActivityPubConversion.php:122 msgid "Source activity" msgstr "" -#: src/Module/Debug/Babel.php:44 +#: src/Module/Debug/Babel.php:39 msgid "Source input" msgstr "" -#: src/Module/Debug/Babel.php:50 +#: src/Module/Debug/Babel.php:45 msgid "BBCode::toPlaintext" msgstr "" -#: src/Module/Debug/Babel.php:56 +#: src/Module/Debug/Babel.php:51 msgid "BBCode::convert (raw HTML)" msgstr "" -#: src/Module/Debug/Babel.php:61 +#: src/Module/Debug/Babel.php:56 msgid "BBCode::convert (hex)" msgstr "" -#: src/Module/Debug/Babel.php:66 +#: src/Module/Debug/Babel.php:61 msgid "BBCode::convert" msgstr "" -#: src/Module/Debug/Babel.php:72 +#: src/Module/Debug/Babel.php:67 msgid "BBCode::convert => HTML::toBBCode" msgstr "" -#: src/Module/Debug/Babel.php:78 +#: src/Module/Debug/Babel.php:73 msgid "BBCode::toMarkdown" msgstr "" -#: src/Module/Debug/Babel.php:84 +#: src/Module/Debug/Babel.php:79 msgid "BBCode::toMarkdown => Markdown::convert (raw HTML)" msgstr "" -#: src/Module/Debug/Babel.php:88 +#: src/Module/Debug/Babel.php:83 msgid "BBCode::toMarkdown => Markdown::convert" msgstr "" -#: src/Module/Debug/Babel.php:94 +#: src/Module/Debug/Babel.php:89 msgid "BBCode::toMarkdown => Markdown::toBBCode" msgstr "" -#: src/Module/Debug/Babel.php:100 +#: src/Module/Debug/Babel.php:95 msgid "BBCode::toMarkdown => Markdown::convert => HTML::toBBCode" msgstr "" -#: src/Module/Debug/Babel.php:108 +#: src/Module/Debug/Babel.php:103 msgid "Item Body" msgstr "" -#: src/Module/Debug/Babel.php:112 +#: src/Module/Debug/Babel.php:107 msgid "Item Tags" msgstr "" -#: src/Module/Debug/Babel.php:118 +#: src/Module/Debug/Babel.php:113 msgid "PageInfo::appendToBody" msgstr "" -#: src/Module/Debug/Babel.php:123 +#: src/Module/Debug/Babel.php:118 msgid "PageInfo::appendToBody => BBCode::convert (raw HTML)" msgstr "" -#: src/Module/Debug/Babel.php:127 +#: src/Module/Debug/Babel.php:122 msgid "PageInfo::appendToBody => BBCode::convert" msgstr "" -#: src/Module/Debug/Babel.php:134 +#: src/Module/Debug/Babel.php:129 msgid "Source input (Diaspora format)" msgstr "" -#: src/Module/Debug/Babel.php:143 +#: src/Module/Debug/Babel.php:138 msgid "Source input (Markdown)" msgstr "" -#: src/Module/Debug/Babel.php:149 +#: src/Module/Debug/Babel.php:144 msgid "Markdown::convert (raw HTML)" msgstr "" -#: src/Module/Debug/Babel.php:154 +#: src/Module/Debug/Babel.php:149 msgid "Markdown::convert" msgstr "" -#: src/Module/Debug/Babel.php:160 +#: src/Module/Debug/Babel.php:155 msgid "Markdown::toBBCode" msgstr "" -#: src/Module/Debug/Babel.php:167 +#: src/Module/Debug/Babel.php:162 msgid "Raw HTML input" msgstr "" -#: src/Module/Debug/Babel.php:172 +#: src/Module/Debug/Babel.php:167 msgid "HTML Input" msgstr "" -#: src/Module/Debug/Babel.php:179 +#: src/Module/Debug/Babel.php:174 msgid "HTML Purified (raw)" msgstr "" -#: src/Module/Debug/Babel.php:184 +#: src/Module/Debug/Babel.php:179 msgid "HTML Purified (hex)" msgstr "" -#: src/Module/Debug/Babel.php:189 +#: src/Module/Debug/Babel.php:184 msgid "HTML Purified" msgstr "" -#: src/Module/Debug/Babel.php:195 +#: src/Module/Debug/Babel.php:190 msgid "HTML::toBBCode" msgstr "" -#: src/Module/Debug/Babel.php:201 +#: src/Module/Debug/Babel.php:196 msgid "HTML::toBBCode => BBCode::convert" msgstr "" -#: src/Module/Debug/Babel.php:206 +#: src/Module/Debug/Babel.php:201 msgid "HTML::toBBCode => BBCode::convert (raw HTML)" msgstr "" -#: src/Module/Debug/Babel.php:212 +#: src/Module/Debug/Babel.php:207 msgid "HTML::toBBCode => BBCode::toPlaintext" msgstr "" -#: src/Module/Debug/Babel.php:218 +#: src/Module/Debug/Babel.php:213 msgid "HTML::toMarkdown" msgstr "" -#: src/Module/Debug/Babel.php:224 +#: src/Module/Debug/Babel.php:219 msgid "HTML::toPlaintext" msgstr "" -#: src/Module/Debug/Babel.php:230 +#: src/Module/Debug/Babel.php:225 msgid "HTML::toPlaintext (compact)" msgstr "" -#: src/Module/Debug/Babel.php:248 +#: src/Module/Debug/Babel.php:238 msgid "Decoded post" msgstr "" -#: src/Module/Debug/Babel.php:269 +#: src/Module/Debug/Babel.php:257 msgid "Post array before expand entities" msgstr "" -#: src/Module/Debug/Babel.php:276 -msgid "Post converted" -msgstr "" - -#: src/Module/Debug/Babel.php:281 -msgid "Converted body" -msgstr "" - -#: src/Module/Debug/Babel.php:287 +#: src/Module/Debug/Babel.php:263 msgid "Twitter addon is absent from the addon/ folder." msgstr "" -#: src/Module/Debug/Babel.php:297 +#: src/Module/Debug/Babel.php:273 msgid "Babel Diagnostic" msgstr "" -#: src/Module/Debug/Babel.php:299 +#: src/Module/Debug/Babel.php:275 msgid "Source text" msgstr "" -#: src/Module/Debug/Babel.php:300 +#: src/Module/Debug/Babel.php:276 msgid "BBCode" msgstr "" -#: src/Module/Debug/Babel.php:302 +#: src/Module/Debug/Babel.php:278 msgid "Markdown" msgstr "" -#: src/Module/Debug/Babel.php:303 +#: src/Module/Debug/Babel.php:279 msgid "HTML" msgstr "" -#: src/Module/Debug/Babel.php:305 +#: src/Module/Debug/Babel.php:281 msgid "Twitter Source / Tweet URL (requires API key)" msgstr "" From 12d5e4da44d32752eda4540674f64e8d7a1639b3 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 11 Nov 2024 23:40:45 +0000 Subject: [PATCH 33/38] use get_class() instead of static() in BaseCollection --- src/BaseCollection.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/BaseCollection.php b/src/BaseCollection.php index 9598b1ae78..b30dbfc6b0 100644 --- a/src/BaseCollection.php +++ b/src/BaseCollection.php @@ -89,7 +89,9 @@ class BaseCollection extends \ArrayIterator */ public function map(callable $callback): BaseCollection { - return new self(array_map($callback, $this->getArrayCopy()), $this->getTotalCount()); + $class = get_class($this); + + return new $class(array_map($callback, $this->getArrayCopy()), $this->getTotalCount()); } /** @@ -102,7 +104,9 @@ class BaseCollection extends \ArrayIterator */ public function filter(callable $callback = null, int $flag = 0): BaseCollection { - return new self(array_filter($this->getArrayCopy(), $callback, $flag)); + $class = get_class($this); + + return new $class(array_filter($this->getArrayCopy(), $callback, $flag)); } /** @@ -112,14 +116,16 @@ class BaseCollection extends \ArrayIterator */ public function reverse(): BaseCollection { - return new self(array_reverse($this->getArrayCopy()), $this->getTotalCount()); + $class = get_class($this); + + return new $class(array_reverse($this->getArrayCopy()), $this->getTotalCount()); } /** * Split the collection in smaller collections no bigger than the provided length * * @param int $length - * @return self[] + * @return static[] */ public function chunk(int $length): array { @@ -128,7 +134,9 @@ class BaseCollection extends \ArrayIterator } return array_map(function ($array) { - return new self($array); + $class = get_class($this); + + return new $class($array); }, array_chunk($this->getArrayCopy(), $length)); } From 9a04f90bbdf5d842592452f47720a73d4b1ba3d5 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 12 Nov 2024 00:20:30 +0000 Subject: [PATCH 34/38] Improve check for unlisted receiver --- src/Protocol/ActivityPub/Receiver.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index e31b8fb3d6..0f8184d3db 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -1890,18 +1890,15 @@ class Receiver $object_data['receiver_urls'] = self::getReceiverURL($object); $object_data['receiver'] = $receivers; $object_data['reception_type'] = $reception_types; + $object_data['unlisted'] = false; if (!empty($object['pixelfed:capabilities'])) { $object_data['capabilities'] = self::getCapabilities($object); } - $object_data['unlisted'] = in_array(-1, $object_data['receiver']); - - if (array_key_exists(-1, $object_data['receiver'])) { + if (in_array(-1, $object_data['receiver'])) { + $object_data['unlisted'] = true; unset($object_data['receiver'][-1]); - } - - if (array_key_exists(-1, $object_data['reception_type'])) { unset($object_data['reception_type'][-1]); } From ca51b45f04987dc2184ba7faec564e332115c851 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 12 Nov 2024 21:02:21 +0000 Subject: [PATCH 35/38] Upgrade to PHPStan 2.0 --- composer.json | 2 +- composer.lock | 14 +++++++------- src/Protocol/ActivityPub/Receiver.php | 5 ++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 2090075024..4acfe7e41a 100644 --- a/composer.json +++ b/composer.json @@ -152,7 +152,7 @@ "mikey179/vfsstream": "^1.6", "mockery/mockery": "^1.3", "php-mock/php-mock-phpunit": "^2.10", - "phpstan/phpstan": "^1.12", + "phpstan/phpstan": "^2.0", "phpunit/phpunit": "^9" }, "scripts": { diff --git a/composer.lock b/composer.lock index 7d1e831b14..8d200a3f67 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "11175d4e9806e8a5069d010140431af1", + "content-hash": "3e31a2243fb69e47e1b7000cca946fa2", "packages": [ { "name": "asika/simple-console", @@ -4834,20 +4834,20 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.7", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0" + "reference": "ab4e9b4415a5fc9e4d27f7fe16c8bc9d067dcd6d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", - "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ab4e9b4415a5fc9e4d27f7fe16c8bc9d067dcd6d", + "reference": "ab4e9b4415a5fc9e4d27f7fe16c8bc9d067dcd6d", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -4888,7 +4888,7 @@ "type": "github" } ], - "time": "2024-10-18T11:12:07+00:00" + "time": "2024-11-11T15:43:04+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 0f8184d3db..06bedd4eba 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -1899,7 +1899,10 @@ class Receiver if (in_array(-1, $object_data['receiver'])) { $object_data['unlisted'] = true; unset($object_data['receiver'][-1]); - unset($object_data['reception_type'][-1]); + + if (array_key_exists(-1, $object_data['reception_type'])) { + unset($object_data['reception_type'][-1]); + } } return $object_data; From 3e523ddd0990f9b420195eed7c65a411d8500424 Mon Sep 17 00:00:00 2001 From: Artur Weigandt Date: Tue, 12 Nov 2024 22:03:09 +0100 Subject: [PATCH 36/38] Update src/Protocol/ActivityPub/Receiver.php Co-authored-by: Hypolite Petovan --- src/Protocol/ActivityPub/Receiver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 06bedd4eba..8055ff6666 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -1890,7 +1890,7 @@ class Receiver $object_data['receiver_urls'] = self::getReceiverURL($object); $object_data['receiver'] = $receivers; $object_data['reception_type'] = $reception_types; - $object_data['unlisted'] = false; + $object_data['unlisted'] = false; if (!empty($object['pixelfed:capabilities'])) { $object_data['capabilities'] = self::getCapabilities($object); From ee2cdc7763411ff54b7f2f17a69662a2e7f19742 Mon Sep 17 00:00:00 2001 From: Art4 Date: Wed, 13 Nov 2024 07:49:29 +0000 Subject: [PATCH 37/38] replace method with anonymous function --- src/Module/Debug/ActivityPubConversion.php | 19 +++---- src/Module/Debug/Babel.php | 64 +++++++++++----------- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/src/Module/Debug/ActivityPubConversion.php b/src/Module/Debug/ActivityPubConversion.php index 9b0465f016..da165174b8 100644 --- a/src/Module/Debug/ActivityPubConversion.php +++ b/src/Module/Debug/ActivityPubConversion.php @@ -25,6 +25,10 @@ class ActivityPubConversion extends BaseModule { $results = []; + $visible_whitespace = function (string $s): string { + return '
' . htmlspecialchars($s) . '
'; + }; + if (!empty($_REQUEST['source'])) { try { $source = json_decode($_REQUEST['source'], true); @@ -39,11 +43,11 @@ class ActivityPubConversion extends BaseModule $formatted = json_encode($source, JSON_PRETTY_PRINT); $results[] = [ 'title' => DI::l10n()->t('Formatted'), - 'content' => $this->visible_whitespace(trim(var_export($formatted, true), "'")), + 'content' => $visible_whitespace(trim(var_export($formatted, true), "'")), ]; $results[] = [ 'title' => DI::l10n()->t('Source'), - 'content' => $this->visible_whitespace(var_export($source, true)) + 'content' => $visible_whitespace(var_export($source, true)) ]; $activity = JsonLD::compact($source); if (!$activity) { @@ -51,7 +55,7 @@ class ActivityPubConversion extends BaseModule } $results[] = [ 'title' => DI::l10n()->t('Activity'), - 'content' => $this->visible_whitespace(var_export($activity, true)) + 'content' => $visible_whitespace(var_export($activity, true)) ]; $type = JsonLD::fetchElement($activity, '@type'); @@ -99,14 +103,14 @@ class ActivityPubConversion extends BaseModule $results[] = [ 'title' => DI::l10n()->t('Object data'), - 'content' => $this->visible_whitespace(var_export($object_data, true)) + 'content' => $visible_whitespace(var_export($object_data, true)) ]; $item = ActivityPub\Processor::createItem($object_data, true); $results[] = [ 'title' => DI::l10n()->t('Result Item'), - 'content' => $this->visible_whitespace(var_export($item, true)) + 'content' => $visible_whitespace(var_export($item, true)) ]; } catch (\Throwable $e) { $results[] = [ @@ -126,9 +130,4 @@ class ActivityPubConversion extends BaseModule return $o; } - - private function visible_whitespace(string $s): string - { - return '
' . htmlspecialchars($s) . '
'; - } } diff --git a/src/Module/Debug/Babel.php b/src/Module/Debug/Babel.php index 10b424850b..e7852847f6 100644 --- a/src/Module/Debug/Babel.php +++ b/src/Module/Debug/Babel.php @@ -30,6 +30,11 @@ class Babel extends BaseModule protected function content(array $request = []): string { $results = []; + + $visible_whitespace = function (string $s): string { + return '
' . htmlspecialchars($s) . '
'; + }; + if (!empty($request['text'])) { self::checkFormSecurityTokenForbiddenOnError('babel'); switch (($request['type'] ?? '') ?: 'bbcode') { @@ -37,24 +42,24 @@ class Babel extends BaseModule $bbcode = $request['text']; $results[] = [ 'title' => DI::l10n()->t('Source input'), - 'content' => $this->visible_whitespace($bbcode) + 'content' => $visible_whitespace($bbcode) ]; $plain = Text\BBCode::toPlaintext($bbcode, false); $results[] = [ 'title' => DI::l10n()->t('BBCode::toPlaintext'), - 'content' => $this->visible_whitespace($plain) + 'content' => $visible_whitespace($plain) ]; $html = Text\BBCode::convertForUriId(0, $bbcode); $results[] = [ 'title' => DI::l10n()->t('BBCode::convert (raw HTML)'), - 'content' => $this->visible_whitespace($html) + 'content' => $visible_whitespace($html) ]; $results[] = [ 'title' => DI::l10n()->t('BBCode::convert (hex)'), - 'content' => $this->visible_whitespace(bin2hex($html)), + 'content' => $visible_whitespace(bin2hex($html)), ]; $results[] = [ @@ -65,19 +70,19 @@ class Babel extends BaseModule $bbcode2 = Text\HTML::toBBCode($html); $results[] = [ 'title' => DI::l10n()->t('BBCode::convert => HTML::toBBCode'), - 'content' => $this->visible_whitespace($bbcode2) + 'content' => $visible_whitespace($bbcode2) ]; $markdown = Text\BBCode::toMarkdown($bbcode); $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown'), - 'content' => $this->visible_whitespace($markdown) + 'content' => $visible_whitespace($markdown) ]; $html2 = Text\Markdown::convert($markdown); $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::convert (raw HTML)'), - 'content' => $this->visible_whitespace($html2) + 'content' => $visible_whitespace($html2) ]; $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::convert'), @@ -87,13 +92,13 @@ class Babel extends BaseModule $bbcode3 = Text\Markdown::toBBCode($markdown); $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::toBBCode'), - 'content' => $this->visible_whitespace($bbcode3) + 'content' => $visible_whitespace($bbcode3) ]; $bbcode4 = Text\HTML::toBBCode($html2); $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::convert => HTML::toBBCode'), - 'content' => $this->visible_whitespace($bbcode4) + 'content' => $visible_whitespace($bbcode4) ]; $tags = Text\BBCode::getTags($bbcode); @@ -101,22 +106,22 @@ class Babel extends BaseModule $body = Item::setHashtags($bbcode); $results[] = [ 'title' => DI::l10n()->t('Item Body'), - 'content' => $this->visible_whitespace($body) + 'content' => $visible_whitespace($body) ]; $results[] = [ 'title' => DI::l10n()->t('Item Tags'), - 'content' => $this->visible_whitespace(var_export($tags, true)), + 'content' => $visible_whitespace(var_export($tags, true)), ]; $body2 = PageInfo::searchAndAppendToBody($bbcode, true); $results[] = [ 'title' => DI::l10n()->t('PageInfo::appendToBody'), - 'content' => $this->visible_whitespace($body2) + 'content' => $visible_whitespace($body2) ]; $html3 = Text\BBCode::convertForUriId(0, $body2); $results[] = [ 'title' => DI::l10n()->t('PageInfo::appendToBody => BBCode::convert (raw HTML)'), - 'content' => $this->visible_whitespace($html3) + 'content' => $visible_whitespace($html3) ]; $results[] = [ 'title' => DI::l10n()->t('PageInfo::appendToBody => BBCode::convert'), @@ -127,7 +132,7 @@ class Babel extends BaseModule $diaspora = trim($request['text']); $results[] = [ 'title' => DI::l10n()->t('Source input (Diaspora format)'), - 'content' => $this->visible_whitespace($diaspora), + 'content' => $visible_whitespace($diaspora), ]; $markdown = XML::unescape($diaspora); @@ -136,13 +141,13 @@ class Babel extends BaseModule $results[] = [ 'title' => DI::l10n()->t('Source input (Markdown)'), - 'content' => $this->visible_whitespace($markdown), + 'content' => $visible_whitespace($markdown), ]; $html = Text\Markdown::convert($markdown); $results[] = [ 'title' => DI::l10n()->t('Markdown::convert (raw HTML)'), - 'content' => $this->visible_whitespace($html), + 'content' => $visible_whitespace($html), ]; $results[] = [ @@ -153,14 +158,14 @@ class Babel extends BaseModule $bbcode = Text\Markdown::toBBCode($markdown); $results[] = [ 'title' => DI::l10n()->t('Markdown::toBBCode'), - 'content' => $this->visible_whitespace($bbcode), + 'content' => $visible_whitespace($bbcode), ]; break; case 'html' : $html = trim($request['text']); $results[] = [ 'title' => DI::l10n()->t('Raw HTML input'), - 'content' => $this->visible_whitespace($html), + 'content' => $visible_whitespace($html), ]; $results[] = [ @@ -172,12 +177,12 @@ class Babel extends BaseModule $results[] = [ 'title' => DI::l10n()->t('HTML Purified (raw)'), - 'content' => $this->visible_whitespace($purified), + 'content' => $visible_whitespace($purified), ]; $results[] = [ 'title' => DI::l10n()->t('HTML Purified (hex)'), - 'content' => $this->visible_whitespace(bin2hex($purified)), + 'content' => $visible_whitespace(bin2hex($purified)), ]; $results[] = [ @@ -188,7 +193,7 @@ class Babel extends BaseModule $bbcode = Text\HTML::toBBCode($html); $results[] = [ 'title' => DI::l10n()->t('HTML::toBBCode'), - 'content' => $this->visible_whitespace($bbcode) + 'content' => $visible_whitespace($bbcode) ]; $html2 = Text\BBCode::convertForUriId(0, $bbcode); @@ -205,25 +210,25 @@ class Babel extends BaseModule $bbcode2plain = Text\BBCode::toPlaintext($bbcode); $results[] = [ 'title' => DI::l10n()->t('HTML::toBBCode => BBCode::toPlaintext'), - 'content' => $this->visible_whitespace($bbcode2plain), + 'content' => $visible_whitespace($bbcode2plain), ]; $markdown = Text\HTML::toMarkdown($html); $results[] = [ 'title' => DI::l10n()->t('HTML::toMarkdown'), - 'content' => $this->visible_whitespace($markdown) + 'content' => $visible_whitespace($markdown) ]; $text = Text\HTML::toPlaintext($html, 0); $results[] = [ 'title' => DI::l10n()->t('HTML::toPlaintext'), - 'content' => $this->visible_whitespace($text), + 'content' => $visible_whitespace($text), ]; $text = Text\HTML::toPlaintext($html, 0, true); $results[] = [ 'title' => DI::l10n()->t('HTML::toPlaintext (compact)'), - 'content' => $this->visible_whitespace($text), + 'content' => $visible_whitespace($text), ]; break; case 'twitter': @@ -236,7 +241,7 @@ class Babel extends BaseModule $results[] = [ 'title' => DI::l10n()->t('Decoded post'), - 'content' => $this->visible_whitespace(var_export($status, true)), + 'content' => $visible_whitespace(var_export($status, true)), ]; $postarray = []; @@ -255,7 +260,7 @@ class Babel extends BaseModule $results[] = [ 'title' => DI::l10n()->t('Post array before expand entities'), - 'content' => $this->visible_whitespace(var_export($postarray, true)), + 'content' => $visible_whitespace(var_export($postarray, true)), ]; } else { $results[] = [ @@ -285,9 +290,4 @@ class Babel extends BaseModule return $o; } - - private function visible_whitespace($s): string - { - return '
' . htmlspecialchars($s) . '
'; - } } From 2ef9982f63f80c32248f54a84b9b22f269fd9023 Mon Sep 17 00:00:00 2001 From: Art4 Date: Thu, 14 Nov 2024 07:32:25 +0000 Subject: [PATCH 38/38] refactor Receiver::processObject() method --- src/Protocol/ActivityPub/Receiver.php | 34 +++++++++++++-------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 8055ff6666..7512e6179c 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -1880,31 +1880,29 @@ class Receiver $object_data = self::getObjectDataFromActivity($object); - $receiverdata = self::getReceivers($object, $actor ?: $object_data['actor'] ?? '', $object_data['tags'], true, false); - $receivers = $reception_types = []; - foreach ($receiverdata as $key => $data) { - $receivers[$key] = $data['uid']; - $reception_types[$data['uid']] = $data['type'] ?? 0; - } - $object_data['receiver_urls'] = self::getReceiverURL($object); - $object_data['receiver'] = $receivers; - $object_data['reception_type'] = $reception_types; + $object_data['receiver'] = []; + $object_data['reception_type'] = []; $object_data['unlisted'] = false; + $receiverdata = self::getReceivers($object, $actor ?: $object_data['actor'] ?? '', $object_data['tags'], true, false); + + foreach ($receiverdata as $key => $data) { + if ($data['uid'] !== -1) { + $object_data['reception_type'][$data['uid']] = $data['type'] ?? 0; + } + + if ($key !== -1) { + $object_data['receiver'][$key] = $data['uid']; + } else { + $object_data['unlisted'] = true; + } + } + if (!empty($object['pixelfed:capabilities'])) { $object_data['capabilities'] = self::getCapabilities($object); } - if (in_array(-1, $object_data['receiver'])) { - $object_data['unlisted'] = true; - unset($object_data['receiver'][-1]); - - if (array_key_exists(-1, $object_data['reception_type'])) { - unset($object_data['reception_type'][-1]); - } - } - return $object_data; }