Merge branch 'develop' into introduce-phpmd

pull/14622/head
Art4 2025-02-11 07:57:29 +00:00
commit 7d792600b4
209 changed files with 23312 additions and 20751 deletions

View File

@ -19,7 +19,7 @@ cd $DocumentRoot
# copy the .htaccess-dist file to .htaccess so that rewrite rules work # copy the .htaccess-dist file to .htaccess so that rewrite rules work
cp $DocumentRoot/.htaccess-dist $DocumentRoot/.htaccess cp $DocumentRoot/.htaccess-dist $DocumentRoot/.htaccess
bin/composer.phar --no-dev install bin/composer.phar install
# install friendica # install friendica
bin/console autoinstall -f /tmp/autoinstall.config.php bin/console autoinstall -f /tmp/autoinstall.config.php

1
.gitignore vendored
View File

@ -72,7 +72,6 @@ venv/
/.idea /.idea
#ignore addons directory #ignore addons directory
/addons
/addon /addon
#ignore base .htaccess #ignore base .htaccess

View File

@ -1,14 +1,14 @@
#!/bin/bash #!/bin/sh
# SPDX-FileCopyrightText: 2010 - 2024 the Friendica project # SPDX-FileCopyrightText: 2010 - 2024 the Friendica project
# #
# SPDX-License-Identifier: CC0-1.0 # SPDX-License-Identifier: CC0-1.0
dir=$(cd "${0%[/\\]*}" > /dev/null; pwd) dir=$(cd "$(dirname "$0")" > /dev/null 2>&1; pwd)
if [[ -d /proc/cygdrive && $(which php) == $(readlink -n /proc/cygdrive)/* ]]; then if [ -d /proc/cygdrive ] && [ "$(which php)" = "$(readlink -n /proc/cygdrive)/*" ]; then
# We are in Cygwin using Windows php, so the path must be translated # We are in Cygwin using Windows php, so the path must be translated
dir=$(cygpath -m "$dir"); dir=$(cygpath -m "$dir")
fi fi
php "${dir}/console.php" "$@" php "${dir}/console.php" "$@"

View File

@ -24,7 +24,7 @@ chdir(dirname(__DIR__));
require dirname(__DIR__) . '/vendor/autoload.php'; require dirname(__DIR__) . '/vendor/autoload.php';
fwrite(STDOUT, '`bin/daemon.php` is deprecated since 2024.02 and will be removed in 5 months, please use `bin/console.php daemon` instead.' . \PHP_EOL); fwrite(STDOUT, '`bin/daemon.php` is deprecated since 2025.02 and will be removed in 5 months, please use `bin/console.php daemon` instead.' . \PHP_EOL);
// BC: Add console command as second argument // BC: Add console command as second argument
$argv = $_SERVER['argv'] ?? []; $argv = $_SERVER['argv'] ?? [];

View File

@ -19,7 +19,7 @@ chdir(dirname(__DIR__));
require dirname(__DIR__) . '/vendor/autoload.php'; require dirname(__DIR__) . '/vendor/autoload.php';
fwrite(STDOUT, '`bin/jetstream.php` is deprecated since 2024.02 and will be removed in 5 months, please use `bin/console.php jetstream` instead.' . \PHP_EOL); fwrite(STDOUT, '`bin/jetstream.php` is deprecated since 2025.02 and will be removed in 5 months, please use `bin/console.php jetstream` instead.' . \PHP_EOL);
// BC: Add console command as second argument // BC: Add console command as second argument
$argv = $_SERVER['argv'] ?? []; $argv = $_SERVER['argv'] ?? [];

View File

@ -1,13 +1,20 @@
#!/bin/bash #!/bin/sh
# SPDX-FileCopyrightText: 2010 - 2024 the Friendica project # SPDX-FileCopyrightText: 2010 - 2024 the Friendica project
# #
# SPDX-License-Identifier: CC0-1.0 # SPDX-License-Identifier: CC0-1.0
set -eo pipefail set -e
function resolve { # Custom function to handle pipefail behavior
if [ "$(uname)" == "Darwin" ] pipefail() {
local cmd="$1"
shift
{ eval "$cmd"; } || exit 1
}
resolve() {
if [ "$(uname)" = "Darwin" ]
then then
realpath "$1" realpath "$1"
else else
@ -17,7 +24,7 @@ function resolve {
FULLPATH=$(dirname "$(resolve "$0")") FULLPATH=$(dirname "$(resolve "$0")")
if [ "$1" == "--help" ] || [ "$1" == "-h" ] if [ "$1" = "--help" ] || [ "$1" = "-h" ]
then then
echo "$(basename "$(resolve "$0")") [options]" echo "$(basename "$(resolve "$0")") [options]"
echo echo
@ -28,15 +35,15 @@ fi
MODE='default' MODE='default'
ADDONNAME= ADDONNAME=
if [ "$1" == "--addon" ] || [ "$1" == "-a" ] if [ "$1" = "--addon" ] || [ "$1" = "-a" ]
then then
MODE='addon' MODE='addon'
if [ -z "$2" ]; then echo -e "ERROR: missing addon name\n\nrun_xgettext.sh -a <addonname>"; exit 1; fi if [ -z "$2" ]; then echo "ERROR: missing addon name\n\nrun_xgettext.sh -a <addonname>"; exit 1; fi
ADDONNAME=$2 ADDONNAME=$2
if [ ! -d "$FULLPATH/../addon/$ADDONNAME" ]; then echo "ERROR: addon '$ADDONNAME' not found"; exit 2; fi if [ ! -d "$FULLPATH/../addon/$ADDONNAME" ]; then echo "ERROR: addon '$ADDONNAME' not found"; exit 2; fi
fi fi
if [ "$1" == "--single" ] || [ "$1" == "-s" ] if [ "$1" = "--single" ] || [ "$1" = "-s" ]
then then
MODE='single' MODE='single'
fi fi
@ -70,7 +77,6 @@ case "$MODE" in
;; ;;
esac esac
KEYWORDS="-k -kt -ktt:1,2" KEYWORDS="-k -kt -ktt:1,2"
echo "Extract strings to $OUTFILE.." echo "Extract strings to $OUTFILE.."
@ -79,13 +85,13 @@ echo "Extract strings to $OUTFILE.."
# shellcheck disable=SC2086 # $FINDOPTS is meant to be split # shellcheck disable=SC2086 # $FINDOPTS is meant to be split
find_result=$(find "$FINDSTARTDIR" $FINDOPTS -name "*.php" -type f | LC_ALL=C sort -s) find_result=$(find "$FINDSTARTDIR" $FINDOPTS -name "*.php" -type f | LC_ALL=C sort -s)
total_files=$(wc -l <<< "${find_result}") total_files=$(echo "${find_result}" | wc -l)
count=1 count=1
for file in $find_result for file in $find_result
do do
echo -ne " \r" printf " \r"
echo -ne "Reading file $count/$total_files..." printf "Reading file %d/%d..." "$count" "$total_files"
# On Windows, find still outputs the name of pruned folders # On Windows, find still outputs the name of pruned folders
if [ ! -d "$file" ] if [ ! -d "$file" ]
@ -94,9 +100,8 @@ do
xgettext $KEYWORDS --no-wrap -j -o "$OUTFILE" --from-code=UTF-8 "$file" || exit 1 xgettext $KEYWORDS --no-wrap -j -o "$OUTFILE" --from-code=UTF-8 "$file" || exit 1
sed -i.bkp "s/CHARSET/UTF-8/g" "$OUTFILE" sed -i.bkp "s/CHARSET/UTF-8/g" "$OUTFILE"
fi fi
(( count++ )) count=$((count + 1))
done done
echo -ne "\n"
echo "Interpolate metadata.." echo "Interpolate metadata.."
@ -119,7 +124,7 @@ case "$MODE" in
;; ;;
esac esac
if [ "" != "$1" ] && [ "$MODE" == "default" ] if [ -n "$1" ] && [ "$MODE" = "default" ]
then then
UPDATEFILE="$(resolve "${FULLPATH}/$1")" UPDATEFILE="$(resolve "${FULLPATH}/$1")"
echo "Merging new strings to $UPDATEFILE.." echo "Merging new strings to $UPDATEFILE.."

View File

@ -21,7 +21,7 @@ chdir(dirname(__DIR__));
require dirname(__DIR__) . '/vendor/autoload.php'; require dirname(__DIR__) . '/vendor/autoload.php';
fwrite(STDOUT, '`bin/worker.php` is deprecated since 2024.02 and will be removed in 5 months, please use `bin/console.php worker` instead.' . \PHP_EOL); fwrite(STDOUT, '`bin/worker.php` is deprecated since 2025.02 and will be removed in 5 months, please use `bin/console.php worker` instead.' . \PHP_EOL);
// BC: Add console command as second argument // BC: Add console command as second argument
$argv = $_SERVER['argv'] ?? []; $argv = $_SERVER['argv'] ?? [];

View File

@ -70,10 +70,12 @@
"pragmarx/google2fa": "^5.0", "pragmarx/google2fa": "^5.0",
"pragmarx/recovery": "^0.2", "pragmarx/recovery": "^0.2",
"psr/clock": "^1.0", "psr/clock": "^1.0",
"psr/container": "^2.0", "psr/container": "^1.1|^2.0",
"psr/event-dispatcher": "^1.0",
"psr/log": "^1.1", "psr/log": "^1.1",
"seld/cli-prompt": "^1.0", "seld/cli-prompt": "^1.0",
"smarty/smarty": "^4", "smarty/smarty": "^4",
"symfony/event-dispatcher": "^5.4",
"textalk/websocket": "^1.6", "textalk/websocket": "^1.6",
"ua-parser/uap-php": "^3.9", "ua-parser/uap-php": "^3.9",
"xemlock/htmlpurifier-html5": "^0.1.11" "xemlock/htmlpurifier-html5": "^0.1.11"
@ -114,7 +116,6 @@
}, },
"sort-packages": true, "sort-packages": true,
"autoloader-suffix": "Friendica", "autoloader-suffix": "Friendica",
"optimize-autoloader": true,
"preferred-install": "dist", "preferred-install": "dist",
"allow-plugins": { "allow-plugins": {
"composer/installers": true, "composer/installers": true,
@ -174,6 +175,7 @@
"@cs:install", "@cs:install",
"bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer fix" "bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer fix"
], ],
"cs:fix-develop": "TARGET_BRANCH=develop COMMAND=fix bin/dev/fix-codestyle.sh" "cs:fix-develop": "TARGET_BRANCH=develop COMMAND=fix bin/dev/fix-codestyle.sh",
"install:prod": "@composer install -o --no-dev"
} }
} }

562
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "1398ab5832571c32982984ffe9bd810f", "content-hash": "b77bf714197f04022a5feb001bf07852",
"packages": [ "packages": [
{ {
"name": "asika/simple-console", "name": "asika/simple-console",
@ -3139,6 +3139,9 @@
"psr", "psr",
"psr-6" "psr-6"
], ],
"support": {
"source": "https://github.com/php-fig/cache/tree/master"
},
"time": "2016-08-06T20:24:11+00:00" "time": "2016-08-06T20:24:11+00:00"
}, },
{ {
@ -3187,27 +3190,22 @@
}, },
{ {
"name": "psr/container", "name": "psr/container",
"version": "2.0.2", "version": "1.1.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/container.git", "url": "https://github.com/php-fig/container.git",
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" "reference": "513e0666f7216c7459170d56df27dfcefe1689ea"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea",
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", "reference": "513e0666f7216c7459170d56df27dfcefe1689ea",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.4.0" "php": ">=7.4.0"
}, },
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Psr\\Container\\": "src/" "Psr\\Container\\": "src/"
@ -3232,7 +3230,61 @@
"container-interop", "container-interop",
"psr" "psr"
], ],
"time": "2021-11-05T16:47:00+00:00" "support": {
"issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/1.1.2"
},
"time": "2021-11-05T16:50:12+00:00"
},
{
"name": "psr/event-dispatcher",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/event-dispatcher.git",
"reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0",
"reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0",
"shasum": ""
},
"require": {
"php": ">=7.2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\EventDispatcher\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Standard interfaces for event handling.",
"keywords": [
"events",
"psr",
"psr-14"
],
"support": {
"issues": "https://github.com/php-fig/event-dispatcher/issues",
"source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0"
},
"time": "2019-01-08T18:20:26+00:00"
}, },
{ {
"name": "psr/http-client", "name": "psr/http-client",
@ -3430,6 +3482,9 @@
"psr", "psr",
"psr-3" "psr-3"
], ],
"support": {
"source": "https://github.com/php-fig/log/tree/1.1.4"
},
"time": "2021-05-03T11:20:27+00:00" "time": "2021-05-03T11:20:27+00:00"
}, },
{ {
@ -3647,16 +3702,16 @@
}, },
{ {
"name": "symfony/deprecation-contracts", "name": "symfony/deprecation-contracts",
"version": "v2.5.2", "version": "v2.5.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git", "url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918",
"reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3664,12 +3719,12 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": { "branch-alias": {
"dev-main": "2.5-dev" "dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
} }
}, },
"autoload": { "autoload": {
@ -3693,6 +3748,9 @@
], ],
"description": "A generic function and convention to trigger deprecation notices", "description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4"
},
"funding": [ "funding": [
{ {
"url": "https://symfony.com/sponsor", "url": "https://symfony.com/sponsor",
@ -3707,7 +3765,171 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-01-02T09:53:40+00:00" "time": "2024-09-25T14:11:13+00:00"
},
{
"name": "symfony/event-dispatcher",
"version": "v5.4.45",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "72982eb416f61003e9bb6e91f8b3213600dcf9e9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/72982eb416f61003e9bb6e91f8b3213600dcf9e9",
"reference": "72982eb416f61003e9bb6e91f8b3213600dcf9e9",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1|^3",
"symfony/event-dispatcher-contracts": "^2|^3",
"symfony/polyfill-php80": "^1.16"
},
"conflict": {
"symfony/dependency-injection": "<4.4"
},
"provide": {
"psr/event-dispatcher-implementation": "1.0",
"symfony/event-dispatcher-implementation": "2.0"
},
"require-dev": {
"psr/log": "^1|^2|^3",
"symfony/config": "^4.4|^5.0|^6.0",
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
"symfony/error-handler": "^4.4|^5.0|^6.0",
"symfony/expression-language": "^4.4|^5.0|^6.0",
"symfony/http-foundation": "^4.4|^5.0|^6.0",
"symfony/service-contracts": "^1.1|^2|^3",
"symfony/stopwatch": "^4.4|^5.0|^6.0"
},
"suggest": {
"symfony/dependency-injection": "",
"symfony/http-kernel": ""
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\EventDispatcher\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/event-dispatcher/tree/v5.4.45"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-25T14:11:13+00:00"
},
{
"name": "symfony/event-dispatcher-contracts",
"version": "v2.5.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher-contracts.git",
"reference": "e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f",
"reference": "e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"psr/event-dispatcher": "^1"
},
"suggest": {
"symfony/event-dispatcher-implementation": ""
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": {
"dev-main": "2.5-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Contracts\\EventDispatcher\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Generic abstractions related to dispatching event",
"homepage": "https://symfony.com",
"keywords": [
"abstractions",
"contracts",
"decoupling",
"interfaces",
"interoperability",
"standards"
],
"support": {
"source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.4"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-25T14:11:13+00:00"
}, },
{ {
"name": "symfony/polyfill-php56", "name": "symfony/polyfill-php56",
@ -3774,6 +3996,86 @@
], ],
"time": "2020-10-23T14:02:19+00:00" "time": "2020-10-23T14:02:19+00:00"
}, },
{
"name": "symfony/polyfill-php80",
"version": "v1.31.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
"reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php80\\": ""
},
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ion Bazan",
"email": "ion.bazan@gmail.com"
},
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-09T11:45:10+00:00"
},
{ {
"name": "textalk/websocket", "name": "textalk/websocket",
"version": "1.6.3", "version": "1.6.3",
@ -6725,41 +7027,50 @@
}, },
{ {
"name": "symfony/dependency-injection", "name": "symfony/dependency-injection",
"version": "v3.2.14", "version": "v5.4.48",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/dependency-injection.git", "url": "https://github.com/symfony/dependency-injection.git",
"reference": "d9f2e62e1a93d52ad4e4f6faaf66f6eef723d761" "reference": "e5ca16dee39ef7d63e552ff0bf0a2526a1142c92"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/d9f2e62e1a93d52ad4e4f6faaf66f6eef723d761", "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/e5ca16dee39ef7d63e552ff0bf0a2526a1142c92",
"reference": "d9f2e62e1a93d52ad4e4f6faaf66f6eef723d761", "reference": "e5ca16dee39ef7d63e552ff0bf0a2526a1142c92",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.5.9" "php": ">=7.2.5",
"psr/container": "^1.1.1",
"symfony/deprecation-contracts": "^2.1|^3",
"symfony/polyfill-php80": "^1.16",
"symfony/polyfill-php81": "^1.22",
"symfony/service-contracts": "^1.1.6|^2"
}, },
"conflict": { "conflict": {
"symfony/yaml": "<3.2" "ext-psr": "<1.1|>=2",
"symfony/config": "<5.3",
"symfony/finder": "<4.4",
"symfony/proxy-manager-bridge": "<4.4",
"symfony/yaml": "<4.4.26"
},
"provide": {
"psr/container-implementation": "1.0",
"symfony/service-implementation": "1.0|2.0"
}, },
"require-dev": { "require-dev": {
"symfony/config": "~2.8|~3.0", "symfony/config": "^5.3|^6.0",
"symfony/expression-language": "~2.8|~3.0", "symfony/expression-language": "^4.4|^5.0|^6.0",
"symfony/yaml": "~3.2" "symfony/yaml": "^4.4.26|^5.0|^6.0"
}, },
"suggest": { "suggest": {
"symfony/config": "", "symfony/config": "",
"symfony/expression-language": "For using expressions in service container configuration", "symfony/expression-language": "For using expressions in service container configuration",
"symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required",
"symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them",
"symfony/yaml": "" "symfony/yaml": ""
}, },
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2-dev"
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Symfony\\Component\\DependencyInjection\\": "" "Symfony\\Component\\DependencyInjection\\": ""
@ -6782,12 +7093,26 @@
"homepage": "https://symfony.com/contributors" "homepage": "https://symfony.com/contributors"
} }
], ],
"description": "Symfony DependencyInjection Component", "description": "Allows you to standardize and centralize the way objects are constructed in your application",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/dependency-injection/tree/3.2" "source": "https://github.com/symfony/dependency-injection/tree/v5.4.48"
}, },
"time": "2017-07-28T15:22:55+00:00" "funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-11-20T10:51:57+00:00"
}, },
{ {
"name": "symfony/filesystem", "name": "symfony/filesystem",
@ -7015,86 +7340,6 @@
], ],
"time": "2024-09-09T11:45:10+00:00" "time": "2024-09-09T11:45:10+00:00"
}, },
{
"name": "symfony/polyfill-php80",
"version": "v1.31.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
"reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php80\\": ""
},
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ion Bazan",
"email": "ion.bazan@gmail.com"
},
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-09T11:45:10+00:00"
},
{ {
"name": "symfony/polyfill-php81", "name": "symfony/polyfill-php81",
"version": "v1.31.0", "version": "v1.31.0",
@ -7171,6 +7416,89 @@
], ],
"time": "2024-09-09T11:45:10+00:00" "time": "2024-09-09T11:45:10+00:00"
}, },
{
"name": "symfony/service-contracts",
"version": "v2.5.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
"reference": "f37b419f7aea2e9abf10abd261832cace12e3300"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/f37b419f7aea2e9abf10abd261832cace12e3300",
"reference": "f37b419f7aea2e9abf10abd261832cace12e3300",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"psr/container": "^1.1",
"symfony/deprecation-contracts": "^2.1|^3"
},
"conflict": {
"ext-psr": "<1.1|>=2"
},
"suggest": {
"symfony/service-implementation": ""
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": {
"dev-main": "2.5-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Contracts\\Service\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Generic abstractions related to writing services",
"homepage": "https://symfony.com",
"keywords": [
"abstractions",
"contracts",
"decoupling",
"interfaces",
"interoperability",
"standards"
],
"support": {
"source": "https://github.com/symfony/service-contracts/tree/v2.5.4"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-25T14:11:13+00:00"
},
{ {
"name": "theseer/tokenizer", "name": "theseer/tokenizer",
"version": "1.2.3", "version": "1.2.3",

View File

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 2025.02-dev (Interrupted Fern) -- Friendica 2025.02-dev (Interrupted Fern)
-- DB_UPDATE_VERSION 1576 -- DB_UPDATE_VERSION 1577
-- ------------------------------------------ -- ------------------------------------------
@ -1609,7 +1609,7 @@ CREATE TABLE IF NOT EXISTS `post-user` (
`psid` int unsigned COMMENT 'ID of the permission set of this post', `psid` int unsigned COMMENT 'ID of the permission set of this post',
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`), UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
INDEX `uri-id` (`uri-id`), INDEX `uri-id_origin_deleted` (`uri-id`,`origin`,`deleted`),
INDEX `parent-uri-id` (`parent-uri-id`), INDEX `parent-uri-id` (`parent-uri-id`),
INDEX `thr-parent-id` (`thr-parent-id`), INDEX `thr-parent-id` (`thr-parent-id`),
INDEX `external-id` (`external-id`), INDEX `external-id` (`external-id`),
@ -3809,7 +3809,8 @@ CREATE VIEW `pending-view` AS SELECT
`contact`.`nick` AS `nick` `contact`.`nick` AS `nick`
FROM `register` FROM `register`
INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid` INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
INNER JOIN `user` ON `register`.`uid` = `user`.`uid`; INNER JOIN `user` ON `register`.`uid` = `user`.`uid`
WHERE `register`.`uid` != 0;
-- --
-- VIEW tag-search-view -- VIEW tag-search-view

View File

@ -62,7 +62,7 @@ If you want to have git automatically update the dependencies with composer, you
} }
# `composer install` if the `composer.lock` file gets changed # `composer install` if the `composer.lock` file gets changed
# to update all the php dependencies # to update all the php dependencies
check_run composer.lock "bin/composer.phar install --no-dev" check_run composer.lock "bin/composer.phar install"
just place it into `.git/hooks/post-merge` and make it executable. just place it into `.git/hooks/post-merge` and make it executable.
@ -210,9 +210,9 @@ If the deprecated code is no longer used inside Friendica or the official addons
The code MUST NOT be deleted. The code MUST NOT be deleted.
Starting from the next release, it MUST be stay for at least 5 months. Starting from the next release, it MUST be stay for at least 5 months.
Hard deprecated code COULD remain longer than 5 months, depending on when a release appears. Hard deprecated code COULD remain longer than 5 months, depending on when a release appears.
Addon developer MUST NOT consider that they have more than 5 months to adjust their code. Addon developer SHOULD NOT consider that they have more than 5 months to adjust their code.
Hard deprecation code means that the code triggers an `E_USER_DEPRECATION` error if it is called. Hard deprecation code means that the code triggers a muted `E_USER_DEPRECATION` error if it is called.
For instance with the deprecated class `Friendica\Core\Logger` the call of every method should trigger an error: For instance with the deprecated class `Friendica\Core\Logger` the call of every method should trigger an error:
```php ```php
@ -224,7 +224,7 @@ For instance with the deprecated class `Friendica\Core\Logger` the call of every
class Logger { class Logger {
public static function info(string $message, array $context = []) public static function info(string $message, array $context = [])
{ {
trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.05 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED); @trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.05 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
self::getInstance()->info($message, $context); self::getInstance()->info($message, $context);
} }
@ -233,7 +233,7 @@ class Logger {
} }
``` ```
This way the maintainer or users of addons will be notified that the addon will stop working in one of the next releases. This way the maintainer or users of addons will be notified in the logs that the addon will stop working in one of the next releases.
The addon maintainer now has at least 5 months or at least one release to fix the deprecations. The addon maintainer now has at least 5 months or at least one release to fix the deprecations.
Please note that the deprecation message contains the release that will be released next. Please note that the deprecation message contains the release that will be released next.

View File

@ -76,14 +76,6 @@ This makes the software much easier to update.
The Linux commands to clone the repository into a directory "mywebsite" would be The Linux commands to clone the repository into a directory "mywebsite" would be
git clone https://github.com/friendica/friendica.git -b stable mywebsite git clone https://github.com/friendica/friendica.git -b stable mywebsite
cd mywebsite
bin/composer.phar install --no-dev
Make sure the folder *view/smarty3* exists and is writable by the webserver user, in this case *www-data*
mkdir -p view/smarty3
chown www-data:www-data view/smarty3
chmod 775 view/smarty3
Get the addons by going into your website folder. Get the addons by going into your website folder.
@ -93,10 +85,20 @@ Clone the addon repository (separately):
git clone https://github.com/friendica/friendica-addons.git -b stable addon git clone https://github.com/friendica/friendica-addons.git -b stable addon
Install the dependencies:
bin/composer.phar run install:prod
Make sure the folder *view/smarty3* exists and is writable by the webserver user, in this case *www-data*
mkdir -p view/smarty3
chown www-data:www-data view/smarty3
chmod 775 view/smarty3
If you want to use the development version of Friendica you can switch to the develop branch in the repository by running If you want to use the development version of Friendica you can switch to the develop branch in the repository by running
git checkout develop git checkout develop
bin/composer.phar install bin/composer.phar run install:prod
cd addon cd addon
git checkout develop git checkout develop

View File

@ -30,7 +30,7 @@ You can get the latest changes at any time with
cd path/to/friendica cd path/to/friendica
git pull git pull
bin/composer.phar install --no-dev bin/composer.phar run install:prod
The addon tree has to be updated separately like so: The addon tree has to be updated separately like so:

View File

@ -18,7 +18,7 @@ What you need to do:
Please use an up-to-date vagrant version from https://www.vagrantup.com/downloads.html. Please use an up-to-date vagrant version from https://www.vagrantup.com/downloads.html.
2. Git clone your Friendica repository. 2. Git clone your Friendica repository.
Inside, you'll find a `Vagrantfile` and some scripts in the `bin/dev` folder. Inside, you'll find a `Vagrantfile` and some scripts in the `bin/dev` folder.
Pull the PHP requirements with `bin/composer install`. Pull the PHP requirements with `bin/composer.phar install`.
3. Run `vagrant up` from inside the friendica clone. 3. Run `vagrant up` from inside the friendica clone.
This will start the virtual machine. This will start the virtual machine.
Be patient: When it runs for the first time, it downloads a Debian Server image and installs Friendica. Be patient: When it runs for the first time, it downloads a Debian Server image and installs Friendica.

View File

@ -45,10 +45,10 @@ Indexes
------------ ------------
| Name | Fields | | Name | Fields |
| -------------------- | ----------------------- | |-----------------------| ----------------------- |
| PRIMARY | id | | PRIMARY | id |
| uid_uri-id | UNIQUE, uid, uri-id | | uid_uri-id | UNIQUE, uid, uri-id |
| uri-id | uri-id | | uri-id_origin_deleted | uri-id, origin, deleted |
| parent-uri-id | parent-uri-id | | parent-uri-id | parent-uri-id |
| thr-parent-id | thr-parent-id | | thr-parent-id | thr-parent-id |
| external-id | external-id | | external-id | external-id |

View File

@ -59,7 +59,7 @@ Der Linux-Code, mit dem man die Dateien direkt in ein Verzeichnis wie "meinewebs
git clone https://github.com/friendica/friendica.git -b stable mywebsite git clone https://github.com/friendica/friendica.git -b stable mywebsite
cd mywebsite cd mywebsite
bin/composer.phar install bin/composer.phar run install:prod
Stelle sicher, dass der Ordner *view/smarty3* existiert and von dem Webserver-Benutzer beschreibbar ist Stelle sicher, dass der Ordner *view/smarty3* existiert and von dem Webserver-Benutzer beschreibbar ist
@ -85,7 +85,7 @@ Wenn du die Entwickler Version von Friendica verwenden möchtest kannst du auf d
Dies tust du mit den folgenden Befehlen Dies tust du mit den folgenden Befehlen
git checkout develop git checkout develop
bin/composer.phar install bin/composer.phar run install:prod
cd addon cd addon
git checkout develop git checkout develop

View File

@ -8,7 +8,7 @@
$start_time = microtime(true); $start_time = microtime(true);
if (!file_exists(__DIR__ . '/vendor/autoload.php')) { if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
die('Vendor path not found. Please execute "bin/composer.phar --no-dev install" on the command line in the web root.'); die('Vendor path not found. Please execute "bin/composer.phar run install:prod" on the command line in the web root.');
} }
require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/vendor/autoload.php';

View File

@ -11,7 +11,6 @@ use Friendica\Content\Nav;
use Friendica\Content\Pager; use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Core\ACL; use Friendica\Core\ACL;
use Friendica\Core\Addon;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\System; use Friendica\Core\System;
@ -1067,6 +1066,7 @@ function photos_content()
$cmnt_tpl = Renderer::getMarkupTemplate('comment_item.tpl'); $cmnt_tpl = Renderer::getMarkupTemplate('comment_item.tpl');
$tpl = Renderer::getMarkupTemplate('photo_item.tpl'); $tpl = Renderer::getMarkupTemplate('photo_item.tpl');
$return_path = DI::args()->getCommand(); $return_path = DI::args()->getCommand();
$addonHelper = DI::addonHelper();
if (!DBA::isResult($items)) { if (!DBA::isResult($items)) {
if (($can_post || Security::canWriteToUserWall($owner_uid))) { if (($can_post || Security::canWriteToUserWall($owner_uid))) {
@ -1075,7 +1075,7 @@ function photos_content()
* This should be better if done by a hook * This should be better if done by a hook
*/ */
$qcomment = null; $qcomment = null;
if (Addon::isEnabled('qcomment')) { if ($addonHelper->isAddonEnabled('qcomment')) {
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words'); $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : []; $qcomment = $words ? explode("\n", $words) : [];
} }
@ -1131,7 +1131,7 @@ function photos_content()
* This should be better if done by a hook * This should be better if done by a hook
*/ */
$qcomment = null; $qcomment = null;
if (Addon::isEnabled('qcomment')) { if ($addonHelper->isAddonEnabled('qcomment')) {
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words'); $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : []; $qcomment = $words ? explode("\n", $words) : [];
} }
@ -1211,7 +1211,7 @@ function photos_content()
* This should be better if done by a hook * This should be better if done by a hook
*/ */
$qcomment = null; $qcomment = null;
if (Addon::isEnabled('qcomment')) { if ($addonHelper->isAddonEnabled('qcomment')) {
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words'); $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : []; $qcomment = $words ? explode("\n", $words) : [];
} }

View File

@ -17,16 +17,14 @@ use Friendica\App\Router;
use Friendica\Capabilities\ICanCreateResponses; use Friendica\Capabilities\ICanCreateResponses;
use Friendica\Capabilities\ICanHandleRequests; use Friendica\Capabilities\ICanHandleRequests;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Core\Addon\AddonHelper;
use Friendica\Core\Addon\Capability\ICanLoadAddons; use Friendica\Core\Addon\Capability\ICanLoadAddons;
use Friendica\Core\Config\Factory\Config; use Friendica\Core\Config\Factory\Config;
use Friendica\Core\Container; use Friendica\Core\Container;
use Friendica\Core\Hooks\HookEventBridge;
use Friendica\Core\Logger\LoggerManager; use Friendica\Core\Logger\LoggerManager;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleUserSessions; use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Database\Definition\DbaDefinition;
use Friendica\Database\Definition\ViewDefinition;
use Friendica\Module\Maintenance;
use Friendica\Security\Authentication;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\DiceContainer; use Friendica\Core\DiceContainer;
use Friendica\Core\L10n; use Friendica\Core\L10n;
@ -35,9 +33,15 @@ use Friendica\Core\Logger\Handler\ErrorHandler;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Update; use Friendica\Core\Update;
use Friendica\Database\Definition\DbaDefinition;
use Friendica\Database\Definition\ViewDefinition;
use Friendica\Event\ConfigLoadedEvent;
use Friendica\Event\Event;
use Friendica\Module\Maintenance;
use Friendica\Module\Special\HTTPException as ModuleHTTPException; use Friendica\Module\Special\HTTPException as ModuleHTTPException;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Protocol\ATProtocol\DID; use Friendica\Protocol\ATProtocol\DID;
use Friendica\Security\Authentication;
use Friendica\Security\ExAuth; use Friendica\Security\ExAuth;
use Friendica\Security\OpenWebAuth; use Friendica\Security\OpenWebAuth;
use Friendica\Util\BasePath; use Friendica\Util\BasePath;
@ -45,6 +49,7 @@ use Friendica\Util\DateTimeFormat;
use Friendica\Util\HTTPInputData; use Friendica\Util\HTTPInputData;
use Friendica\Util\HTTPSignature; use Friendica\Util\HTTPSignature;
use Friendica\Util\Profiler; use Friendica\Util\Profiler;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@ -153,6 +158,8 @@ class App
$this->registerErrorHandler(); $this->registerErrorHandler();
$this->registerEventDispatcher();
$this->requestId = $this->container->create(Request::class)->getRequestId(); $this->requestId = $this->container->create(Request::class)->getRequestId();
$this->auth = $this->container->create(Authentication::class); $this->auth = $this->container->create(Authentication::class);
$this->config = $this->container->create(IManageConfigValues::class); $this->config = $this->container->create(IManageConfigValues::class);
@ -165,6 +172,8 @@ class App
$this->session = $this->container->create(IHandleUserSessions::class); $this->session = $this->container->create(IHandleUserSessions::class);
$this->appHelper = $this->container->create(AppHelper::class); $this->appHelper = $this->container->create(AppHelper::class);
$addonHelper = $this->container->create(AddonHelper::class);
$this->load( $this->load(
$request->getServerParams(), $request->getServerParams(),
$this->container->create(DbaDefinition::class), $this->container->create(DbaDefinition::class),
@ -172,15 +181,19 @@ class App
$this->mode, $this->mode,
$this->config, $this->config,
$this->profiler, $this->profiler,
$this->container->create(EventDispatcherInterface::class),
$this->appHelper, $this->appHelper,
$addonHelper,
); );
$this->registerTemplateEngine(); $this->registerTemplateEngine();
$this->runFrontend( $this->runFrontend(
$this->container->create(EventDispatcherInterface::class),
$this->container->create(IManagePersonalConfigValues::class), $this->container->create(IManagePersonalConfigValues::class),
$this->container->create(Page::class), $this->container->create(Page::class),
$this->container->create(Nav::class), $this->container->create(Nav::class),
$addonHelper,
$this->container->create(ModuleHTTPException::class), $this->container->create(ModuleHTTPException::class),
$start_time, $start_time,
$request $request
@ -202,6 +215,8 @@ class App
$this->registerErrorHandler(); $this->registerErrorHandler();
$this->registerEventDispatcher();
$this->load( $this->load(
$serverParams, $serverParams,
$this->container->create(DbaDefinition::class), $this->container->create(DbaDefinition::class),
@ -209,7 +224,9 @@ class App
$this->container->create(Mode::class), $this->container->create(Mode::class),
$this->container->create(IManageConfigValues::class), $this->container->create(IManageConfigValues::class),
$this->container->create(Profiler::class), $this->container->create(Profiler::class),
$this->container->create(EventDispatcherInterface::class),
$this->container->create(AppHelper::class), $this->container->create(AppHelper::class),
$this->container->create(AddonHelper::class),
); );
$this->registerTemplateEngine(); $this->registerTemplateEngine();
@ -230,6 +247,8 @@ class App
$this->registerErrorHandler(); $this->registerErrorHandler();
$this->registerEventDispatcher();
$this->load( $this->load(
$serverParams, $serverParams,
$this->container->create(DbaDefinition::class), $this->container->create(DbaDefinition::class),
@ -237,7 +256,9 @@ class App
$this->container->create(Mode::class), $this->container->create(Mode::class),
$this->container->create(IManageConfigValues::class), $this->container->create(IManageConfigValues::class),
$this->container->create(Profiler::class), $this->container->create(Profiler::class),
$this->container->create(EventDispatcherInterface::class),
$this->container->create(AppHelper::class), $this->container->create(AppHelper::class),
$this->container->create(AddonHelper::class),
); );
/** @var BasePath */ /** @var BasePath */
@ -301,6 +322,16 @@ class App
ErrorHandler::register($this->container->create(LoggerInterface::class)); ErrorHandler::register($this->container->create(LoggerInterface::class));
} }
private function registerEventDispatcher(): void
{
/** @var \Friendica\Event\EventDispatcher */
$eventDispatcher = $this->container->create(EventDispatcherInterface::class);
foreach (HookEventBridge::getStaticSubscribedEvents() as $eventName => $methodName) {
$eventDispatcher->addListener($eventName, [HookEventBridge::class, $methodName]);
}
}
private function registerTemplateEngine(): void private function registerTemplateEngine(): void
{ {
Renderer::registerTemplateEngine('Friendica\Render\FriendicaSmartyEngine'); Renderer::registerTemplateEngine('Friendica\Render\FriendicaSmartyEngine');
@ -316,7 +347,9 @@ class App
Mode $mode, Mode $mode,
IManageConfigValues $config, IManageConfigValues $config,
Profiler $profiler, Profiler $profiler,
AppHelper $appHelper EventDispatcherInterface $eventDispatcher,
AppHelper $appHelper,
AddonHelper $addonHelper
): void { ): void {
if ($config->get('system', 'ini_max_execution_time') !== false) { if ($config->get('system', 'ini_max_execution_time') !== false) {
set_time_limit((int) $config->get('system', 'ini_max_execution_time')); set_time_limit((int) $config->get('system', 'ini_max_execution_time'));
@ -338,8 +371,9 @@ class App
if ($mode->has(Mode::DBAVAILABLE)) { if ($mode->has(Mode::DBAVAILABLE)) {
Core\Hook::loadHooks(); Core\Hook::loadHooks();
$loader = (new Config())->createConfigFileManager($appHelper->getBasePath(), $serverParams); $loader = (new Config())->createConfigFileManager($appHelper->getBasePath(), $addonHelper->getAddonPath(), $serverParams);
Core\Hook::callAll('load_config', $loader);
$eventDispatcher->dispatch(new ConfigLoadedEvent(ConfigLoadedEvent::CONFIG_LOADED, $loader));
// Hooks are now working, reload the whole definitions with hook enabled // Hooks are now working, reload the whole definitions with hook enabled
$dbaDefinition->load(true); $dbaDefinition->load(true);
@ -385,9 +419,11 @@ class App
* @throws \ImagickException * @throws \ImagickException
*/ */
private function runFrontend( private function runFrontend(
EventDispatcherInterface $eventDispatcher,
IManagePersonalConfigValues $pconfig, IManagePersonalConfigValues $pconfig,
Page $page, Page $page,
Nav $nav, Nav $nav,
AddonHelper $addonHelper,
ModuleHTTPException $httpException, ModuleHTTPException $httpException,
float $start_time, float $start_time,
ServerRequestInterface $request ServerRequestInterface $request
@ -424,7 +460,8 @@ class App
$serverVars['REQUEST_METHOD'] === 'GET') { $serverVars['REQUEST_METHOD'] === 'GET') {
System::externalRedirect($this->baseURL . '/' . $this->args->getQueryString()); System::externalRedirect($this->baseURL . '/' . $this->args->getQueryString());
} }
Core\Hook::callAll('init_1');
$eventDispatcher->dispatch(new Event(Event::INIT));
} }
DID::routeRequest($this->args->getCommand(), $serverVars); DID::routeRequest($this->args->getCommand(), $serverVars);
@ -475,12 +512,12 @@ class App
// but we need "view" module for stylesheet // but we need "view" module for stylesheet
if ($this->mode->isInstall() && $moduleName !== 'install') { if ($this->mode->isInstall() && $moduleName !== 'install') {
$this->baseURL->redirect('install'); $this->baseURL->redirect('install');
} else {
Core\Update::check($this->appHelper->getBasePath(), false);
Core\Addon::loadAddons();
Core\Hook::loadHooks();
} }
Core\Update::check($this->appHelper->getBasePath(), false);
$addonHelper->loadAddons();
Core\Hook::loadHooks();
// Compatibility with Hubzilla // Compatibility with Hubzilla
if ($moduleName == 'rpost') { if ($moduleName == 'rpost') {
$this->baseURL->redirect('compose'); $this->baseURL->redirect('compose');

View File

@ -14,7 +14,6 @@ use Friendica\App;
use Friendica\AppHelper; use Friendica\AppHelper;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
@ -22,12 +21,14 @@ use Friendica\Core\Session\Model\UserSession;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Theme; use Friendica\Core\Theme;
use Friendica\DI; use Friendica\DI;
use Friendica\Event\HtmlFilterEvent;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Util\Images; use Friendica\Util\Images;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Profiler; use Friendica\Util\Profiler;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use GuzzleHttp\Psr7\Utils; use GuzzleHttp\Psr7\Utils;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
/** /**
@ -70,6 +71,8 @@ class Page implements ArrayAccess
*/ */
private $basePath; private $basePath;
private EventDispatcherInterface $eventDispatcher;
private $timestamp = 0; private $timestamp = 0;
private $method = ''; private $method = '';
private $module = ''; private $module = '';
@ -78,10 +81,11 @@ class Page implements ArrayAccess
/** /**
* @param string $basepath The Page basepath * @param string $basepath The Page basepath
*/ */
public function __construct(string $basepath) public function __construct(string $basepath, EventDispatcherInterface $eventDispatcher)
{ {
$this->timestamp = microtime(true); $this->timestamp = microtime(true);
$this->basePath = $basepath; $this->basePath = $basepath;
$this->eventDispatcher = $eventDispatcher;
} }
public function setLogging(string $method, string $module, string $command) public function setLogging(string $method, string $module, string $command)
@ -192,17 +196,6 @@ class Page implements ArrayAccess
IManagePersonalConfigValues $pConfig, IManagePersonalConfigValues $pConfig,
int $localUID int $localUID
) { ) {
$interval = ($localUID ? $pConfig->get($localUID, 'system', 'update_interval') : 40000);
// If the update is 'deactivated' set it to the highest integer number (~24 days)
if ($interval < 0) {
$interval = 2147483647;
}
if ($interval < 10000) {
$interval = 40000;
}
// Default title: current module called // Default title: current module called
if (empty($this->page['title']) && $args->getModuleName()) { if (empty($this->page['title']) && $args->getModuleName()) {
$this->page['title'] = ucfirst($args->getModuleName()); $this->page['title'] = ucfirst($args->getModuleName());
@ -229,7 +222,9 @@ class Page implements ArrayAccess
$touch_icon = 'images/friendica-192.png'; $touch_icon = 'images/friendica-192.png';
} }
Hook::callAll('head', $this->page['htmlhead']); $this->page['htmlhead'] = $this->eventDispatcher->dispatch(
new HtmlFilterEvent(HtmlFilterEvent::HEAD, $this->page['htmlhead'])
)->getHtml();
$tpl = Renderer::getMarkupTemplate('head.tpl'); $tpl = Renderer::getMarkupTemplate('head.tpl');
/* put the head template at the beginning of page['htmlhead'] /* put the head template at the beginning of page['htmlhead']
@ -268,7 +263,7 @@ class Page implements ArrayAccess
'$local_user' => $localUID, '$local_user' => $localUID,
'$generator' => 'Friendica' . ' ' . App::VERSION, '$generator' => 'Friendica' . ' ' . App::VERSION,
'$update_interval' => $interval, '$update_content' => (int)$pConfig->get($localUID, 'system', 'update_content'),
'$shortcut_icon' => $shortcut_icon, '$shortcut_icon' => $shortcut_icon,
'$touch_icon' => $touch_icon, '$touch_icon' => $touch_icon,
'$block_public' => intval($config->get('system', 'block_public')), '$block_public' => intval($config->get('system', 'block_public')),
@ -351,11 +346,14 @@ class Page implements ArrayAccess
]); ]);
} }
Hook::callAll('footer', $this->page['footer']); $this->page['footer'] = $this->eventDispatcher->dispatch(
new HtmlFilterEvent(HtmlFilterEvent::FOOTER, $this->page['footer'])
)->getHtml();
$tpl = Renderer::getMarkupTemplate('footer.tpl'); $tpl = Renderer::getMarkupTemplate('footer.tpl');
$this->page['footer'] = Renderer::replaceMacros($tpl, [ $this->page['footer'] = Renderer::replaceMacros($tpl, [
'$footerScripts' => array_unique($this->footerScripts), '$footerScripts' => array_unique($this->footerScripts),
'$close' => $l10n->t('Close'),
]) . $this->page['footer']; ]) . $this->page['footer'];
} }
@ -375,7 +373,9 @@ class Page implements ArrayAccess
{ {
// initialise content region // initialise content region
if ($mode->isNormal()) { if ($mode->isNormal()) {
Hook::callAll('page_content_top', $this->page['content']); $this->page['content'] = $this->eventDispatcher->dispatch(
new HtmlFilterEvent(HtmlFilterEvent::PAGE_CONTENT_TOP, $this->page['content'])
)->getHtml();
} }
$this->page['content'] .= (string)$response->getBody(); $this->page['content'] .= (string)$response->getBody();
@ -473,7 +473,9 @@ class Page implements ArrayAccess
$profiler->set(microtime(true) - $timestamp, 'aftermath'); $profiler->set(microtime(true) - $timestamp, 'aftermath');
if (!$mode->isAjax()) { if (!$mode->isAjax()) {
Hook::callAll('page_end', $this->page['content']); $this->page['content'] = $this->eventDispatcher->dispatch(
new HtmlFilterEvent(HtmlFilterEvent::PAGE_END, $this->page['content'])
)->getHtml();
} }
// Add the navigation (menu) template // Add the navigation (menu) template

View File

@ -7,13 +7,11 @@
namespace Friendica\App; namespace Friendica\App;
use Dice\Dice;
use FastRoute\DataGenerator\GroupCountBased; use FastRoute\DataGenerator\GroupCountBased;
use FastRoute\Dispatcher; use FastRoute\Dispatcher;
use FastRoute\RouteCollector; use FastRoute\RouteCollector;
use FastRoute\RouteParser\Std; use FastRoute\RouteParser\Std;
use Friendica\Capabilities\ICanHandleRequests; use Friendica\Core\Addon\AddonHelper;
use Friendica\Core\Addon;
use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Cache\Capability\ICanCache; use Friendica\Core\Cache\Capability\ICanCache;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
@ -86,6 +84,8 @@ class Router
/** @var LoggerInterface */ /** @var LoggerInterface */
private $logger; private $logger;
private AddonHelper $addonHelper;
/** @var bool */ /** @var bool */
private $isLocalUser; private $isLocalUser;
@ -110,7 +110,7 @@ class Router
* @param IHandleUserSessions $userSession * @param IHandleUserSessions $userSession
* @param RouteCollector|null $routeCollector * @param RouteCollector|null $routeCollector
*/ */
public function __construct(array $server, string $baseRoutesFilepath, L10n $l10n, ICanCache $cache, ICanLock $lock, IManageConfigValues $config, Arguments $args, LoggerInterface $logger, IHandleUserSessions $userSession, RouteCollector $routeCollector = null) public function __construct(array $server, string $baseRoutesFilepath, L10n $l10n, ICanCache $cache, ICanLock $lock, IManageConfigValues $config, Arguments $args, LoggerInterface $logger, AddonHelper $addonHelper, IHandleUserSessions $userSession, RouteCollector $routeCollector = null)
{ {
$this->baseRoutesFilepath = $baseRoutesFilepath; $this->baseRoutesFilepath = $baseRoutesFilepath;
$this->l10n = $l10n; $this->l10n = $l10n;
@ -120,6 +120,7 @@ class Router
$this->config = $config; $this->config = $config;
$this->server = $server; $this->server = $server;
$this->logger = $logger; $this->logger = $logger;
$this->addonHelper = $addonHelper;
$this->isLocalUser = !empty($userSession->getLocalUserId()); $this->isLocalUser = !empty($userSession->getLocalUserId());
$this->routeCollector = $routeCollector ?? new RouteCollector(new Std(), new GroupCountBased()); $this->routeCollector = $routeCollector ?? new RouteCollector(new Std(), new GroupCountBased());
@ -282,7 +283,7 @@ class Router
if ($routeInfo[0] === Dispatcher::FOUND) { if ($routeInfo[0] === Dispatcher::FOUND) {
$this->moduleClass = $routeInfo[1]; $this->moduleClass = $routeInfo[1];
$this->parameters[] = $routeInfo[2]; $this->parameters[] = $routeInfo[2];
} else if ($routeInfo[0] === Dispatcher::METHOD_NOT_ALLOWED) { } elseif ($routeInfo[0] === Dispatcher::METHOD_NOT_ALLOWED) {
throw new HTTPException\MethodNotAllowedException($this->l10n->t('Method not allowed for this module. Allowed method(s): %s', implode(', ', $routeInfo[1]))); throw new HTTPException\MethodNotAllowedException($this->l10n->t('Method not allowed for this module. Allowed method(s): %s', implode(', ', $routeInfo[1])));
} else { } else {
throw new HTTPException\NotFoundException($this->l10n->t('Page not found.')); throw new HTTPException\NotFoundException($this->l10n->t('Page not found.'));
@ -293,7 +294,7 @@ class Router
} catch (NotFoundException $e) { } catch (NotFoundException $e) {
$moduleName = $this->args->getModuleName(); $moduleName = $this->args->getModuleName();
// Then we try addon-provided modules that we wrap in the LegacyModule class // Then we try addon-provided modules that we wrap in the LegacyModule class
if (Addon::isEnabled($moduleName) && file_exists("addon/{$moduleName}/{$moduleName}.php")) { if ($this->addonHelper->isAddonEnabled($moduleName) && file_exists("addon/{$moduleName}/{$moduleName}.php")) {
//Check if module is an app and if public access to apps is allowed or not //Check if module is an app and if public access to apps is allowed or not
$privateapps = $this->config->get('config', 'private_addons', false); $privateapps = $this->config->get('config', 'private_addons', false);
if (!$this->isLocalUser && Hook::isAddonApp($moduleName) && $privateapps) { if (!$this->isLocalUser && Hook::isAddonApp($moduleName) && $privateapps) {

View File

@ -10,7 +10,7 @@ namespace Friendica\Console;
use Console_Table; use Console_Table;
use Friendica\App\Mode; use Friendica\App\Mode;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Addon as AddonCore; use Friendica\Core\Addon\AddonHelper;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use RuntimeException; use RuntimeException;
@ -34,6 +34,7 @@ class Addon extends \Asika\SimpleConsole\Console
* @var Database * @var Database
*/ */
private $dba; private $dba;
private AddonHelper $addonHelper;
protected function getHelp() protected function getHelp()
{ {
@ -56,15 +57,16 @@ HELP;
return $help; return $help;
} }
public function __construct(Mode $appMode, L10n $l10n, Database $dba, array $argv = null) public function __construct(Mode $appMode, L10n $l10n, Database $dba, AddonHelper $addonHelper, array $argv = null)
{ {
parent::__construct($argv); parent::__construct($argv);
$this->appMode = $appMode; $this->appMode = $appMode;
$this->l10n = $l10n; $this->l10n = $l10n;
$this->dba = $dba; $this->dba = $dba;
$this->addonHelper = $addonHelper;
AddonCore::loadAddons(); $this->addonHelper->loadAddons();
} }
protected function doExecute(): int protected function doExecute(): int
@ -122,23 +124,22 @@ HELP;
return false; return false;
} }
foreach (AddonCore::getAvailableList() as $addon) { foreach ($this->addonHelper->getAvailableAddons() as $addonId) {
$addon_name = $addon[0]; $enabled = $this->addonHelper->isAddonEnabled($addonId);
$enabled = AddonCore::isEnabled($addon_name);
if ($subCmd === 'all') { if ($subCmd === 'all') {
$table->addRow([$addon_name, $enabled ? 'enabled' : 'disabled']); $table->addRow([$addonId, $enabled ? 'enabled' : 'disabled']);
continue; continue;
} }
if ($subCmd === 'enabled' && $enabled === true) { if ($subCmd === 'enabled' && $enabled === true) {
$table->addRow([$addon_name]); $table->addRow([$addonId]);
continue; continue;
} }
if ($subCmd === 'disabled' && $enabled === false) { if ($subCmd === 'disabled' && $enabled === false) {
$table->addRow([$addon_name]); $table->addRow([$addonId]);
continue; continue;
} }
} }
@ -163,11 +164,11 @@ HELP;
throw new RuntimeException($this->l10n->t('Addon not found')); throw new RuntimeException($this->l10n->t('Addon not found'));
} }
if (AddonCore::isEnabled($addon)) { if ($this->addonHelper->isAddonEnabled($addon)) {
throw new RuntimeException($this->l10n->t('Addon already enabled')); throw new RuntimeException($this->l10n->t('Addon already enabled'));
} }
AddonCore::install($addon); $this->addonHelper->installAddon($addon);
return 0; return 0;
} }
@ -187,11 +188,11 @@ HELP;
throw new RuntimeException($this->l10n->t('Addon not found')); throw new RuntimeException($this->l10n->t('Addon not found'));
} }
if (!AddonCore::isEnabled($addon)) { if (!$this->addonHelper->isAddonEnabled($addon)) {
throw new RuntimeException($this->l10n->t('Addon already disabled')); throw new RuntimeException($this->l10n->t('Addon already disabled'));
} }
AddonCore::uninstall($addon); $this->addonHelper->uninstallAddon($addon);
return 0; return 0;
} }

View File

@ -11,7 +11,7 @@ namespace Friendica\Console;
use Asika\SimpleConsole\Console; use Asika\SimpleConsole\Console;
use Friendica\App\Mode; use Friendica\App\Mode;
use Friendica\Core\Addon; use Friendica\Core\Addon\AddonHelper;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs; use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
@ -29,6 +29,7 @@ final class JetstreamDaemon extends Console
private IManageKeyValuePairs $keyValue; private IManageKeyValuePairs $keyValue;
private SysDaemon $daemon; private SysDaemon $daemon;
private Jetstream $jetstream; private Jetstream $jetstream;
private AddonHelper $addonHelper;
/** /**
* @param Mode $mode * @param Mode $mode
@ -38,7 +39,7 @@ final class JetstreamDaemon extends Console
* @param Jetstream $jetstream * @param Jetstream $jetstream
* @param array|null $argv * @param array|null $argv
*/ */
public function __construct(Mode $mode, IManageConfigValues $config, IManageKeyValuePairs $keyValue, SysDaemon $daemon, Jetstream $jetstream, array $argv = null) public function __construct(Mode $mode, IManageConfigValues $config, IManageKeyValuePairs $keyValue, SysDaemon $daemon, Jetstream $jetstream, AddonHelper $addonHelper, array $argv = null)
{ {
parent::__construct($argv); parent::__construct($argv);
@ -47,6 +48,7 @@ final class JetstreamDaemon extends Console
$this->keyValue = $keyValue; $this->keyValue = $keyValue;
$this->jetstream = $jetstream; $this->jetstream = $jetstream;
$this->daemon = $daemon; $this->daemon = $daemon;
$this->addonHelper = $addonHelper;
} }
protected function getHelp(): string protected function getHelp(): string
@ -95,10 +97,10 @@ HELP;
); );
} }
Addon::loadAddons(); $this->addonHelper->loadAddons();
Hook::loadHooks(); Hook::loadHooks();
if (!Addon::isEnabled('bluesky')) { if (!$this->addonHelper->isAddonEnabled('bluesky')) {
throw new RuntimeException("Bluesky has to be enabled.\n"); throw new RuntimeException("Bluesky has to be enabled.\n");
} }

View File

@ -192,5 +192,7 @@ HELP;
} while ($moved); } while ($moved);
$this->out(sprintf(date('[Y-m-d H:i:s] ') . 'Moved %d files total', $total)); $this->out(sprintf(date('[Y-m-d H:i:s] ') . 'Moved %d files total', $total));
return 0;
} }
} }

View File

@ -207,7 +207,7 @@ class Conversation
if ($total === 0) { if ($total === 0) {
throw new InternalServerErrorException(sprintf('There has to be at least one Liker for verb "%s"', $verb)); throw new InternalServerErrorException(sprintf('There has to be at least one Liker for verb "%s"', $verb));
} else if ($total === 1) { } elseif ($total === 1) {
$likerString = $likers[0]; $likerString = $likers[0];
} else { } else {
if ($total < $this->config->get('system', 'max_likers')) { if ($total < $this->config->get('system', 'max_likers')) {
@ -326,7 +326,7 @@ class Conversation
'$ispublic' => $this->l10n->t('Visible to <strong>everybody</strong>'), '$ispublic' => $this->l10n->t('Visible to <strong>everybody</strong>'),
'$linkurl' => $this->l10n->t('Please enter a image/video/audio/webpage URL:'), '$linkurl' => $this->l10n->t('Please enter a image/video/audio/webpage URL:'),
'$term' => $this->l10n->t('Tag term:'), '$term' => $this->l10n->t('Tag term:'),
'$fileas' => $this->l10n->t('Save to Folder:'), '$fileas' => $this->l10n->t('Save to Folder'),
'$whereareu' => $this->l10n->t('Where are you right now?'), '$whereareu' => $this->l10n->t('Where are you right now?'),
'$delitems' => $this->l10n->t("Delete item\x28s\x29?"), '$delitems' => $this->l10n->t("Delete item\x28s\x29?"),
'$is_mobile' => $this->mode->isMobile(), '$is_mobile' => $this->mode->isMobile(),
@ -1501,7 +1501,7 @@ class Conversation
$body_html = ItemModel::prepareBody($item, true, $preview); $body_html = ItemModel::prepareBody($item, true, $preview);
[$categories, $folders] = $this->item->determineCategoriesTerms($item, $this->session->getLocalUserId()); list($categories, $folders) = $this->item->determineCategoriesTerms($item, $this->session->getLocalUserId());
if (!empty($item['featured'])) { if (!empty($item['featured'])) {
$pinned = $this->l10n->t('Pinned item'); $pinned = $this->l10n->t('Pinned item');

View File

@ -7,8 +7,8 @@
namespace Friendica\Content; namespace Friendica\Content;
use Friendica\Core\Hook;
use Friendica\DI; use Friendica\DI;
use Friendica\Event\ArrayFilterEvent;
class Feature class Feature
{ {
@ -41,15 +41,23 @@ class Feature
*/ */
public static function isEnabled(int $uid, $feature): bool public static function isEnabled(int $uid, $feature): bool
{ {
if (!DI::config()->get('feature_lock', $feature, false)) { $config = DI::config();
$enabled = DI::config()->get('feature', $feature) ?? self::getDefault($feature); $pConfig = DI::pConfig();
$enabled = DI::pConfig()->get($uid, 'feature', $feature) ?? $enabled; $eventDispatcher = DI::eventDispatcher();
if (!$config->get('feature_lock', $feature, false)) {
$enabled = $config->get('feature', $feature) ?? self::getDefault($feature);
$enabled = $pConfig->get($uid, 'feature', $feature) ?? $enabled;
} else { } else {
$enabled = true; $enabled = true;
} }
$arr = ['uid' => $uid, 'feature' => $feature, 'enabled' => $enabled]; $arr = ['uid' => $uid, 'feature' => $feature, 'enabled' => $enabled];
Hook::callAll('isEnabled', $arr);
$arr = $eventDispatcher->dispatch(
new ArrayFilterEvent(ArrayFilterEvent::FEATURE_ENABLED, $arr)
)->getArray();
return (bool)$arr['enabled']; return (bool)$arr['enabled'];
} }
@ -86,55 +94,58 @@ class Feature
*/ */
public static function get($filtered = true) public static function get($filtered = true)
{ {
$arr = [ $l10n = DI::l10n();
$config = DI::config();
$eventDispatcher = DI::eventDispatcher();
$arr = [
// General // General
'general' => [ 'general' => [
DI::l10n()->t('General Features'), $l10n->t('General Features'),
//array('expire', DI::l10n()->t('Content Expiration'), DI::l10n()->t('Remove old posts/comments after a period of time')), //array('expire', $l10n->t('Content Expiration'), $l10n->t('Remove old posts/comments after a period of time')),
[self::PHOTO_LOCATION, DI::l10n()->t('Photo Location'), DI::l10n()->t("Photo metadata is normally stripped. This extracts the location \x28if present\x29 prior to stripping metadata and links it to a map."), false, DI::config()->get('feature_lock', self::PHOTO_LOCATION, false)], [self::PHOTO_LOCATION, $l10n->t('Photo Location'), $l10n->t("Photo metadata is normally stripped. This extracts the location \x28if present\x29 prior to stripping metadata and links it to a map."), false, $config->get('feature_lock', self::PHOTO_LOCATION, false)],
[self::COMMUNITY, DI::l10n()->t('Display the community in the navigation'), DI::l10n()->t('If enabled, the community can be accessed via the navigation menu. Independent from this setting, the community timelines can always be accessed via the channels.'), true, DI::config()->get('feature_lock', self::COMMUNITY, false)], [self::COMMUNITY, $l10n->t('Display the community in the navigation'), $l10n->t('If enabled, the community can be accessed via the navigation menu. Independent from this setting, the community timelines can always be accessed via the channels.'), true, $config->get('feature_lock', self::COMMUNITY, false)],
], ],
// Post composition // Post composition
'composition' => [ 'composition' => [
DI::l10n()->t('Post Composition Features'), $l10n->t('Post Composition Features'),
[self::EXPLICIT_MENTIONS, DI::l10n()->t('Explicit Mentions'), DI::l10n()->t('Add explicit mentions to comment box for manual control over who gets mentioned in replies.'), false, DI::config()->get('feature_lock', Feature::EXPLICIT_MENTIONS, false)], [self::EXPLICIT_MENTIONS, $l10n->t('Explicit Mentions'), $l10n->t('Add explicit mentions to comment box for manual control over who gets mentioned in replies.'), false, $config->get('feature_lock', Feature::EXPLICIT_MENTIONS, false)],
[self::ADD_ABSTRACT, DI::l10n()->t('Add an abstract from ActivityPub content warnings'), DI::l10n()->t('Add an abstract when commenting on ActivityPub posts with a content warning. Abstracts are displayed as content warning on systems like Mastodon or Pleroma.'), false, DI::config()->get('feature_lock', self::ADD_ABSTRACT, false)], [self::ADD_ABSTRACT, $l10n->t('Add an abstract from ActivityPub content warnings'), $l10n->t('Add an abstract when commenting on ActivityPub posts with a content warning. Abstracts are displayed as content warning on systems like Mastodon or Pleroma.'), false, $config->get('feature_lock', self::ADD_ABSTRACT, false)],
], ],
// Item tools // Item tools
'tools' => [ 'tools' => [
DI::l10n()->t('Post/Comment Tools'), $l10n->t('Post/Comment Tools'),
[self::CATEGORIES, DI::l10n()->t('Post Categories'), DI::l10n()->t('Add categories to your posts'), false, DI::config()->get('feature_lock', self::CATEGORIES, false)], [self::CATEGORIES, $l10n->t('Post Categories'), $l10n->t('Add categories to your posts'), false, $config->get('feature_lock', self::CATEGORIES, false)],
], ],
// Widget visibility on the network stream // Widget visibility on the network stream
'network' => [ 'network' => [
DI::l10n()->t('Network Widgets'), $l10n->t('Network Widgets'),
[self::CIRCLES, DI::l10n()->t('Circles'), DI::l10n()->t('Display posts that have been created by accounts of the selected circle.'), true, DI::config()->get('feature_lock', self::CIRCLES, false)], [self::CIRCLES, $l10n->t('Circles'), $l10n->t('Display posts that have been created by accounts of the selected circle.'), true, $config->get('feature_lock', self::CIRCLES, false)],
[self::GROUPS, DI::l10n()->t('Groups'), DI::l10n()->t('Display posts that have been distributed by the selected group.'), true, DI::config()->get('feature_lock', self::GROUPS, false)], [self::GROUPS, $l10n->t('Groups'), $l10n->t('Display posts that have been distributed by the selected group.'), true, $config->get('feature_lock', self::GROUPS, false)],
[self::ARCHIVE, DI::l10n()->t('Archives'), DI::l10n()->t('Display an archive where posts can be selected by month and year.'), true, DI::config()->get('feature_lock', self::ARCHIVE, false)], [self::ARCHIVE, $l10n->t('Archives'), $l10n->t('Display an archive where posts can be selected by month and year.'), true, $config->get('feature_lock', self::ARCHIVE, false)],
[self::NETWORKS, DI::l10n()->t('Protocols'), DI::l10n()->t('Display posts with the selected protocols.'), true, DI::config()->get('feature_lock', self::NETWORKS, false)], [self::NETWORKS, $l10n->t('Protocols'), $l10n->t('Display posts with the selected protocols.'), true, $config->get('feature_lock', self::NETWORKS, false)],
[self::ACCOUNTS, DI::l10n()->t('Account Types'), DI::l10n()->t('Display posts done by accounts with the selected account type.'), true, DI::config()->get('feature_lock', self::ACCOUNTS, false)], [self::ACCOUNTS, $l10n->t('Account Types'), $l10n->t('Display posts done by accounts with the selected account type.'), true, $config->get('feature_lock', self::ACCOUNTS, false)],
[self::CHANNELS, DI::l10n()->t('Channels'), DI::l10n()->t('Display posts in the system channels and user defined channels.'), true, DI::config()->get('feature_lock', self::CHANNELS, false)], [self::CHANNELS, $l10n->t('Channels'), $l10n->t('Display posts in the system channels and user defined channels.'), true, $config->get('feature_lock', self::CHANNELS, false)],
[self::SEARCHES, DI::l10n()->t('Saved Searches'), DI::l10n()->t('Display posts that contain subscribed hashtags.'), true, DI::config()->get('feature_lock', self::SEARCHES, false)], [self::SEARCHES, $l10n->t('Saved Searches'), $l10n->t('Display posts that contain subscribed hashtags.'), true, $config->get('feature_lock', self::SEARCHES, false)],
[self::FOLDERS, DI::l10n()->t('Saved Folders'), DI::l10n()->t('Display a list of folders in which posts are stored.'), true, DI::config()->get('feature_lock', self::FOLDERS, false)], [self::FOLDERS, $l10n->t('Saved Folders'), $l10n->t('Display a list of folders in which posts are stored.'), true, $config->get('feature_lock', self::FOLDERS, false)],
[self::NOSHARER, DI::l10n()->t('Own Contacts'), DI::l10n()->t('Include or exclude posts from subscribed accounts. This widget is not visible on all channels.'), true, DI::config()->get('feature_lock', self::NOSHARER, false)], [self::NOSHARER, $l10n->t('Own Contacts'), $l10n->t('Include or exclude posts from subscribed accounts. This widget is not visible on all channels.'), true, $config->get('feature_lock', self::NOSHARER, false)],
[self::TRENDING_TAGS, DI::l10n()->t('Trending Tags'), DI::l10n()->t('Display a list of the most popular tags in recent public posts.'), false, DI::config()->get('feature_lock', self::TRENDING_TAGS, false)], [self::TRENDING_TAGS, $l10n->t('Trending Tags'), $l10n->t('Display a list of the most popular tags in recent public posts.'), false, $config->get('feature_lock', self::TRENDING_TAGS, false)],
], ],
// Advanced Profile Settings // Advanced Profile Settings
'advanced_profile' => [ 'advanced_profile' => [
DI::l10n()->t('Advanced Profile Settings'), $l10n->t('Advanced Profile Settings'),
[self::TAGCLOUD, DI::l10n()->t('Tag Cloud'), DI::l10n()->t('Provide a personal tag cloud on your profile page'), false, DI::config()->get('feature_lock', self::TAGCLOUD, false)], [self::TAGCLOUD, $l10n->t('Tag Cloud'), $l10n->t('Provide a personal tag cloud on your profile page'), false, $config->get('feature_lock', self::TAGCLOUD, false)],
[self::MEMBER_SINCE, DI::l10n()->t('Display Membership Date'), DI::l10n()->t('Display membership date in profile'), false, DI::config()->get('feature_lock', self::MEMBER_SINCE, false)], [self::MEMBER_SINCE, $l10n->t('Display Membership Date'), $l10n->t('Display membership date in profile'), false, $config->get('feature_lock', self::MEMBER_SINCE, false)],
], ],
//Advanced Calendar Settings //Advanced Calendar Settings
'advanced_calendar' => [ 'advanced_calendar' => [
DI::l10n()->t('Advanced Calendar Settings'), $l10n->t('Advanced Calendar Settings'),
[self::PUBLIC_CALENDAR, DI::l10n()->t('Allow anonymous access to your calendar'), DI::l10n()->t('Allows anonymous visitors to consult your calendar and your public events. Contact birthday events are private to you.'), false, DI::config()->get('feature_lock', self::PUBLIC_CALENDAR, false)], [self::PUBLIC_CALENDAR, $l10n->t('Allow anonymous access to your calendar'), $l10n->t('Allows anonymous visitors to consult your calendar and your public events. Contact birthday events are private to you.'), false, $config->get('feature_lock', self::PUBLIC_CALENDAR, false)],
] ]
]; ];
@ -144,7 +155,7 @@ class Feature
foreach ($arr as $k => $x) { foreach ($arr as $k => $x) {
$has_items = false; $has_items = false;
$kquantity = count($arr[$k]); $kquantity = count($arr[$k]);
for ($y = 0; $y < $kquantity; $y ++) { for ($y = 0; $y < $kquantity; $y++) {
if (is_array($arr[$k][$y])) { if (is_array($arr[$k][$y])) {
if ($arr[$k][$y][4] === false) { if ($arr[$k][$y][4] === false) {
$has_items = true; $has_items = true;
@ -159,7 +170,10 @@ class Feature
} }
} }
Hook::callAll('get', $arr); $arr = $eventDispatcher->dispatch(
new ArrayFilterEvent(ArrayFilterEvent::FEATURE_GET, $arr)
)->getArray();
return $arr; return $arr;
} }
} }

View File

@ -108,8 +108,6 @@ class GroupManager
$entries = []; $entries = [];
$contacts = [];
foreach ($contacts as $contact) { foreach ($contacts as $contact) {
$entry = [ $entry = [
'url' => 'contact/' . $contact['id'] . '/conversations', 'url' => 'contact/' . $contact['id'] . '/conversations',

View File

@ -607,7 +607,7 @@ class Item
} else { } else {
$owner_avatar = $item['owner-id']; $owner_avatar = $item['owner-id'];
$owner_updated = $item['owner-updated']; $owner_updated = $item['owner-updated'];
$owner_thumb = $item['owner-avatar']; $owner_thumb = $item['owner-avatar'] ?? '';
} }
if (empty($owner_thumb) || Photo::isPhotoURI($owner_thumb)) { if (empty($owner_thumb) || Photo::isPhotoURI($owner_thumb)) {

View File

@ -10,11 +10,12 @@ namespace Friendica\Content;
use Friendica\App\BaseURL; use Friendica\App\BaseURL;
use Friendica\App\Router; use Friendica\App\Router;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleUserSessions; use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Event\ArrayFilterEvent;
use Friendica\Event\HtmlFilterEvent;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Module\Conversation\Community; use Friendica\Module\Conversation\Community;
@ -22,6 +23,7 @@ use Friendica\Module\Home;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Security\OpenWebAuth; use Friendica\Security\OpenWebAuth;
use Psr\EventDispatcher\EventDispatcherInterface;
class Nav class Nav
{ {
@ -63,7 +65,9 @@ class Nav
/** @var Router */ /** @var Router */
private $router; private $router;
public function __construct(BaseURL $baseUrl, L10n $l10n, IHandleUserSessions $session, Database $database, IManageConfigValues $config, Router $router) private EventDispatcherInterface $eventDispatcher;
public function __construct(BaseURL $baseUrl, L10n $l10n, IHandleUserSessions $session, Database $database, IManageConfigValues $config, Router $router, EventDispatcherInterface $eventDispatcher)
{ {
$this->baseUrl = $baseUrl; $this->baseUrl = $baseUrl;
$this->l10n = $l10n; $this->l10n = $l10n;
@ -71,6 +75,7 @@ class Nav
$this->database = $database; $this->database = $database;
$this->config = $config; $this->config = $config;
$this->router = $router; $this->router = $router;
$this->eventDispatcher = $eventDispatcher;
} }
/** /**
@ -108,12 +113,15 @@ class Nav
'$userinfo' => $nav_info['userinfo'], '$userinfo' => $nav_info['userinfo'],
'$sel' => self::$selected, '$sel' => self::$selected,
'$apps' => $this->getAppMenu(), '$apps' => $this->getAppMenu(),
'$home' => $this->l10n->t('Go back'), '$home' => $this->l10n->t('Home'),
'$skip' => $this->l10n->t('Skip to main content'),
'$clear_notifs' => $this->l10n->t('Clear notifications'), '$clear_notifs' => $this->l10n->t('Clear notifications'),
'$search_hint' => $this->l10n->t('@name, !group, #tags, content') '$search_hint' => $this->l10n->t('@name, !group, #tags, content')
]); ]);
Hook::callAll('page_header', $nav); $nav = $this->eventDispatcher->dispatch(
new HtmlFilterEvent(HtmlFilterEvent::PAGE_HEADER, $nav)
)->getHtml();
return $nav; return $nav;
} }
@ -150,9 +158,11 @@ class Nav
) { ) {
$arr = ['app_menu' => $appMenu]; $arr = ['app_menu' => $appMenu];
Hook::callAll('app_menu', $arr); $arr = $this->eventDispatcher->dispatch(
new ArrayFilterEvent(ArrayFilterEvent::APP_MENU, $arr)
)->getArray();
$appMenu = $arr['app_menu']; $appMenu = $arr['app_menu'] ?? [];
} }
return $appMenu; return $appMenu;
@ -336,7 +346,9 @@ class Nav
'userinfo' => $userinfo, 'userinfo' => $userinfo,
]; ];
Hook::callAll('nav_info', $nav_info); $nav_info = $this->eventDispatcher->dispatch(
new ArrayFilterEvent(ArrayFilterEvent::NAV_INFO, $nav_info)
)->getArray();
return $nav_info; return $nav_info;
} }

View File

@ -1583,7 +1583,7 @@ class BBCode
// Check for headers // Check for headers
if ($simple_html == self::INTERNAL) { if ($simple_html == self::INTERNAL) {
//Ensure to always start with <h4> if possible //Ensure to always start with <h3> if possible
$heading_count = 0; $heading_count = 0;
for ($level = 6; $level > 0; $level--) { for ($level = 6; $level > 0; $level--) {
if (preg_match("(\[h$level\].*?\[\/h$level\])ism", $text)) { if (preg_match("(\[h$level\].*?\[\/h$level\])ism", $text)) {
@ -1591,7 +1591,7 @@ class BBCode
} }
} }
if ($heading_count > 0) { if ($heading_count > 0) {
$heading = min($heading_count + 3, 6); $heading = min($heading_count + 2, 6);
for ($level = 6; $level > 0; $level--) { for ($level = 6; $level > 0; $level--) {
if (preg_match("(\[h$level\].*?\[\/h$level\])ism", $text)) { if (preg_match("(\[h$level\].*?\[\/h$level\])ism", $text)) {
$text = preg_replace("(\[h$level\](.*?)\[\/h$level\])ism", "</p><h$heading>$1</h$heading><p>", $text); $text = preg_replace("(\[h$level\](.*?)\[\/h$level\])ism", "</p><h$heading>$1</h$heading><p>", $text);

View File

@ -7,7 +7,6 @@
namespace Friendica\Content; namespace Friendica\Content;
use Friendica\Core\Addon;
use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
@ -33,13 +32,13 @@ class Widget
*/ */
public static function follow(string $value = ''): string public static function follow(string $value = ''): string
{ {
return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/follow.tpl'), array( return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/follow.tpl'), [
'$connect' => DI::l10n()->t('Add New Contact'), '$connect' => DI::l10n()->t('Add New Contact'),
'$desc' => DI::l10n()->t('Enter address or web location'), '$desc' => DI::l10n()->t('Enter address or web location'),
'$hint' => DI::l10n()->t('Example: bob@example.com, http://example.com/barbara'), '$hint' => DI::l10n()->t('Example: bob@example.com, http://example.com/barbara'),
'$value' => $value, '$value' => $value,
'$follow' => DI::l10n()->t('Connect') '$follow' => DI::l10n()->t('Connect')
)); ]);
} }
/** /**
@ -87,19 +86,21 @@ class Widget
*/ */
public static function unavailableNetworks(): array public static function unavailableNetworks(): array
{ {
$addonHelper = DI::addonHelper();
// Always hide content from these networks // Always hide content from these networks
$networks = [Protocol::PHANTOM, Protocol::FACEBOOK, Protocol::APPNET, Protocol::TWITTER, Protocol::ZOT, Protocol::OSTATUS, Protocol::STATUSNET]; $networks = [Protocol::PHANTOM, Protocol::FACEBOOK, Protocol::APPNET, Protocol::TWITTER, Protocol::ZOT, Protocol::OSTATUS, Protocol::STATUSNET];
Addon::loadAddons(); $addonHelper->loadAddons();
if (!Addon::isEnabled('discourse')) { if (!$addonHelper->isAddonEnabled('discourse')) {
$networks[] = Protocol::DISCOURSE; $networks[] = Protocol::DISCOURSE;
} }
if (!Addon::isEnabled('pumpio')) { if (!$addonHelper->isAddonEnabled('pumpio')) {
$networks[] = Protocol::PUMPIO; $networks[] = Protocol::PUMPIO;
} }
if (!Addon::isEnabled('tumblr')) { if (!$addonHelper->isAddonEnabled('tumblr')) {
$networks[] = Protocol::TUMBLR; $networks[] = Protocol::TUMBLR;
} }
@ -107,7 +108,7 @@ class Widget
$networks[] = Protocol::DIASPORA; $networks[] = Protocol::DIASPORA;
} }
if (!Addon::isEnabled('pnut')) { if (!$addonHelper->isAddonEnabled('pnut')) {
$networks[] = Protocol::PNUT; $networks[] = Protocol::PNUT;
} }
return $networks; return $networks;
@ -120,18 +121,20 @@ class Widget
*/ */
public static function availableNetworks(): array public static function availableNetworks(): array
{ {
$networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::FEED]; $addonHelper = DI::addonHelper();
Addon::loadAddons();
if (Addon::isEnabled('discourse')) { $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::FEED];
$addonHelper->loadAddons();
if ($addonHelper->isAddonEnabled('discourse')) {
$networks[] = Protocol::DISCOURSE; $networks[] = Protocol::DISCOURSE;
} }
if (Addon::isEnabled('pumpio')) { if ($addonHelper->isAddonEnabled('pumpio')) {
$networks[] = Protocol::PUMPIO; $networks[] = Protocol::PUMPIO;
} }
if (Addon::isEnabled('tumblr')) { if ($addonHelper->isAddonEnabled('tumblr')) {
$networks[] = Protocol::TUMBLR; $networks[] = Protocol::TUMBLR;
} }
@ -143,7 +146,7 @@ class Widget
$networks[] = Protocol::MAIL; $networks[] = Protocol::MAIL;
} }
if (Addon::isEnabled('pnut')) { if ($addonHelper->isAddonEnabled('pnut')) {
$networks[] = Protocol::PNUT; $networks[] = Protocol::PNUT;
} }
return $networks; return $networks;

View File

@ -18,6 +18,9 @@ class Addon
{ {
/** /**
* The addon sub-directory * The addon sub-directory
*
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::getAddonPath()` instead
*
* @var string * @var string
*/ */
const DIRECTORY = 'addon'; const DIRECTORY = 'addon';
@ -34,6 +37,8 @@ class Addon
* This list is made from scanning the addon/ folder. * This list is made from scanning the addon/ folder.
* Unsupported addons are excluded unless they already are enabled or system.show_unsupported_addon is set. * Unsupported addons are excluded unless they already are enabled or system.show_unsupported_addon is set.
* *
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::getAvailableAddons()` instead
*
* @return array * @return array
* @throws \Exception * @throws \Exception
*/ */
@ -64,6 +69,8 @@ class Addon
* Returns a list of addons that can be configured at the node level. * Returns a list of addons that can be configured at the node level.
* The list is formatted for display in the admin panel aside. * The list is formatted for display in the admin panel aside.
* *
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::getEnabledAddonsWithAdminSettings()` instead
*
* @return array * @return array
* @throws \Exception * @throws \Exception
*/ */
@ -88,7 +95,6 @@ class Addon
return $addons_admin; return $addons_admin;
} }
/** /**
* Synchronize addons: * Synchronize addons:
* *
@ -100,6 +106,7 @@ class Addon
* Then go through the config list and if we have a addon that isn't installed, * Then go through the config list and if we have a addon that isn't installed,
* call the install procedure and add it to the database. * call the install procedure and add it to the database.
* *
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::loadAddons()` instead
*/ */
public static function loadAddons() public static function loadAddons()
{ {
@ -109,6 +116,8 @@ class Addon
/** /**
* uninstalls an addon. * uninstalls an addon.
* *
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::uninstallAddon()` instead
*
* @param string $addon name of the addon * @param string $addon name of the addon
* @return void * @return void
* @throws \Exception * @throws \Exception
@ -135,6 +144,8 @@ class Addon
/** /**
* installs an addon. * installs an addon.
* *
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::installAddon()` instead
*
* @param string $addon name of the addon * @param string $addon name of the addon
* @return bool * @return bool
* @throws \Exception * @throws \Exception
@ -173,6 +184,8 @@ class Addon
/** /**
* reload all updated addons * reload all updated addons
* *
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::reloadAddons()` instead
*
* @return void * @return void
* @throws \Exception * @throws \Exception
* *
@ -209,6 +222,9 @@ class Addon
* * Maintainer: Jess <email> * * Maintainer: Jess <email>
* * * *
* *\endcode * *\endcode
*
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::getAddonInfo()` instead
*
* @param string $addon the name of the addon * @param string $addon the name of the addon
* @return array with the addon information * @return array with the addon information
* @throws \Exception * @throws \Exception
@ -275,6 +291,8 @@ class Addon
/** /**
* Checks if the provided addon is enabled * Checks if the provided addon is enabled
* *
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::isAddonEnabled()` instead
*
* @param string $addon * @param string $addon
* @return boolean * @return boolean
*/ */
@ -286,6 +304,8 @@ class Addon
/** /**
* Returns a list of the enabled addon names * Returns a list of the enabled addon names
* *
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::getEnabledAddons()` instead
*
* @return array * @return array
*/ */
public static function getEnabledList(): array public static function getEnabledList(): array
@ -296,6 +316,8 @@ class Addon
/** /**
* Returns the list of non-hidden enabled addon names * Returns the list of non-hidden enabled addon names
* *
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::getVisibleEnabledAddons()` instead
*
* @return array * @return array
* @throws \Exception * @throws \Exception
*/ */

View File

@ -0,0 +1,92 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Core\Addon;
/**
* Some functions to handle addons
*/
interface AddonHelper
{
/**
* Returns the absolute path to the addon folder
*
* e.g. `/var/www/html/addon`
*/
public function getAddonPath(): string;
/**
* Returns the list of available addons.
*
* This list is made from scanning the addon/ folder.
* Unsupported addons are excluded unless they already are enabled or system.show_unsupported_addon is set.
*
* @return string[]
*/
public function getAvailableAddons(): array;
/**
* Installs an addon.
*
* @param string $addonId name of the addon
*
* @return bool true on success or false on failure
*/
public function installAddon(string $addonId): bool;
/**
* Uninstalls an addon.
*
* @param string $addonId name of the addon
*/
public function uninstallAddon(string $addonId): void;
/**
* Load addons.
*
* @internal
*/
public function loadAddons(): void;
/**
* Reload (uninstall and install) all updated addons.
*/
public function reloadAddons(): void;
/**
* Get the comment block of an addon as value object.
*/
public function getAddonInfo(string $addonId): AddonInfo;
/**
* Checks if the provided addon is enabled
*/
public function isAddonEnabled(string $addonId): bool;
/**
* Returns a list with the IDs of the enabled addons
*
* @return string[]
*/
public function getEnabledAddons(): array;
/**
* Returns a list with the IDs of the non-hidden enabled addons
*
* @return string[]
*/
public function getVisibleEnabledAddons(): array;
/**
* Returns a list with the IDs of the enabled addons that provides admin settings.
*
* @return string[]
*/
public function getEnabledAddonsWithAdminSettings(): array;
}

View File

@ -0,0 +1,140 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Core\Addon;
/**
* Information about an addon
*/
final class AddonInfo
{
/**
* @internal Never create this object by yourself, use `Friendica\Core\Addon\AddonHelper::getAddonInfo()` instead.
*
* @see Friendica\Core\Addon\AddonHelper::getAddonInfo()
*/
public static function fromArray(array $info): self
{
$id = array_key_exists('id', $info) ? (string) $info['id'] : '';
$name = array_key_exists('name', $info) ? (string) $info['name'] : '';
$description = array_key_exists('description', $info) ? (string) $info['description'] : '';
$authors = array_key_exists('authors', $info) ? self::parseContributors($info['authors']) : [];
$maintainers = array_key_exists('maintainers', $info) ? self::parseContributors($info['maintainers']) : [];
$version = array_key_exists('version', $info) ? (string) $info['version'] : '';
$status = array_key_exists('status', $info) ? (string) $info['status'] : '';
return new self(
$id,
$name,
$description,
$authors,
$maintainers,
$version,
$status
);
}
private static function parseContributors($entries): array
{
if (!is_array($entries)) {
return [];
}
$contributors = [];
foreach ($entries as $entry) {
if (!is_array($entry)) {
continue;
}
if (!array_key_exists('name', $entry)) {
continue;
}
$contributor = [
'name' => (string) $entry['name'],
];
if (array_key_exists('link', $entry)) {
$contributor['link'] = (string) $entry['link'];
}
$contributors[] = $contributor;
}
return $contributors;
}
private string $id = '';
private string $name = '';
private string $description = '';
private array $authors = [];
private array $maintainers = [];
private string $version = '';
private string $status = '';
private function __construct(
string $id,
string $name,
string $description,
array $authors,
array $maintainers,
string $version,
string $status
) {
$this->id = $id;
$this->name = $name;
$this->description = $description;
$this->authors = $authors;
$this->maintainers = $maintainers;
$this->version = $version;
$this->status = $status;
}
public function getId(): string
{
return $this->id;
}
public function getName(): string
{
return $this->name;
}
public function getDescription(): string
{
return $this->description;
}
public function getAuthors(): array
{
return $this->authors;
}
public function getMaintainers(): array
{
return $this->maintainers;
}
public function getVersion(): string
{
return $this->version;
}
public function getStatus(): string
{
return $this->status;
}
}

View File

@ -0,0 +1,154 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Core\Addon;
use Friendica\Core\Addon;
/**
* Proxy to the Addon class
*
* @internal
*/
final class AddonProxy implements AddonHelper
{
private string $addonPath;
public function __construct(string $addonPath)
{
$this->addonPath = $addonPath;
}
/**
* Returns the absolute path to the addon folder
*
* e.g. `/var/www/html/addon`
*/
public function getAddonPath(): string
{
return $this->addonPath;
}
/**
* Returns the list of available addons.
*
* This list is made from scanning the addon/ folder.
* Unsupported addons are excluded unless they already are enabled or system.show_unsupported_addon is set.
*
* @return string[]
*/
public function getAvailableAddons(): array
{
return array_map(
function (array $item) {
return $item[0];
},
Addon::getAvailableList()
);
}
/**
* Installs an addon.
*
* @param string $addonId name of the addon
*
* @return bool true on success or false on failure
*/
public function installAddon(string $addonId): bool
{
return Addon::install($addonId);
}
/**
* Uninstalls an addon.
*
* @param string $addonId name of the addon
*/
public function uninstallAddon(string $addonId): void
{
Addon::uninstall($addonId);
}
/**
* Load addons.
*
* @internal
*/
public function loadAddons(): void
{
Addon::loadAddons();
}
/**
* Reload (uninstall and install) all updated addons.
*/
public function reloadAddons(): void
{
Addon::reload();
}
/**
* Get the comment block of an addon as value object.
*/
public function getAddonInfo(string $addonId): AddonInfo
{
$data = Addon::getInfo($addonId);
// add addon ID
$data['id'] = $addonId;
// rename author to authors
$data['authors'] = $data['author'];
unset($data['author']);
// rename maintainer to maintainers
$data['maintainers'] = $data['maintainer'];
unset($data['maintainer']);
return AddonInfo::fromArray($data);
}
/**
* Checks if the provided addon is enabled
*/
public function isAddonEnabled(string $addonId): bool
{
return Addon::isEnabled($addonId);
}
/**
* Returns a list with the IDs of the enabled addons
*
* @return string[]
*/
public function getEnabledAddons(): array
{
return Addon::getEnabledList();
}
/**
* Returns a list with the IDs of the non-hidden enabled addons
*
* @return string[]
*/
public function getVisibleEnabledAddons(): array
{
return Addon::getVisibleList();
}
/**
* Returns a list with the IDs of the enabled addons that provides admin settings.
*
* @return string[]
*/
public function getEnabledAddonsWithAdminSettings(): array
{
return array_keys(Addon::getAdminList());
}
}

View File

@ -42,7 +42,7 @@ class Config
* *
* @return Util\ConfigFileManager * @return Util\ConfigFileManager
*/ */
public function createConfigFileManager(string $basePath, array $server = []): Util\ConfigFileManager public function createConfigFileManager(string $basePath, string $addonPath, array $server = []): Util\ConfigFileManager
{ {
if (!empty($server[self::CONFIG_DIR_ENV]) && is_dir($server[self::CONFIG_DIR_ENV])) { if (!empty($server[self::CONFIG_DIR_ENV]) && is_dir($server[self::CONFIG_DIR_ENV])) {
$configDir = $server[self::CONFIG_DIR_ENV]; $configDir = $server[self::CONFIG_DIR_ENV];
@ -51,7 +51,7 @@ class Config
} }
$staticDir = $basePath . DIRECTORY_SEPARATOR . self::STATIC_DIR; $staticDir = $basePath . DIRECTORY_SEPARATOR . self::STATIC_DIR;
return new Util\ConfigFileManager($basePath, $configDir, $staticDir, $server); return new Util\ConfigFileManager($basePath, $addonPath, $configDir, $staticDir, $server);
} }
/** /**

View File

@ -7,7 +7,6 @@
namespace Friendica\Core\Config\Util; namespace Friendica\Core\Config\Util;
use Friendica\Core\Addon;
use Friendica\Core\Config\Exception\ConfigFileException; use Friendica\Core\Config\Exception\ConfigFileException;
use Friendica\Core\Config\ValueObject\Cache; use Friendica\Core\Config\ValueObject\Cache;
@ -46,6 +45,7 @@ class ConfigFileManager
* @var string * @var string
*/ */
private $baseDir; private $baseDir;
private string $addonDir;
/** /**
* @var string * @var string
*/ */
@ -65,9 +65,10 @@ class ConfigFileManager
* @param string $configDir * @param string $configDir
* @param string $staticDir * @param string $staticDir
*/ */
public function __construct(string $baseDir, string $configDir, string $staticDir, array $server = []) public function __construct(string $baseDir, string $addonDir, string $configDir, string $staticDir, array $server = [])
{ {
$this->baseDir = $baseDir; $this->baseDir = $baseDir;
$this->addonDir = $addonDir;
$this->configDir = $configDir; $this->configDir = $configDir;
$this->staticDir = $staticDir; $this->staticDir = $staticDir;
$this->server = $server; $this->server = $server;
@ -122,7 +123,7 @@ class ConfigFileManager
if (file_exists($configName)) { if (file_exists($configName)) {
return $this->loadConfigFile($configName); return $this->loadConfigFile($configName);
} else if (file_exists($iniName)) { } elseif (file_exists($iniName)) {
return $this->loadINIConfigFile($iniName); return $this->loadINIConfigFile($iniName);
} else { } else {
return []; return [];
@ -160,17 +161,16 @@ class ConfigFileManager
*/ */
public function loadAddonConfig(string $name): array public function loadAddonConfig(string $name): array
{ {
$filepath = $this->baseDir . DIRECTORY_SEPARATOR . // /var/www/html/ $filepath = $this->addonDir . DIRECTORY_SEPARATOR . // /var/www/html/addon/
Addon::DIRECTORY . DIRECTORY_SEPARATOR . // addon/
$name . DIRECTORY_SEPARATOR . // openstreetmap/ $name . DIRECTORY_SEPARATOR . // openstreetmap/
'config' . DIRECTORY_SEPARATOR . // config/ 'config' . DIRECTORY_SEPARATOR . // config/
$name . ".config.php"; // openstreetmap.config.php $name . ".config.php"; // openstreetmap.config.php
if (file_exists($filepath)) { if (!file_exists($filepath)) {
return $this->loadConfigFile($filepath);
} else {
return []; return [];
} }
return $this->loadConfigFile($filepath);
} }
/** /**

View File

@ -0,0 +1,113 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Core\Hooks;
use Friendica\Core\Hook;
use Friendica\Event\ArrayFilterEvent;
use Friendica\Event\ConfigLoadedEvent;
use Friendica\Event\Event;
use Friendica\Event\HtmlFilterEvent;
use Friendica\Event\NamedEvent;
/**
* Bridge between the EventDispatcher and the Hook class.
*
* @internal Provides BC
*/
final class HookEventBridge
{
/**
* @internal This allows us to mock the Hook call in tests.
*
* @var \Closure|null
*/
private static $mockedCallHook = null;
/**
* This maps the new event names to the legacy Hook names.
*/
private static array $eventMapper = [
Event::INIT => 'init_1',
ConfigLoadedEvent::CONFIG_LOADED => 'load_config',
ArrayFilterEvent::APP_MENU => 'app_menu',
ArrayFilterEvent::NAV_INFO => 'nav_info',
ArrayFilterEvent::FEATURE_ENABLED => 'isEnabled',
ArrayFilterEvent::FEATURE_GET => 'get',
HtmlFilterEvent::HEAD => 'head',
HtmlFilterEvent::FOOTER => 'footer',
HtmlFilterEvent::PAGE_HEADER => 'page_header',
HtmlFilterEvent::PAGE_CONTENT_TOP => 'page_content_top',
HtmlFilterEvent::PAGE_END => 'page_end',
];
/**
* @return array<string, string>
*/
public static function getStaticSubscribedEvents(): array
{
return [
Event::INIT => 'onNamedEvent',
ConfigLoadedEvent::CONFIG_LOADED => 'onConfigLoadedEvent',
ArrayFilterEvent::APP_MENU => 'onArrayFilterEvent',
ArrayFilterEvent::NAV_INFO => 'onArrayFilterEvent',
ArrayFilterEvent::FEATURE_ENABLED => 'onArrayFilterEvent',
ArrayFilterEvent::FEATURE_GET => 'onArrayFilterEvent',
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent',
HtmlFilterEvent::PAGE_CONTENT_TOP => 'onHtmlFilterEvent',
HtmlFilterEvent::PAGE_END => 'onHtmlFilterEvent',
];
}
public static function onNamedEvent(NamedEvent $event): void
{
static::callHook($event->getName(), '');
}
public static function onConfigLoadedEvent(ConfigLoadedEvent $event): void
{
static::callHook($event->getName(), $event->getConfig());
}
public static function onArrayFilterEvent(ArrayFilterEvent $event): void
{
$event->setArray(
static::callHook($event->getName(), $event->getArray())
);
}
public static function onHtmlFilterEvent(HtmlFilterEvent $event): void
{
$event->setHtml(
static::callHook($event->getName(), $event->getHtml())
);
}
/**
* @param string|array|object $data
*
* @return string|array|object
*/
private static function callHook(string $name, $data)
{
// If possible, map the event name to the legacy Hook name
$name = static::$eventMapper[$name] ?? $name;
// Little hack to allow mocking the Hook call in tests.
if (static::$mockedCallHook instanceof \Closure) {
return (static::$mockedCallHook)->__invoke($name, $data);
}
Hook::callAll($name, $data);
return $data;
}
}

View File

@ -8,7 +8,6 @@
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\DI; use Friendica\DI;
use Friendica\Core\Logger\Type\WorkerLogger;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
/** /**
@ -18,10 +17,7 @@ use Psr\Log\LoggerInterface;
*/ */
class Logger class Logger
{ {
/** private static function getInstance(): LoggerInterface
* @return LoggerInterface|WorkerLogger
*/
private static function getInstance()
{ {
return DI::logger(); return DI::logger();
} }
@ -38,6 +34,8 @@ class Logger
*/ */
public static function emergency(string $message, array $context = []) public static function emergency(string $message, array $context = [])
{ {
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
self::getInstance()->emergency($message, $context); self::getInstance()->emergency($message, $context);
} }
@ -55,6 +53,8 @@ class Logger
*/ */
public static function alert(string $message, array $context = []) public static function alert(string $message, array $context = [])
{ {
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
self::getInstance()->alert($message, $context); self::getInstance()->alert($message, $context);
} }
@ -71,6 +71,8 @@ class Logger
*/ */
public static function critical(string $message, array $context = []) public static function critical(string $message, array $context = [])
{ {
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
self::getInstance()->critical($message, $context); self::getInstance()->critical($message, $context);
} }
@ -86,6 +88,8 @@ class Logger
*/ */
public static function error(string $message, array $context = []) public static function error(string $message, array $context = [])
{ {
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
self::getInstance()->error($message, $context); self::getInstance()->error($message, $context);
} }
@ -103,6 +107,8 @@ class Logger
*/ */
public static function warning(string $message, array $context = []) public static function warning(string $message, array $context = [])
{ {
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
self::getInstance()->warning($message, $context); self::getInstance()->warning($message, $context);
} }
@ -117,6 +123,8 @@ class Logger
*/ */
public static function notice(string $message, array $context = []) public static function notice(string $message, array $context = [])
{ {
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
self::getInstance()->notice($message, $context); self::getInstance()->notice($message, $context);
} }
@ -134,6 +142,8 @@ class Logger
*/ */
public static function info(string $message, array $context = []) public static function info(string $message, array $context = [])
{ {
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
self::getInstance()->info($message, $context); self::getInstance()->info($message, $context);
} }
@ -148,6 +158,8 @@ class Logger
*/ */
public static function debug(string $message, array $context = []) public static function debug(string $message, array $context = [])
{ {
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
self::getInstance()->debug($message, $context); self::getInstance()->debug($message, $context);
} }
} }

View File

@ -197,7 +197,7 @@ class ErrorHandler
E_STRICT => LogLevel::NOTICE, E_STRICT => LogLevel::NOTICE,
E_RECOVERABLE_ERROR => LogLevel::ERROR, E_RECOVERABLE_ERROR => LogLevel::ERROR,
E_DEPRECATED => LogLevel::NOTICE, E_DEPRECATED => LogLevel::NOTICE,
E_USER_DEPRECATED => LogLevel::NOTICE, E_USER_DEPRECATED => LogLevel::WARNING,
]; ];
} }
@ -248,17 +248,29 @@ class ErrorHandler
*/ */
public function handleError(int $code, string $message, string $file = '', int $line = 0, ?array $context = []): bool public function handleError(int $code, string $message, string $file = '', int $line = 0, ?array $context = []): bool
{ {
if ($this->handleOnlyReportedErrors && !(error_reporting() & $code)) { if ($this->handleOnlyReportedErrors && !(error_reporting() & $code) && $code !== E_USER_DEPRECATED) {
return true; return true;
} }
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
array_shift($trace); // Exclude handleError from trace
if ($code === E_USER_DEPRECATED && $trace[0]['function'] ?? '' === 'trigger_error') {
$calledPlace = $trace[1] ?? [];
$message .= sprintf(
' It was called in `%s`%s.',
$calledPlace['file'],
isset($calledPlace['line']) ? ' in line ' . $calledPlace['line'] : ''
);
}
// fatal error codes are ignored if a fatal error handler is present as well to avoid duplicate log entries // fatal error codes are ignored if a fatal error handler is present as well to avoid duplicate log entries
if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) { if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) {
$level = $this->errorLevelMap[$code] ?? LogLevel::CRITICAL; $level = $this->errorLevelMap[$code] ?? LogLevel::CRITICAL;
$this->logger->log($level, self::codeToString($code).': '.$message, ['code' => $code, 'message' => $message, 'file' => $file, 'line' => $line]); $this->logger->log($level, self::codeToString($code).': '.$message, ['code' => $code, 'message' => $message, 'file' => $file, 'line' => $line]);
} else { } else {
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
array_shift($trace); // Exclude handleError from trace
$this->lastFatalTrace = $trace; $this->lastFatalTrace = $trace;
} }

View File

@ -8,7 +8,6 @@
namespace Friendica\Core\Storage\Repository; namespace Friendica\Core\Storage\Repository;
use Exception; use Exception;
use Friendica\Core\Addon;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
@ -20,6 +19,7 @@ use Friendica\Core\Storage\Capability\ICanConfigureStorage;
use Friendica\Core\Storage\Capability\ICanWriteToStorage; use Friendica\Core\Storage\Capability\ICanWriteToStorage;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Core\Storage\Type; use Friendica\Core\Storage\Type;
use Friendica\DI;
use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Network\HTTPException\InternalServerErrorException;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@ -84,7 +84,7 @@ class StorageManager
/// @fixme Loading the addons & hooks here is really bad practice, but solves https://github.com/friendica/friendica/issues/11178 /// @fixme Loading the addons & hooks here is really bad practice, but solves https://github.com/friendica/friendica/issues/11178
/// clean solution = Making Addon & Hook dynamic and load them inside the constructor, so there's no custom load logic necessary anymore /// clean solution = Making Addon & Hook dynamic and load them inside the constructor, so there's no custom load logic necessary anymore
if ($includeAddon) { if ($includeAddon) {
Addon::loadAddons(); DI::addonHelper()->loadAddons();
Hook::loadHooks(); Hook::loadHooks();
} }
@ -228,11 +228,13 @@ class StorageManager
*/ */
public function isValidBackend(string $name = null, array $validBackends = null): bool public function isValidBackend(string $name = null, array $validBackends = null): bool
{ {
$validBackends = $validBackends ?? array_merge($this->validBackends, $validBackends = $validBackends ?? array_merge(
$this->validBackends,
[ [
Type\SystemResource::getName(), Type\SystemResource::getName(),
Type\ExternalResource::getName(), Type\ExternalResource::getName(),
]); ]
);
return in_array($name, $validBackends); return in_array($name, $validBackends);
} }

View File

@ -8,6 +8,7 @@
namespace Friendica; namespace Friendica;
use Dice\Dice; use Dice\Dice;
use Friendica\Core\Addon\AddonHelper;
use Friendica\Core\Logger\Capability\ICheckLoggerSettings; use Friendica\Core\Logger\Capability\ICheckLoggerSettings;
use Friendica\Core\Logger\LoggerManager; use Friendica\Core\Logger\LoggerManager;
use Friendica\Core\Logger\Util\LoggerSettingsCheck; use Friendica\Core\Logger\Util\LoggerSettingsCheck;
@ -280,6 +281,11 @@ abstract class DI
return self::$dice->create(Core\Storage\Repository\StorageManager::class); return self::$dice->create(Core\Storage\Repository\StorageManager::class);
} }
public static function addonHelper(): AddonHelper
{
return self::$dice->create(AddonHelper::class);
}
/** /**
* @return \Friendica\Core\System * @return \Friendica\Core\System
*/ */
@ -332,9 +338,16 @@ abstract class DI
*/ */
public static function workerLogger() public static function workerLogger()
{ {
@trigger_error('`' . __METHOD__ . '()` is deprecated since 2025.02 and will be removed after 5 months, use `DI::logger()` instead.', E_USER_DEPRECATED);
return self::$dice->create(Core\Logger\Type\WorkerLogger::class); return self::$dice->create(Core\Logger\Type\WorkerLogger::class);
} }
/**
* @internal Only for use in Friendica\Core\Worker class
*
* @see Friendica\Core\Worker::execFunction()
*/
public static function loggerManager(): LoggerManager public static function loggerManager(): LoggerManager
{ {
return self::$dice->create(LoggerManager::class); return self::$dice->create(LoggerManager::class);
@ -782,4 +795,13 @@ abstract class DI
{ {
return self::$dice->create(Content\Post\Repository\PostMedia::class); return self::$dice->create(Content\Post\Repository\PostMedia::class);
} }
/**
* @internal The EventDispatcher should never called outside of the core, like in addons or themes
* @deprecated 2025.02 Use constructor injection instead
*/
public static function eventDispatcher(): \Psr\EventDispatcher\EventDispatcherInterface
{
return self::$dice->create(\Psr\EventDispatcher\EventDispatcherInterface::class);
}
} }

View File

@ -0,0 +1,45 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Event;
/**
* Allow Event listener to modify an array.
*
* @internal
*/
final class ArrayFilterEvent extends Event
{
public const APP_MENU = 'friendica.data.app_menu';
public const NAV_INFO = 'friendica.data.nav_info';
public const FEATURE_ENABLED = 'friendica.data.feature_enabled';
public const FEATURE_GET = 'friendica.data.feature_get';
private array $array;
public function __construct(string $name, array $array)
{
parent::__construct($name);
$this->array = $array;
}
public function getArray(): array
{
return $this->array;
}
public function setArray(array $array): void
{
$this->array = $array;
}
}

View File

@ -0,0 +1,36 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Event;
use Friendica\Core\Config\Util\ConfigFileManager;
/**
* Notify that the config was loaded
*
* @internal
*/
final class ConfigLoadedEvent extends Event
{
public const CONFIG_LOADED = 'friendica.config_loaded';
private ConfigFileManager $config;
public function __construct(string $name, ConfigFileManager $config)
{
parent::__construct($name);
$this->config = $config;
}
public function getConfig(): ConfigFileManager
{
return $this->config;
}
}

35
src/Event/Event.php Normal file
View File

@ -0,0 +1,35 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Event;
/**
* One-way Event to inform listener about something happend.
*
* @internal
*/
class Event implements NamedEvent
{
/**
* Friendica is initialized.
*/
public const INIT = 'friendica.init';
private string $name;
public function __construct(string $name)
{
$this->name = $name;
}
public function getName(): string
{
return $this->name;
}
}

View File

@ -0,0 +1,37 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Event;
use Symfony\Component\EventDispatcher\EventDispatcher as SymfonyEventDispatcher;
/**
* Modified Event Dispatcher.
*
* @internal
*/
final class EventDispatcher extends SymfonyEventDispatcher
{
/**
* Add support for named events.
*
* @template T of object
* @param T $event
*
* @return T The passed $event MUST be returned
*/
public function dispatch(object $event, ?string $eventName = null): object
{
if ($eventName === null && $event instanceof NamedEvent) {
$eventName = $event->getName();
}
return parent::dispatch($event, $eventName);
}
}

View File

@ -0,0 +1,47 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Event;
/**
* Allow Event listener to modify HTML.
*
* @internal
*/
final class HtmlFilterEvent extends Event
{
public const HEAD = 'friendica.html.head';
public const FOOTER = 'friendica.html.footer';
public const PAGE_HEADER = 'friendica.html.page_header';
public const PAGE_CONTENT_TOP = 'friendica.html.page_content_top';
public const PAGE_END = 'friendica.html.page_end';
private string $html;
public function __construct(string $name, string $html)
{
parent::__construct($name);
$this->html = $html;
}
public function getHtml(): string
{
return $this->html;
}
public function setHtml(string $html): void
{
$this->html = $html;
}
}

20
src/Event/NamedEvent.php Normal file
View File

@ -0,0 +1,20 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Event;
/**
* Interface for named events.
*
* @internal
*/
interface NamedEvent
{
public function getName(): string;
}

View File

@ -10,6 +10,7 @@ namespace Friendica\Model\Contact;
use Exception; use Exception;
use Friendica\Content\Widget; use Friendica\Content\Widget;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Worker;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
@ -22,6 +23,7 @@ use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Worker\AddContact;
/** /**
* This class provides relationship information based on the `contact-relation` table. * This class provides relationship information based on the `contact-relation` table.
@ -162,20 +164,22 @@ class Relation
$following_counter = 0; $following_counter = 0;
DI::logger()->info('Discover contacts', ['id' => $target, 'url' => $url, 'contacts' => count($contacts)]); DI::logger()->info('Discover contacts', ['id' => $target, 'url' => $url, 'contacts' => count($contacts)]);
foreach ($contacts as $contact) { foreach ($contacts as $contact_url) {
$actor = Contact::getIdForURL($contact); $contact = Contact::getByURL($contact_url, false, ['id']);
if (!empty($actor)) { if (!empty($contact['id'])) {
if (in_array($contact, $followers)) { if (in_array($contact_url, $followers)) {
$fields = ['cid' => $target, 'relation-cid' => $actor, 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()]; $fields = ['cid' => $target, 'relation-cid' => $contact['id'], 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()];
DBA::insert('contact-relation', $fields, Database::INSERT_UPDATE); DBA::insert('contact-relation', $fields, Database::INSERT_UPDATE);
$follower_counter++; $follower_counter++;
} }
if (in_array($contact, $followings)) { if (in_array($contact_url, $followings)) {
$fields = ['cid' => $actor, 'relation-cid' => $target, 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()]; $fields = ['cid' => $contact['id'], 'relation-cid' => $target, 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()];
DBA::insert('contact-relation', $fields, Database::INSERT_UPDATE); DBA::insert('contact-relation', $fields, Database::INSERT_UPDATE);
$following_counter++; $following_counter++;
} }
} else {
AddContact::add(Worker::PRIORITY_LOW, 0, $contact_url);
} }
} }

View File

@ -3182,6 +3182,10 @@ class Item
} }
if (!empty($shared_item['uri-id'])) { if (!empty($shared_item['uri-id'])) {
if (!$s) {
DI::logger()->notice('Unexpected empty item HTML', ['item' => $item]);
}
$s = self::replacePlatformIcon($s, $shared_item, $uid); $s = self::replacePlatformIcon($s, $shared_item, $uid);
} }
@ -3258,6 +3262,10 @@ class Item
*/ */
private static function replacePlatformIcon(string $html, array $item, int $uid): string private static function replacePlatformIcon(string $html, array $item, int $uid): string
{ {
if ($html === '') {
return $html;
}
$dom = new \DOMDocument(); $dom = new \DOMDocument();
if (!@$dom->loadHTML($html)) { if (!@$dom->loadHTML($html)) {
return $html; return $html;

View File

@ -10,6 +10,7 @@ namespace Friendica\Model\Post;
use Friendica\Content\PageInfo; use Friendica\Content\PageInfo;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
@ -255,6 +256,7 @@ class Media
private static function isFederatedServer(string $url): bool private static function isFederatedServer(string $url): bool
{ {
try {
$baseurl = Network::getBaseUrl(new Uri($url)); $baseurl = Network::getBaseUrl(new Uri($url));
if (empty($baseurl)) { if (empty($baseurl)) {
return false; return false;
@ -265,6 +267,10 @@ class Media
} }
return DBA::exists('gserver', ['nurl' => Strings::normaliseLink($baseurl), 'network' => Protocol::FEDERATED]); return DBA::exists('gserver', ['nurl' => Strings::normaliseLink($baseurl), 'network' => Protocol::FEDERATED]);
} catch(\Throwable $e) {
DI::logger()->notice('Invalid URL provided', ['url' => $url, 'exception' => $e, 'callstack' => System::callstack(10)]);
return false;
}
} }
private static function addPreviewData(array $media): array private static function addPreviewData(array $media): array
@ -790,7 +796,7 @@ class Media
} }
// Search for links with descriptions // Search for links with descriptions
if (preg_match_all("/\[url\=(https?:.*?)\].*?\[\/url\]/ism", $body, $matches)) { if (preg_match_all("#\[url=(https?://.+?)].+?\[/url]#ism", $body, $matches)) {
foreach ($matches[1] as $url) { foreach ($matches[1] as $url) {
DI::logger()->info('Got page url (link with description)', ['uri-id' => $uriid, 'url' => $url]); DI::logger()->info('Got page url (link with description)', ['uri-id' => $uriid, 'url' => $url]);
$result = self::insert(['uri-id' => $uriid, 'type' => self::UNKNOWN, 'url' => $url], false); $result = self::insert(['uri-id' => $uriid, 'type' => self::UNKNOWN, 'url' => $url], false);

View File

@ -8,7 +8,6 @@
namespace Friendica\Module\Admin\Addons; namespace Friendica\Module\Admin\Addons;
use Friendica\Content\Text\Markdown; use Friendica\Content\Text\Markdown;
use Friendica\Core\Addon;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Module\BaseAdmin; use Friendica\Module\BaseAdmin;
@ -42,12 +41,12 @@ class Details extends BaseAdmin
{ {
parent::content(); parent::content();
$addons_admin = Addon::getAdminList(); $addonHelper = DI::addonHelper();
$addon = Strings::sanitizeFilePathItem($this->parameters['addon']); $addon = Strings::sanitizeFilePathItem($this->parameters['addon']);
if (!is_file("addon/$addon/$addon.php")) { if (!is_file("addon/$addon/$addon.php")) {
DI::sysmsg()->addNotice(DI::l10n()->t('Addon not found.')); DI::sysmsg()->addNotice(DI::l10n()->t('Addon not found.'));
Addon::uninstall($addon); $addonHelper->uninstallAddon($addon);
DI::baseUrl()->redirect('admin/addons'); DI::baseUrl()->redirect('admin/addons');
} }
@ -55,11 +54,11 @@ class Details extends BaseAdmin
self::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_addons_details', 't'); self::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_addons_details', 't');
// Toggle addon status // Toggle addon status
if (Addon::isEnabled($addon)) { if ($addonHelper->isAddonEnabled($addon)) {
Addon::uninstall($addon); $addonHelper->uninstallAddon($addon);
DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s disabled.', $addon)); DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s disabled.', $addon));
} else { } else {
Addon::install($addon); $addonHelper->installAddon($addon);
DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s enabled.', $addon)); DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s enabled.', $addon));
} }
@ -67,7 +66,7 @@ class Details extends BaseAdmin
} }
// display addon details // display addon details
if (Addon::isEnabled($addon)) { if ($addonHelper->isAddonEnabled($addon)) {
$status = 'on'; $status = 'on';
$action = DI::l10n()->t('Disable'); $action = DI::l10n()->t('Disable');
} else { } else {
@ -82,13 +81,17 @@ class Details extends BaseAdmin
$readme = '<pre>' . file_get_contents("addon/$addon/README") . '</pre>'; $readme = '<pre>' . file_get_contents("addon/$addon/README") . '</pre>';
} }
$addons_admin = $addonHelper->getEnabledAddonsWithAdminSettings();
$admin_form = ''; $admin_form = '';
if (array_key_exists($addon, $addons_admin)) { if (in_array($addon, $addons_admin)) {
require_once "addon/$addon/$addon.php"; require_once "addon/$addon/$addon.php";
$func = $addon . '_addon_admin'; $func = $addon . '_addon_admin';
$func($admin_form); $func($admin_form);
} }
$addonInfo = $addonHelper->getAddonInfo($addon);
$t = Renderer::getMarkupTemplate('admin/addons/details.tpl'); $t = Renderer::getMarkupTemplate('admin/addons/details.tpl');
return Renderer::replaceMacros($t, [ return Renderer::replaceMacros($t, [
@ -100,7 +103,13 @@ class Details extends BaseAdmin
'$addon' => $addon, '$addon' => $addon,
'$status' => $status, '$status' => $status,
'$action' => $action, '$action' => $action,
'$info' => Addon::getInfo($addon), '$info' => [
'name' => $addonInfo->getName(),
'version' => $addonInfo->getVersion(),
'description' => $addonInfo->getDescription(),
'author' => $addonInfo->getAuthors(),
'maintainer' => $addonInfo->getMaintainers(),
],
'$str_author' => DI::l10n()->t('Author: '), '$str_author' => DI::l10n()->t('Author: '),
'$str_maintainer' => DI::l10n()->t('Maintainer: '), '$str_maintainer' => DI::l10n()->t('Maintainer: '),

View File

@ -7,7 +7,6 @@
namespace Friendica\Module\Admin\Addons; namespace Friendica\Module\Admin\Addons;
use Friendica\Core\Addon;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Module\BaseAdmin; use Friendica\Module\BaseAdmin;
@ -24,22 +23,25 @@ class Index extends BaseAdmin
{ {
parent::content(); parent::content();
$addonHelper = DI::addonHelper();
// reload active themes // reload active themes
if (!empty($_GET['action'])) { if (!empty($_GET['action'])) {
self::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_addons', 't'); self::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_addons', 't');
switch ($_GET['action']) { switch ($_GET['action']) {
case 'reload': case 'reload':
Addon::reload(); $addonHelper->reloadAddons();
DI::sysmsg()->addInfo(DI::l10n()->t('Addons reloaded')); DI::sysmsg()->addInfo(DI::l10n()->t('Addons reloaded'));
break; break;
case 'toggle' : case 'toggle':
$addon = $_GET['addon'] ?? ''; $addon = $_GET['addon'] ?? '';
if (Addon::isEnabled($addon)) {
Addon::uninstall($addon); if ($addonHelper->isAddonEnabled($addon)) {
$addonHelper->uninstallAddon($addon);
DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s disabled.', $addon)); DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s disabled.', $addon));
} elseif (Addon::install($addon)) { } elseif ($addonHelper->installAddon($addon)) {
DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s enabled.', $addon)); DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s enabled.', $addon));
} else { } else {
DI::sysmsg()->addNotice(DI::l10n()->t('Addon %s failed to install.', $addon)); DI::sysmsg()->addNotice(DI::l10n()->t('Addon %s failed to install.', $addon));
@ -52,7 +54,23 @@ class Index extends BaseAdmin
DI::baseUrl()->redirect('admin/addons'); DI::baseUrl()->redirect('admin/addons');
} }
$addons = Addon::getAvailableList(); $addons = [];
foreach ($addonHelper->getAvailableAddons() as $addonId) {
$addonInfo = $addonHelper->getAddonInfo($addonId);
$info = [
'name' => $addonInfo->getName(),
'description' => $addonInfo->getDescription(),
'version' => $addonInfo->getVersion(),
];
$addons[] = [
$addonId,
($addonHelper->isAddonEnabled($addonId) ? 'on' : 'off'),
$info,
];
}
$t = Renderer::getMarkupTemplate('admin/addons/index.tpl'); $t = Renderer::getMarkupTemplate('admin/addons/index.tpl');
return Renderer::replaceMacros($t, [ return Renderer::replaceMacros($t, [

View File

@ -8,7 +8,6 @@
namespace Friendica\Module\Admin; namespace Friendica\Module\Admin;
use Friendica\App; use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config\ValueObject\Cache; use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Update; use Friendica\Core\Update;
@ -28,6 +27,7 @@ class Summary extends BaseAdmin
parent::content(); parent::content();
$basePath = DI::appHelper()->getBasePath(); $basePath = DI::appHelper()->getBasePath();
$addonPath = DI::addonHelper()->getAddonPath();
// are there MyISAM tables in the DB? If so, trigger a warning message // are there MyISAM tables in the DB? If so, trigger a warning message
$warningtext = []; $warningtext = [];
@ -101,8 +101,12 @@ class Summary extends BaseAdmin
// Check server vitality // Check server vitality
if (!self::checkSelfHostMeta()) { if (!self::checkSelfHostMeta()) {
$well_known = DI::baseUrl() . Probe::HOST_META; $well_known = DI::baseUrl() . Probe::HOST_META;
$warningtext[] = DI::l10n()->t('<a href="%s">%s</a> is not reachable on your system. This is a severe configuration issue that prevents server to server communication. See <a href="%s">the installation page</a> for help.', $warningtext[] = DI::l10n()->t(
$well_known, $well_known, DI::baseUrl() . '/help/Install'); '<a href="%s">%s</a> is not reachable on your system. This is a severe configuration issue that prevents server to server communication. See <a href="%s">the installation page</a> for help.',
$well_known,
$well_known,
DI::baseUrl() . '/help/Install'
);
} }
// Check logfile permission // Check logfile permission
@ -114,7 +118,7 @@ class Summary extends BaseAdmin
} }
// check legacy basepath settings // check legacy basepath settings
$configLoader = (new Config())->createConfigFileManager($basePath, $_SERVER); $configLoader = (new Config())->createConfigFileManager($basePath, $addonPath, $_SERVER);
$configCache = new Cache(); $configCache = new Cache();
$configLoader->setupCache($configCache); $configLoader->setupCache($configCache);
$confBasepath = $configCache->get('system', 'basepath'); $confBasepath = $configCache->get('system', 'basepath');
@ -125,25 +129,31 @@ class Summary extends BaseAdmin
'from' => $currBasepath, 'from' => $currBasepath,
'to' => $confBasepath, 'to' => $confBasepath,
]); ]);
$warningtext[] = DI::l10n()->t('Friendica\'s system.basepath was updated from \'%s\' to \'%s\'. Please remove the system.basepath from your db to avoid differences.', $warningtext[] = DI::l10n()->t(
'Friendica\'s system.basepath was updated from \'%s\' to \'%s\'. Please remove the system.basepath from your db to avoid differences.',
$currBasepath, $currBasepath,
$confBasepath); $confBasepath
);
} elseif (!is_dir($currBasepath)) { } elseif (!is_dir($currBasepath)) {
DI::logger()->alert('Friendica\'s system.basepath is wrong.', [ DI::logger()->alert('Friendica\'s system.basepath is wrong.', [
'from' => $currBasepath, 'from' => $currBasepath,
'to' => $confBasepath, 'to' => $confBasepath,
]); ]);
$warningtext[] = DI::l10n()->t('Friendica\'s current system.basepath \'%s\' is wrong and the config file \'%s\' isn\'t used.', $warningtext[] = DI::l10n()->t(
'Friendica\'s current system.basepath \'%s\' is wrong and the config file \'%s\' isn\'t used.',
$currBasepath, $currBasepath,
$confBasepath); $confBasepath
);
} else { } else {
DI::logger()->alert('Friendica\'s system.basepath is wrong.', [ DI::logger()->alert('Friendica\'s system.basepath is wrong.', [
'from' => $currBasepath, 'from' => $currBasepath,
'to' => $confBasepath, 'to' => $confBasepath,
]); ]);
$warningtext[] = DI::l10n()->t('Friendica\'s current system.basepath \'%s\' is not equal to the config file \'%s\'. Please fix your configuration.', $warningtext[] = DI::l10n()->t(
'Friendica\'s current system.basepath \'%s\' is not equal to the config file \'%s\'. Please fix your configuration.',
$currBasepath, $currBasepath,
$confBasepath); $confBasepath
);
} }
} }
@ -177,7 +187,7 @@ class Summary extends BaseAdmin
'$platform' => App::PLATFORM, '$platform' => App::PLATFORM,
'$codename' => App::CODENAME, '$codename' => App::CODENAME,
'$build' => DI::config()->get('system', 'build'), '$build' => DI::config()->get('system', 'build'),
'$addons' => [DI::l10n()->t('Active addons'), Addon::getEnabledList()], '$addons' => [DI::l10n()->t('Active addons'), DI::addonHelper()->getEnabledAddons()],
'$serversettings' => $server_settings, '$serversettings' => $server_settings,
'$warningtext' => $warningtext, '$warningtext' => $warningtext,
]); ]);

View File

@ -8,7 +8,6 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\Addon;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
@ -98,9 +97,19 @@ abstract class BaseAdmin extends BaseModule
]], ]],
]; ];
$addons_admin = [];
foreach (DI::addonHelper()->getEnabledAddonsWithAdminSettings() as $addonId) {
$addons_admin[$addonId] = [
'url' => 'admin/addons/' . $addonId,
'name' => $addonId,
'class' => 'addon',
];
}
$t = Renderer::getMarkupTemplate('admin/aside.tpl'); $t = Renderer::getMarkupTemplate('admin/aside.tpl');
DI::page()['aside'] .= Renderer::replaceMacros($t, [ DI::page()['aside'] .= Renderer::replaceMacros($t, [
'$admin' => ['addons_admin' => Addon::getAdminList()], '$admin' => ['addons_admin' => $addons_admin],
'$subpages' => $aside_sub, '$subpages' => $aside_sub,
'$admtxt' => DI::l10n()->t('Admin'), '$admtxt' => DI::l10n()->t('Admin'),
'$plugadmtxt' => DI::l10n()->t('Addon Features'), '$plugadmtxt' => DI::l10n()->t('Addon Features'),

View File

@ -134,6 +134,6 @@ class BaseProfile extends BaseModule
$tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); $tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs']]); return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs'], '$more' => DI::l10n()->t('More')]);
} }
} }

View File

@ -154,7 +154,7 @@ class BaseSettings extends BaseModule
$tabs[] = [ $tabs[] = [
'label' => $this->t('Import Contacts'), 'label' => $this->t('Import Contacts'),
'url' => 'settings/importcontacts', 'url' => 'settings/importcontacts',
'selected' => static::class == Settings\UserExport::class ? 'active' : '', 'selected' => static::class == Settings\ContactImport::class ? 'active' : '',
'accesskey' => '', 'accesskey' => '',
]; ];

View File

@ -21,7 +21,6 @@ use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\Theme; use Friendica\Core\Theme;
use Friendica\Model\Event; use Friendica\Model\Event;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Module\BaseProfile; use Friendica\Module\BaseProfile;
use Friendica\Module\Response; use Friendica\Module\Response;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
@ -119,6 +118,8 @@ class Show extends BaseModule
'$week' => $this->t('week'), '$week' => $this->t('week'),
'$day' => $this->t('day'), '$day' => $this->t('day'),
'$list' => $this->t('list'), '$list' => $this->t('list'),
'$prev' => $this->t('prev'),
'$next' => $this->t('next'),
]); ]);
return $o; return $o;

View File

@ -387,7 +387,7 @@ class Contact extends BaseModule
]; ];
$tabs_tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); $tabs_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
$tabs_html = Renderer::replaceMacros($tabs_tpl, ['$tabs' => $tabs]); $tabs_html = Renderer::replaceMacros($tabs_tpl, ['$tabs' => $tabs, '$more' => DI::l10n()->t('More')]);
switch ($rel) { switch ($rel) {
case 'followers': case 'followers':
@ -534,7 +534,7 @@ class Contact extends BaseModule
} }
$tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); $tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
$tab_str = Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]); $tab_str = Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs, '$more' => DI::l10n()->t('More')]);
return $tab_str; return $tab_str;
} }

View File

@ -95,7 +95,7 @@ class Channel extends Timeline
$tabs = array_merge($tabs, $this->getTabArray($this->community->getTimelines(true), 'channel')); $tabs = array_merge($tabs, $this->getTabArray($this->community->getTimelines(true), 'channel'));
$tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); $tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
$o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]); $o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs, '$more' => $this->l10n->t('More')]);
Nav::setSelected('channel'); Nav::setSelected('channel');

View File

@ -88,7 +88,7 @@ class Community extends Timeline
if (!$this->raw) { if (!$this->raw) {
$tabs = $this->getTabArray($this->community->getTimelines($this->session->isAuthenticated()), 'community'); $tabs = $this->getTabArray($this->community->getTimelines($this->session->isAuthenticated()), 'community');
$tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); $tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
$o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]); $o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs, '$more' => $this->l10n->t('More')]);
Nav::setSelected('community'); Nav::setSelected('community');

View File

@ -292,7 +292,7 @@ class Network extends Timeline
$tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); $tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
return Renderer::replaceMacros($tpl, ['$tabs' => $tabs]); return Renderer::replaceMacros($tpl, ['$tabs' => $tabs, '$more' => $this->l10n->t('More')]);
} }
protected function parseRequest(array $request) protected function parseRequest(array $request)
@ -344,6 +344,7 @@ class Network extends Timeline
// since otherwise the feed will optically jump, when some already visible thread has been updated. // since otherwise the feed will optically jump, when some already visible thread has been updated.
if ($this->update && ($this->selectedTab == NetworkEntity::COMMENTED)) { if ($this->update && ($this->selectedTab == NetworkEntity::COMMENTED)) {
$this->order = 'received'; $this->order = 'received';
$request['last_received'] = $request['last_commented'] ?? null; $request['last_received'] = $request['last_commented'] ?? null;
$request['first_received'] = $request['first_commented'] ?? null; $request['first_received'] = $request['first_commented'] ?? null;
} }

View File

@ -691,13 +691,16 @@ class Timeline extends BaseModule
$items = $this->selectItems(); $items = $this->selectItems();
$key = ''; $key = '';
$maxpostperauthor = 0;
if ($this->selectedTab == Community::LOCAL) { if ($this->selectedTab == Community::LOCAL) {
$maxpostperauthor = (int)$this->config->get('system', 'max_author_posts_community_page'); $maxpostperauthor = (int)$this->config->get('system', 'max_author_posts_community_page');
$key = 'author-id'; $key = 'author-id';
} elseif ($this->selectedTab == Community::GLOBAL) { } elseif ($this->selectedTab == Community::GLOBAL) {
$maxpostperauthor = (int)$this->config->get('system', 'max_server_posts_community_page'); $maxpostperauthor = (int)$this->config->get('system', 'max_server_posts_community_page');
$key = 'author-gsid'; $key = 'author-gsid';
} else { }
if ($maxpostperauthor === 0) {
$this->setItemsSeenByCondition([ $this->setItemsSeenByCondition([
'unseen' => true, 'unseen' => true,
'uid' => $this->session->getLocalUserId(), 'uid' => $this->session->getLocalUserId(),

View File

@ -56,7 +56,7 @@ class SaveTag extends BaseModule
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl"); $tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
echo Renderer::replaceMacros($tpl, [ echo Renderer::replaceMacros($tpl, [
'$field' => ['term', $this->t("Save to Folder:"), '', '', $filetags, $this->t('- select -')], '$field' => ['term', $this->t("Folder:"), '', '', $filetags, $this->t('- select -')],
'$submit' => $this->t('Save'), '$submit' => $this->t('Save'),
]); ]);

View File

@ -11,7 +11,7 @@ use Friendica\App;
use Friendica\App\Arguments; use Friendica\App\Arguments;
use Friendica\App\BaseURL; use Friendica\App\BaseURL;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\Addon; use Friendica\Core\Addon\AddonHelper;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs; use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
@ -31,6 +31,7 @@ use Psr\Log\LoggerInterface;
*/ */
class Friendica extends BaseModule class Friendica extends BaseModule
{ {
private AddonHelper $addonHelper;
/** @var IManageConfigValues */ /** @var IManageConfigValues */
private $config; private $config;
/** @var IManageKeyValuePairs */ /** @var IManageKeyValuePairs */
@ -38,18 +39,19 @@ class Friendica extends BaseModule
/** @var IHandleUserSessions */ /** @var IHandleUserSessions */
private $session; private $session;
public function __construct(IHandleUserSessions $session, IManageKeyValuePairs $keyValue, IManageConfigValues $config, L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) public function __construct(AddonHelper $addonHelper, IHandleUserSessions $session, IManageKeyValuePairs $keyValue, IManageConfigValues $config, L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{ {
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->config = $config; $this->config = $config;
$this->keyValue = $keyValue; $this->keyValue = $keyValue;
$this->session = $session; $this->session = $session;
$this->addonHelper = $addonHelper;
} }
protected function content(array $request = []): string protected function content(array $request = []): string
{ {
$visibleAddonList = Addon::getVisibleList(); $visibleAddonList = $this->addonHelper->getVisibleEnabledAddons();
if (!empty($visibleAddonList)) { if (!empty($visibleAddonList)) {
$sorted = $visibleAddonList; $sorted = $visibleAddonList;
@ -102,11 +104,13 @@ class Friendica extends BaseModule
$tpl = Renderer::getMarkupTemplate('friendica.tpl'); $tpl = Renderer::getMarkupTemplate('friendica.tpl');
return Renderer::replaceMacros($tpl, [ return Renderer::replaceMacros($tpl, [
'about' => $this->t('This is Friendica, version %s that is running at the web location %s. The database version is %s, the post update version is %s.', 'about' => $this->t(
'This is Friendica, version %s that is running at the web location %s. The database version is %s, the post update version is %s.',
'<strong>' . App::VERSION . '</strong>', '<strong>' . App::VERSION . '</strong>',
$this->baseUrl, $this->baseUrl,
'<strong>' . $this->config->get('system', 'build') . '/' . DB_UPDATE_VERSION . '</strong>', '<strong>' . $this->config->get('system', 'build') . '/' . DB_UPDATE_VERSION . '</strong>',
'<strong>' . $this->keyValue->get('post_update_version') . '/' . PostUpdate::VERSION . '</strong>'), '<strong>' . $this->keyValue->get('post_update_version') . '/' . PostUpdate::VERSION . '</strong>'
),
'friendica' => $this->t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.'), 'friendica' => $this->t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.'),
'bugs' => $this->t('Bug reports and issues: please visit') . ' ' . '<a href="https://github.com/friendica/friendica/issues?state=open">' . $this->t('the bugtracker at github') . '</a>', 'bugs' => $this->t('Bug reports and issues: please visit') . ' ' . '<a href="https://github.com/friendica/friendica/issues?state=open">' . $this->t('the bugtracker at github') . '</a>',
'info' => $this->t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca'), 'info' => $this->t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca'),
@ -157,7 +161,7 @@ class Friendica extends BaseModule
]; ];
} }
$visible_addons = Addon::getVisibleList(); $visible_addons = $this->addonHelper->getVisibleEnabledAddons();
$this->config->reload(); $this->config->reload();
$locked_features = []; $locked_features = [];

View File

@ -235,22 +235,22 @@ class Install extends BaseModule
'$system_url' => $this->configCache->get('system', 'url'), '$system_url' => $this->configCache->get('system', 'url'),
'$dbhost' => ['database-hostname', '$dbhost' => ['database-hostname',
$this->t('Database Server Name'), $this->t('Database Server Name'),
$this->configCache->get('database', 'hostname'), $this->configCache->get('database', 'hostname') ? : getenv('MYSQL_HOST') ? : 'localhost',
'', '',
$this->t('Required')], $this->t('Required')],
'$dbuser' => ['database-username', '$dbuser' => ['database-username',
$this->t('Database Login Name'), $this->t('Database Login Name'),
$this->configCache->get('database', 'username'), $this->configCache->get('database', 'username') ? : getenv('MYSQL_USER') ? : '',
'', '',
$this->t('Required'), $this->t('Required'),
'autofocus'], 'autofocus'],
'$dbpass' => ['database-password', '$dbpass' => ['database-password',
$this->t('Database Login Password'), $this->t('Database Login Password'),
$this->configCache->get('database', 'password'), $this->configCache->get('database', 'password') ? : getenv('MYSQL_PASSWORD') ? : '',
$this->t("For security reasons the password must not be empty"), $this->t("For security reasons the password must not be empty"),
$this->t('Required')], $this->t('Required')],
'$dbdata' => ['database-database', '$dbdata' => ['database-database',
$this->t('Database Name'), $this->t('Database Name') ? : getenv('MYSQL_DATABASE') ? : '',
$this->configCache->get('database', 'database'), $this->configCache->get('database', 'database'),
'', '',
$this->t('Required')], $this->t('Required')],

View File

@ -99,7 +99,7 @@ abstract class BaseUsers extends BaseModeration
Hook::callAll('moderation_users_tabs', $tabs_arr); Hook::callAll('moderation_users_tabs', $tabs_arr);
$tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); $tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
return Renderer::replaceMacros($tpl, ['$tabs' => $tabs_arr['tabs']]); return Renderer::replaceMacros($tpl, ['$tabs' => $tabs_arr['tabs'], '$more' => $this->t('More')]);
} }
protected function setupUserCallback(): \Closure protected function setupUserCallback(): \Closure

View File

@ -124,8 +124,8 @@ class Active extends BaseUsers
*/ */
private function processGetActions(): void private function processGetActions(): void
{ {
$action = (string)$this->parameters['action'] ?? ''; $action = (string) ($this->parameters['action'] ?? '');
$uid = (int)$this->parameters['uid'] ?? 0; $uid = (int) ($this->parameters['uid'] ?? 0);
if ($uid === 0) { if ($uid === 0) {
return; return;
@ -150,6 +150,7 @@ class Active extends BaseUsers
} }
$this->baseUrl->redirect('moderation/users/active'); $this->baseUrl->redirect('moderation/users/active');
// no break
case 'block': case 'block':
self::checkFormSecurityTokenRedirectOnError('moderation/users/active', 'moderation_users_active', 't'); self::checkFormSecurityTokenRedirectOnError('moderation/users/active', 'moderation_users_active', 't');
User::block($uid); User::block($uid);

View File

@ -123,8 +123,8 @@ class Blocked extends BaseUsers
*/ */
private function processGetActions(): void private function processGetActions(): void
{ {
$action = (string)$this->parameters['action'] ?? ''; $action = (string) ($this->parameters['action'] ?? '');
$uid = (int)$this->parameters['uid'] ?? 0; $uid = (int) ($this->parameters['uid'] ?? 0);
if ($uid === 0) { if ($uid === 0) {
return; return;
@ -148,6 +148,7 @@ class Blocked extends BaseUsers
$this->systemMessages->addNotice($this->t('You can\'t remove yourself')); $this->systemMessages->addNotice($this->t('You can\'t remove yourself'));
} }
$this->baseUrl->redirect('moderation/users/blocked'); $this->baseUrl->redirect('moderation/users/blocked');
// no break
case 'unblock': case 'unblock':
self::checkFormSecurityTokenRedirectOnError('/moderation/users/blocked', 'moderation_users_blocked', 't'); self::checkFormSecurityTokenRedirectOnError('/moderation/users/blocked', 'moderation_users_blocked', 't');
User::block($uid, false); User::block($uid, false);

View File

@ -135,8 +135,8 @@ class Index extends BaseUsers
*/ */
private function processGetActions(): void private function processGetActions(): void
{ {
$action = (string) $this->parameters['action'] ?? ''; $action = (string) ($this->parameters['action'] ?? '');
$uid = (int) $this->parameters['uid'] ?? 0; $uid = (int) ($this->parameters['uid'] ?? 0);
if ($uid === 0) { if ($uid === 0) {
return; return;
@ -161,11 +161,13 @@ class Index extends BaseUsers
} }
$this->baseUrl->redirect('moderation/users'); $this->baseUrl->redirect('moderation/users');
// no break
case 'block': case 'block':
self::checkFormSecurityTokenRedirectOnError('moderation/users', 'moderation_users', 't'); self::checkFormSecurityTokenRedirectOnError('moderation/users', 'moderation_users', 't');
User::block($uid); User::block($uid);
$this->systemMessages->addNotice($this->t('User "%s" blocked', $user['username'])); $this->systemMessages->addNotice($this->t('User "%s" blocked', $user['username']));
$this->baseUrl->redirect('moderation/users'); $this->baseUrl->redirect('moderation/users');
// no break
case 'unblock': case 'unblock':
self::checkFormSecurityTokenRedirectOnError('moderation/users', 'moderation_users', 't'); self::checkFormSecurityTokenRedirectOnError('moderation/users', 'moderation_users', 't');
User::block($uid, false); User::block($uid, false);

View File

@ -148,8 +148,8 @@ class Register extends BaseModule
'$fillext' => $fillext, '$fillext' => $fillext,
'$oidlabel' => $oidlabel, '$oidlabel' => $oidlabel,
'$openid' => $openid_url, '$openid' => $openid_url,
'$namelabel' => DI::l10n()->t('Your Display Name (as you would like it to be displayed on this system'), '$namelabel' => DI::l10n()->t('Your Display Name (as you would like it to be displayed on this system):'),
'$addrlabel' => DI::l10n()->t('Your Email Address: (Initial information will be send there, so this has to be an existing address.)'), '$addrlabel' => DI::l10n()->t('Your Email Address (initial information will be sent there, so this must be a valid address):'),
'$addrlabel2' => DI::l10n()->t('Please repeat your e-mail address:'), '$addrlabel2' => DI::l10n()->t('Please repeat your e-mail address:'),
'$ask_password' => $ask_password, '$ask_password' => $ask_password,
'$password1' => ['password1', DI::l10n()->t('New Password:'), '', DI::l10n()->t('Leave empty for an auto generated password.')], '$password1' => ['password1', DI::l10n()->t('New Password:'), '', DI::l10n()->t('Leave empty for an auto generated password.')],

View File

@ -185,7 +185,7 @@ class Channels extends BaseSettings
'image' => ["image[$channel->code]", $this->t("Images"), $channel->mediaType & 1], 'image' => ["image[$channel->code]", $this->t("Images"), $channel->mediaType & 1],
'video' => ["video[$channel->code]", $this->t("Videos"), $channel->mediaType & 2], 'video' => ["video[$channel->code]", $this->t("Videos"), $channel->mediaType & 2],
'audio' => ["audio[$channel->code]", $this->t("Audio"), $channel->mediaType & 4], 'audio' => ["audio[$channel->code]", $this->t("Audio"), $channel->mediaType & 4],
'languages' => ["languages[$channel->code][]", $this->t('Languages'), $channel->languages ?? $channel_languages, $this->t('Select all languages that you want to see in this channel.'), $languages, 'multiple'], 'languages' => ["languages[$channel->code][]", $this->t('Languages'), $channel->languages ?? $channel_languages, $this->t('Select all languages that you want to see in this channel. "Unspecified" describes all posts for which no language information was detected (e.g. posts with just an image or too little text to be sure of the language). If you want to see all languages, you will need to select all items in the list.'), $languages, 'multiple'],
'publish' => $publish, 'publish' => $publish,
'delete' => ["delete[$channel->code]", $this->t("Delete channel") . ' (' . $channel->label . ')', false, $this->t("Check to delete this entry from the channel list")] 'delete' => ["delete[$channel->code]", $this->t("Delete channel") . ' (' . $channel->label . ')', false, $this->t("Check to delete this entry from the channel list")]
]; ];

View File

@ -103,13 +103,7 @@ class Display extends BaseSettings
$show_page_drop = (bool)$request['show_page_drop']; $show_page_drop = (bool)$request['show_page_drop'];
$display_eventlist = (bool)$request['display_eventlist']; $display_eventlist = (bool)$request['display_eventlist'];
$preview_mode = (int)$request['preview_mode']; $preview_mode = (int)$request['preview_mode'];
$browser_update = (int)$request['browser_update']; $update_content = (int)$request['update_content'];
if ($browser_update != -1) {
$browser_update = $browser_update * 1000;
if ($browser_update < 10000) {
$browser_update = 10000;
}
}
$enabled_timelines = []; $enabled_timelines = [];
foreach ($enable as $code => $enabled) { foreach ($enable as $code => $enabled) {
@ -144,7 +138,7 @@ class Display extends BaseSettings
$this->pConfig->set($uid, 'system', 'itemspage_network', $itemspage_network); $this->pConfig->set($uid, 'system', 'itemspage_network', $itemspage_network);
$this->pConfig->set($uid, 'system', 'itemspage_mobile_network', $itemspage_mobile_network); $this->pConfig->set($uid, 'system', 'itemspage_mobile_network', $itemspage_mobile_network);
$this->pConfig->set($uid, 'system', 'update_interval', $browser_update); $this->pConfig->set($uid, 'system', 'update_content', $update_content);
$this->pConfig->set($uid, 'system', 'no_smilies', !$enable_smile); $this->pConfig->set($uid, 'system', 'no_smilies', !$enable_smile);
$this->pConfig->set($uid, 'system', 'infinite_scroll', $infinite_scroll); $this->pConfig->set($uid, 'system', 'infinite_scroll', $infinite_scroll);
$this->pConfig->set($uid, 'system', 'no_smart_threading', !$enable_smart_threading); $this->pConfig->set($uid, 'system', 'no_smart_threading', !$enable_smart_threading);
@ -238,11 +232,7 @@ class Display extends BaseSettings
$itemspage_mobile_network = intval($this->pConfig->get($uid, 'system', 'itemspage_mobile_network')); $itemspage_mobile_network = intval($this->pConfig->get($uid, 'system', 'itemspage_mobile_network'));
$itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : $this->config->get('system', 'itemspage_network_mobile')); $itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : $this->config->get('system', 'itemspage_network_mobile'));
$browser_update = intval($this->pConfig->get($uid, 'system', 'update_interval')); $update_content = $this->pConfig->get($uid, 'system', 'update_content') ?? false;
if ($browser_update != -1) {
$browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
}
$enable_smile = !$this->pConfig->get($uid, 'system', 'no_smilies', false); $enable_smile = !$this->pConfig->get($uid, 'system', 'no_smilies', false);
$infinite_scroll = $this->pConfig->get($uid, 'system', 'infinite_scroll', false); $infinite_scroll = $this->pConfig->get($uid, 'system', 'infinite_scroll', false);
$enable_smart_threading = !$this->pConfig->get($uid, 'system', 'no_smart_threading', false); $enable_smart_threading = !$this->pConfig->get($uid, 'system', 'no_smart_threading', false);
@ -332,7 +322,7 @@ class Display extends BaseSettings
'$itemspage_network' => ['itemspage_network', $this->t('Number of items to display per page:'), $itemspage_network, $this->t('Maximum of 100 items')], '$itemspage_network' => ['itemspage_network', $this->t('Number of items to display per page:'), $itemspage_network, $this->t('Maximum of 100 items')],
'$itemspage_mobile_network' => ['itemspage_mobile_network', $this->t('Number of items to display per page when viewed from mobile device:'), $itemspage_mobile_network, $this->t('Maximum of 100 items')], '$itemspage_mobile_network' => ['itemspage_mobile_network', $this->t('Number of items to display per page when viewed from mobile device:'), $itemspage_mobile_network, $this->t('Maximum of 100 items')],
'$ajaxint' => ['browser_update', $this->t('Update browser every xx seconds'), $browser_update, $this->t('Minimum of 10 seconds. Enter -1 to disable it.')], '$update_content' => ['update_content', $this->t('Regularly update the page content'), $update_content, $this->t('When enabled, new content on network, community and channels are added on top.')],
'$enable_smile' => ['enable_smile', $this->t('Display emoticons'), $enable_smile, $this->t('When enabled, emoticons are replaced with matching symbols.')], '$enable_smile' => ['enable_smile', $this->t('Display emoticons'), $enable_smile, $this->t('When enabled, emoticons are replaced with matching symbols.')],
'$infinite_scroll' => ['infinite_scroll', $this->t('Infinite scroll'), $infinite_scroll, $this->t('Automatic fetch new items when reaching the page end.')], '$infinite_scroll' => ['infinite_scroll', $this->t('Infinite scroll'), $infinite_scroll, $this->t('Automatic fetch new items when reaching the page end.')],
'$enable_smart_threading' => ['enable_smart_threading', $this->t('Enable Smart Threading'), $enable_smart_threading, $this->t('Enable the automatic suppression of extraneous thread indentation.')], '$enable_smart_threading' => ['enable_smart_threading', $this->t('Enable Smart Threading'), $enable_smart_threading, $this->t('Enable the automatic suppression of extraneous thread indentation.')],
@ -353,7 +343,7 @@ class Display extends BaseSettings
'$timelines' => $timelines, '$timelines' => $timelines,
'$timeline_explanation' => $this->t('Enable timelines that you want to see in the channels widget. Bookmark timelines that you want to see in the top menu.'), '$timeline_explanation' => $this->t('Enable timelines that you want to see in the channels widget. Bookmark timelines that you want to see in the top menu.'),
'$channel_languages' => ['channel_languages[]', $this->t('Channel languages:'), $channel_languages, $this->t('Select all languages that you want to see in your channels.'), $languages, 'multiple'], '$channel_languages' => ['channel_languages[]', $this->t('Channel languages:'), $channel_languages, $this->t('Select all the languages you want to see in your channels. "Unspecified" describes all posts for which no language information was detected (e.g. posts with just an image or too little text to be sure of the language). If you want to see all languages, you will need to select all items in the list.'), $languages, 'multiple'],
'$first_day_of_week' => ['first_day_of_week', $this->t('Beginning of week:'), $first_day_of_week, '', $weekdays, false], '$first_day_of_week' => ['first_day_of_week', $this->t('Beginning of week:'), $first_day_of_week, '', $weekdays, false],
'$calendar_default_view' => ['calendar_default_view', $this->t('Default calendar view:'), $calendar_default_view, '', $calendarViews, false], '$calendar_default_view' => ['calendar_default_view', $this->t('Default calendar view:'), $calendar_default_view, '', $calendarViews, false],

View File

@ -45,19 +45,16 @@ class Display extends DisplayModule
$parentUriId = $item['parent-uri-id']; $parentUriId = $item['parent-uri-id'];
if (empty($force)) { if (empty($force)) {
$browserUpdate = intval($this->pConfig->get($profileUid, 'system', 'update_interval') ?? 40000); if ($this->pConfig->get($profileUid, 'system', 'update_content')) {
if ($browserUpdate >= 1000) { $updateDate = date(DateTimeFormat::MYSQL, time() - 120);
$updateDate = date(DateTimeFormat::MYSQL, time() - ($browserUpdate * 2 / 1000));
if (!Post::exists([ if (!Post::exists([
"`parent-uri-id` = ? AND `uid` IN (?, ?) AND `received` > ?", "`parent-uri-id` = ? AND `uid` IN (?, ?) AND `received` > ?",
$parentUriId, 0, $parentUriId, 0,
$profileUid, $updateDate])) { $profileUid, $updateDate])) {
$this->logger->debug('No updated content. Ending process', $this->logger->debug('No updated content. Ending process', ['uri-id' => $uriId, 'uid' => $profileUid, 'updated' => $updateDate]);
['uri-id' => $uriId, 'uid' => $profileUid, 'updated' => $updateDate]);
return ''; return '';
} else { } else {
$this->logger->debug('Updated content found.', $this->logger->debug('Updated content found.', ['uri-id' => $uriId, 'uid' => $profileUid, 'updated' => $updateDate]);
['uri-id' => $uriId, 'uid' => $profileUid, 'updated' => $updateDate]);
} }
} }
} else { } else {

View File

@ -15,7 +15,6 @@ use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Factory\Api\Mastodon\Notification as NotificationFactory; use Friendica\Factory\Api\Mastodon\Notification as NotificationFactory;
@ -205,7 +204,7 @@ class Notify extends BaseRepository
* @return bool * @return bool
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
function createFromArray($params) public function createFromArray($params)
{ {
/** @var string the common prefix of a notification subject */ /** @var string the common prefix of a notification subject */
$subjectPrefix = $this->l10n->t('[Friendica:Notify]'); $subjectPrefix = $this->l10n->t('[Friendica:Notify]');
@ -340,7 +339,8 @@ class Notify extends BaseRepository
$subject = $l10n->t('%s %s posted to your profile wall', $subjectPrefix, $params['source_name']); $subject = $l10n->t('%s %s posted to your profile wall', $subjectPrefix, $params['source_name']);
$preamble = $l10n->t('%1$s posted to your profile wall at %2$s', $params['source_name'], $sitename); $preamble = $l10n->t('%1$s posted to your profile wall at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('%1$s posted to [url=%2$s]your wall[/url]', $epreamble = $l10n->t(
'%1$s posted to [url=%2$s]your wall[/url]',
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]', '[url='.$params['source_link'].']'.$params['source_name'].'[/url]',
$params['link'] $params['link']
); );
@ -356,7 +356,8 @@ class Notify extends BaseRepository
$subject = $l10n->t('%s Introduction received', $subjectPrefix); $subject = $l10n->t('%s Introduction received', $subjectPrefix);
$preamble = $l10n->t('You\'ve received an introduction from \'%1$s\' at %2$s', $params['source_name'], $sitename); $preamble = $l10n->t('You\'ve received an introduction from \'%1$s\' at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('You\'ve received [url=%1$s]an introduction[/url] from %2$s.', $epreamble = $l10n->t(
'You\'ve received [url=%1$s]an introduction[/url] from %2$s.',
$itemlink, $itemlink,
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]' '[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
); );
@ -373,7 +374,8 @@ class Notify extends BaseRepository
$subject = $l10n->t('%s A new person is sharing with you', $subjectPrefix); $subject = $l10n->t('%s A new person is sharing with you', $subjectPrefix);
$preamble = $l10n->t('%1$s is sharing with you at %2$s', $params['source_name'], $sitename); $preamble = $l10n->t('%1$s is sharing with you at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('%1$s is sharing with you at %2$s', $epreamble = $l10n->t(
'%1$s is sharing with you at %2$s',
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]', '[url='.$params['source_link'].']'.$params['source_name'].'[/url]',
$sitename $sitename
); );
@ -383,7 +385,8 @@ class Notify extends BaseRepository
$subject = $l10n->t('%s You have a new follower', $subjectPrefix); $subject = $l10n->t('%s You have a new follower', $subjectPrefix);
$preamble = $l10n->t('You have a new follower at %2$s : %1$s', $params['source_name'], $sitename); $preamble = $l10n->t('You have a new follower at %2$s : %1$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('You have a new follower at %2$s : %1$s', $epreamble = $l10n->t(
'You have a new follower at %2$s : %1$s',
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]', '[url='.$params['source_link'].']'.$params['source_name'].'[/url]',
$sitename $sitename
); );
@ -399,7 +402,8 @@ class Notify extends BaseRepository
$subject = $l10n->t('%s Friend suggestion received', $subjectPrefix); $subject = $l10n->t('%s Friend suggestion received', $subjectPrefix);
$preamble = $l10n->t('You\'ve received a friend suggestion from \'%1$s\' at %2$s', $params['source_name'], $sitename); $preamble = $l10n->t('You\'ve received a friend suggestion from \'%1$s\' at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.', $epreamble = $l10n->t(
'You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.',
$itemlink, $itemlink,
'[url='.$params['item']['url'].']'.$params['item']['name'].'[/url]', '[url='.$params['item']['url'].']'.$params['item']['name'].'[/url]',
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]' '[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
@ -420,7 +424,8 @@ class Notify extends BaseRepository
$subject = $l10n->t('%s Connection accepted', $subjectPrefix); $subject = $l10n->t('%s Connection accepted', $subjectPrefix);
$preamble = $l10n->t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename); $preamble = $l10n->t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('%2$s has accepted your [url=%1$s]connection request[/url].', $epreamble = $l10n->t(
'%2$s has accepted your [url=%1$s]connection request[/url].',
$itemlink, $itemlink,
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]' '[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
); );
@ -435,7 +440,8 @@ class Notify extends BaseRepository
$subject = $l10n->t('%s Connection accepted', $subjectPrefix); $subject = $l10n->t('%s Connection accepted', $subjectPrefix);
$preamble = $l10n->t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename); $preamble = $l10n->t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('%2$s has accepted your [url=%1$s]connection request[/url].', $epreamble = $l10n->t(
'%2$s has accepted your [url=%1$s]connection request[/url].',
$itemlink, $itemlink,
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]' '[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
); );
@ -457,14 +463,17 @@ class Notify extends BaseRepository
$subject = $l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('registration request'); $subject = $l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('registration request');
$preamble = $l10n->t('You\'ve received a registration request from \'%1$s\' at %2$s', $params['source_name'], $sitename); $preamble = $l10n->t('You\'ve received a registration request from \'%1$s\' at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('You\'ve received a [url=%1$s]registration request[/url] from %2$s.', $epreamble = $l10n->t(
'You\'ve received a [url=%1$s]registration request[/url] from %2$s.',
$itemlink, $itemlink,
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]' '[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
); );
$body = $l10n->t("Display Name: %s\nSite Location: %s\nLogin Name: %s (%s)", $body = $l10n->t(
"Display Name: %s\nSite Location: %s\nLogin Name: %s (%s)",
$params['source_name'], $params['source_name'],
$siteurl, $params['source_mail'], $siteurl,
$params['source_mail'],
$params['source_nick'] $params['source_nick']
); );
@ -478,14 +487,17 @@ class Notify extends BaseRepository
$subject = $l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('new registration'); $subject = $l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('new registration');
$preamble = $l10n->t('You\'ve received a new registration from \'%1$s\' at %2$s', $params['source_name'], $sitename); $preamble = $l10n->t('You\'ve received a new registration from \'%1$s\' at %2$s', $params['source_name'], $sitename);
$epreamble = $l10n->t('You\'ve received a [url=%1$s]new registration[/url] from %2$s.', $epreamble = $l10n->t(
'You\'ve received a [url=%1$s]new registration[/url] from %2$s.',
$itemlink, $itemlink,
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]' '[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
); );
$body = $l10n->t("Display Name: %s\nSite Location: %s\nLogin Name: %s (%s)", $body = $l10n->t(
"Display Name: %s\nSite Location: %s\nLogin Name: %s (%s)",
$params['source_name'], $params['source_name'],
$siteurl, $params['source_mail'], $siteurl,
$params['source_mail'],
$params['source_nick'] $params['source_nick']
); );
@ -599,9 +611,7 @@ class Notify extends BaseRepository
DBA::insert('notify-threads', $fields); DBA::insert('notify-threads', $fields);
$emailBuilder->setHeader('Message-ID', $message_id); $emailBuilder->setHeader('Message-ID', $message_id);
$log_msg = "No previous notification found for this parent:\n" . $this->logger->info('No previous notification found for this parent', ['parent' => $params['parent'], 'uid' => $params['uid']]);
" parent: {$params['parent']}\n" . " uid : {$params['uid']}\n";
$this->logger->info($log_msg);
} else { } else {
// If not, just "follow" the thread. // If not, just "follow" the thread.
$emailBuilder->setHeader('References', $message_id); $emailBuilder->setHeader('References', $message_id);
@ -645,7 +655,8 @@ class Notify extends BaseRepository
$emailBuilder->withPhoto( $emailBuilder->withPhoto(
$datarray['source_photo'], $datarray['source_photo'],
$datarray['source_link'] ?? $sitelink, $datarray['source_link'] ?? $sitelink,
$datarray['source_name'] ?? $sitename); $datarray['source_name'] ?? $sitename
);
} }
$email = $emailBuilder->build(); $email = $emailBuilder->build();
@ -725,9 +736,12 @@ class Notify extends BaseRepository
$params['source_photo'] = $contact['photo']; $params['source_photo'] = $contact['photo'];
} }
$item = Model\Post::selectFirstForUser($Notification->uid, Model\Item::ITEM_FIELDLIST, $item = Model\Post::selectFirstForUser(
$Notification->uid,
Model\Item::ITEM_FIELDLIST,
['uid' => [0, $Notification->uid], 'uri-id' => $Notification->targetUriId, 'deleted' => false], ['uid' => [0, $Notification->uid], 'uri-id' => $Notification->targetUriId, 'deleted' => false],
['order' => ['uid' => true]]); ['order' => ['uid' => true]]
);
if (empty($item)) { if (empty($item)) {
$this->logger->info('Item not found', ['uri-id' => $Notification->targetUriId, 'type' => $Notification->type]); $this->logger->info('Item not found', ['uri-id' => $Notification->targetUriId, 'type' => $Notification->type]);
return false; return false;

View File

@ -24,40 +24,24 @@ use Friendica\Object\Api\Mastodon\InstanceV2\Configuration;
*/ */
class Instance extends BaseDataTransferObject class Instance extends BaseDataTransferObject
{ {
/** @var string (URL) */ protected string $uri;
protected $uri; protected string $title;
/** @var string */ protected string $short_description;
protected $title; protected string $description;
/** @var string */ protected string $email;
protected $short_description; protected string $version;
/** @var string */ protected array $urls;
protected $description; protected Stats $stats;
/** @var string */ /** This is meant as a server banner, default Mastodon "thumbnail" is 1600×620px */
protected $email; protected ?string $thumbnail = null;
/** @var string */ protected array $languages;
protected $version; protected int $max_toot_chars;
/** @var array */ protected bool $registrations;
protected $urls; protected bool $approval_required;
/** @var Stats */ protected bool $invites_enabled;
protected $stats; protected Configuration $configuration;
/** @var string|null This is meant as a server banner, default Mastodon "thumbnail" is 1600×620px */ protected ?Account $contact_account = null;
protected $thumbnail = null; protected array $rules = [];
/** @var array */
protected $languages;
/** @var int */
protected $max_toot_chars;
/** @var bool */
protected $registrations;
/** @var bool */
protected $approval_required;
/** @var bool */
protected $invites_enabled;
/** @var Configuration */
protected $configuration;
/** @var Account|null */
protected $contact_account = null;
/** @var array */
protected $rules = [];
public function __construct(IManageConfigValues $config, BaseURL $baseUrl, Database $database, Configuration $configuration, ?Account $contact_account, array $rules) public function __construct(IManageConfigValues $config, BaseURL $baseUrl, Database $database, Configuration $configuration, ?Account $contact_account, array $rules)
{ {
@ -77,7 +61,7 @@ class Instance extends BaseDataTransferObject
$this->approval_required = ($register_policy === Register::APPROVE); $this->approval_required = ($register_policy === Register::APPROVE);
$this->invites_enabled = false; $this->invites_enabled = false;
$this->configuration = $configuration; $this->configuration = $configuration;
$this->contact_account = $contact_account ?? []; $this->contact_account = $contact_account;
$this->rules = $rules; $this->rules = $rules;
} }
} }

View File

@ -498,8 +498,10 @@ class Post
} }
$languages = []; $languages = [];
$language = '';
if (!empty($item['language'])) { if (!empty($item['language'])) {
$languages = DI::l10n()->t('Languages'); $languages = DI::l10n()->t('Languages');
$language = array_key_first(json_decode($item['language'], true));
} }
if (in_array($item['private'], [Item::PUBLIC, Item::UNLISTED]) && in_array($item['network'], Protocol::FEDERATED)) { if (in_array($item['private'], [Item::PUBLIC, Item::UNLISTED]) && in_array($item['network'], Protocol::FEDERATED)) {
@ -553,6 +555,7 @@ class Post
'title' => $item['title'], 'title' => $item['title'],
'summary' => $item['content-warning'], 'summary' => $item['content-warning'],
'localtime' => DateTimeFormat::local($item['created'], 'r'), 'localtime' => DateTimeFormat::local($item['created'], 'r'),
'utc' => DateTimeFormat::utc($item['created']),
'ago' => $item['app'] ? DI::l10n()->t('%s from %s', $ago, $item['app']) : $ago, 'ago' => $item['app'] ? DI::l10n()->t('%s from %s', $ago, $item['app']) : $ago,
'app' => $item['app'], 'app' => $item['app'],
'created' => $ago, 'created' => $ago,
@ -579,6 +582,7 @@ class Post
'tagger' => $tagger, 'tagger' => $tagger,
'filer' => $filer, 'filer' => $filer,
'language' => $languages, 'language' => $languages,
'lang' => $language,
'searchtext' => DI::l10n()->t('Search Text'), 'searchtext' => DI::l10n()->t('Search Text'),
'drop' => $drop, 'drop' => $drop,
'block' => $block, 'block' => $block,

View File

@ -906,15 +906,15 @@ class Processor
if ($id) { if ($id) {
$shared_item = Post::selectFirst(['uri-id'], ['id' => $id]); $shared_item = Post::selectFirst(['uri-id'], ['id' => $id]);
$item['quote-uri-id'] = $shared_item['uri-id']; $item['quote-uri-id'] = $shared_item['uri-id'];
DI::logger()->debug('Quote is found', ['guid' => $item['guid'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url'], 'quote-uri-id' => $item['quote-uri-id']]); DI::logger()->debug('Quote is found', ['uri' => $item['uri'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url'], 'quote-uri-id' => $item['quote-uri-id']]);
} elseif ($uri_id = ItemURI::getIdByURI($activity['quote-url'], false)) { } elseif ($uri_id = ItemURI::getIdByURI($activity['quote-url'], false)) {
DI::logger()->info('Quote was not fetched but the uri-id existed', ['guid' => $item['guid'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url'], 'quote-uri-id' => $uri_id]); DI::logger()->info('Quote was not fetched but the uri-id existed', ['uri' => $item['uri'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url'], 'quote-uri-id' => $uri_id]);
$item['quote-uri-id'] = $uri_id; $item['quote-uri-id'] = $uri_id;
} elseif (Queue::exists($activity['quote-url'], 'as:Create')) { } elseif (Queue::exists($activity['quote-url'], 'as:Create')) {
$item['quote-uri-id'] = ItemURI::getIdByURI($activity['quote-url']); $item['quote-uri-id'] = ItemURI::getIdByURI($activity['quote-url']);
DI::logger()->info('Quote is queued but not processed yet', ['guid' => $item['guid'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url'], 'quote-uri-id' => $item['quote-uri-id']]); DI::logger()->info('Quote is queued but not processed yet', ['uri' => $item['uri'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url'], 'quote-uri-id' => $item['quote-uri-id']]);
} else { } else {
DI::logger()->notice('Quote was not fetched', ['guid' => $item['guid'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url']]); DI::logger()->notice('Quote was not fetched', ['uri' => $item['uri'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url']]);
} }
} }

View File

@ -799,11 +799,13 @@ class Transmitter
if (!empty($item['quote-uri-id']) && in_array($item['private'], [Item::PUBLIC, Item::UNLISTED])) { if (!empty($item['quote-uri-id']) && in_array($item['private'], [Item::PUBLIC, Item::UNLISTED])) {
$quoted = Post::selectFirst(['author-link'], ['uri-id' => $item['quote-uri-id']]); $quoted = Post::selectFirst(['author-link'], ['uri-id' => $item['quote-uri-id']]);
if (!empty($quoted['author-link'])) {
$profile = APContact::getByURL($quoted['author-link'], false); $profile = APContact::getByURL($quoted['author-link'], false);
if (!empty($profile)) { if (!empty($profile)) {
$data['cc'][] = $profile['url']; $data['cc'][] = $profile['url'];
} }
} }
}
$data = self::filterReceiverData($data, $item['author-link']); $data = self::filterReceiverData($data, $item['author-link']);

View File

@ -310,7 +310,7 @@ class Delivery
$atom = DFRN::entries($msgitems, $owner); $atom = DFRN::entries($msgitems, $owner);
} }
DI::logger()->debug('Notifier entry: ' . $contact['url'] . ' ' . ($target_item_id ?? 'relocation') . ' entry: ' . $atom); DI::logger()->debug('Notifier entry', ['url' => $contact['url'], 'target_item_id' => ($target_item_id ?? 'relocation'), 'entry' => $atom]);
$protocol = Post\DeliveryData::DFRN; $protocol = Post\DeliveryData::DFRN;

View File

@ -2790,7 +2790,7 @@ class Diaspora
*/ */
public static function encodePrivateData(string $msg, array $user, array $contact, string $prvkey, string $pubkey): string public static function encodePrivateData(string $msg, array $user, array $contact, string $prvkey, string $pubkey): string
{ {
DI::logger()->debug('Message: ' . $msg); DI::logger()->debug('Diaspora message', ['msg' => $msg]);
// without a public key nothing will work // without a public key nothing will work
if (!$pubkey) { if (!$pubkey) {

View File

@ -8,7 +8,6 @@
namespace Friendica\Protocol; namespace Friendica\Protocol;
use Friendica\App; use Friendica\App;
use Friendica\Core\Addon;
use Friendica\DI; use Friendica\DI;
use Friendica\Module; use Friendica\Module;
use Friendica\Module\Register; use Friendica\Module\Register;
@ -43,6 +42,11 @@ class ZOT
*/ */
public static function getSiteInfo(): array public static function getSiteInfo(): array
{ {
$baseUrl = (string) DI::baseUrl();
$keyValue = DI::keyValue();
$addonHelper = DI::addonHelper();
$config = DI::config();
$policies = [ $policies = [
Module\Register::OPEN => 'open', Module\Register::OPEN => 'open',
Module\Register::APPROVE => 'approve', Module\Register::APPROVE => 'approve',
@ -50,14 +54,14 @@ class ZOT
]; ];
return [ return [
'url' => (string)DI::baseUrl(), 'url' => $baseUrl,
'openWebAuth' => (string)DI::baseUrl() . '/owa', 'openWebAuth' => $baseUrl . '/owa',
'authRedirect' => (string)DI::baseUrl() . '/magic', 'authRedirect' => $baseUrl . '/magic',
'register_policy' => $policies[Register::getPolicy()], 'register_policy' => $policies[Register::getPolicy()],
'accounts' => DI::keyValue()->get('nodeinfo_total_users'), 'accounts' => $keyValue->get('nodeinfo_total_users'),
'plugins' => Addon::getVisibleList(), 'plugins' => $addonHelper->getVisibleEnabledAddons(),
'sitename' => DI::config()->get('config', 'sitename'), 'sitename' => $config->get('config', 'sitename'),
'about' => DI::config()->get('config', 'info'), 'about' => $config->get('config', 'info'),
'project' => App::PLATFORM, 'project' => App::PLATFORM,
'version' => App::VERSION, 'version' => App::VERSION,
]; ];

View File

@ -299,12 +299,19 @@ class Crypto
* Creates cryptographic secure random digits * Creates cryptographic secure random digits
* *
* @param string $digits The count of digits * @param string $digits The count of digits
* @return int The random Digits * @return string The random Digits
* *
* @throws \Exception In case 'random_int' isn't usable * @throws \Exception In case 'random_int' isn't usable
*/ */
public static function randomDigits($digits) public static function randomDigits($digits): string
{ {
return random_int(0, 10 ** $digits - 1); $rn = '';
// generating cryptographically secure pseudo-random integers
for ($i = 0; $i < $digits; $i++) {
$rn .= random_int(0, 9);
}
return $rn;
} }
} }

View File

@ -40,9 +40,13 @@ class Emailer
/** @var string */ /** @var string */
private $siteEmailName; private $siteEmailName;
public function __construct(IManageConfigValues $config, IManagePersonalConfigValues $pConfig, BaseURL $baseURL, LoggerInterface $logger, public function __construct(
L10n $defaultLang) IManageConfigValues $config,
{ IManagePersonalConfigValues $pConfig,
BaseURL $baseURL,
LoggerInterface $logger,
L10n $defaultLang
) {
$this->config = $config; $this->config = $config;
$this->pConfig = $pConfig; $this->pConfig = $pConfig;
$this->logger = $logger; $this->logger = $logger;
@ -89,8 +93,14 @@ class Emailer
*/ */
public function newSystemMail() public function newSystemMail()
{ {
return new SystemMailBuilder($this->l10n, $this->baseUrl, $this->config, $this->logger, return new SystemMailBuilder(
$this->getSiteEmailAddress(), $this->getSiteEmailName()); $this->l10n,
$this->baseUrl,
$this->config,
$this->logger,
$this->getSiteEmailAddress(),
$this->getSiteEmailName()
);
} }
/** /**
@ -100,8 +110,14 @@ class Emailer
*/ */
public function newNotifyMail() public function newNotifyMail()
{ {
return new NotifyMailBuilder($this->l10n, $this->baseUrl, $this->config, $this->logger, return new NotifyMailBuilder(
$this->getSiteEmailAddress(), $this->getSiteEmailName()); $this->l10n,
$this->baseUrl,
$this->config,
$this->logger,
$this->getSiteEmailAddress(),
$this->getSiteEmailName()
);
} }
/** /**
@ -207,8 +223,7 @@ class Emailer
$hookdata['parameters'] $hookdata['parameters']
); );
$this->logger->debug('header ' . 'To: ' . $email->getToAddress() . '\n' . $messageHeader); $this->logger->debug('Email message header', ['To' => $email->getToAddress(), 'messageHeader' => $messageHeader, 'return' => ($res) ? 'true' : 'false']);
$this->logger->debug('return value ' . (($res) ? 'true' : 'false'));
return $res; return $res;
} }

View File

@ -147,7 +147,8 @@ class Temporal
} }
$tpl = Renderer::getMarkupTemplate("field_input.tpl"); $tpl = Renderer::getMarkupTemplate("field_input.tpl");
$o = Renderer::replaceMacros($tpl, $o = Renderer::replaceMacros(
$tpl,
[ [
'$field' => [ '$field' => [
'dob', 'dob',
@ -157,7 +158,8 @@ class Temporal
'', '',
'placeholder="' . DI::l10n()->t('YYYY-MM-DD or MM-DD') . '"' 'placeholder="' . DI::l10n()->t('YYYY-MM-DD or MM-DD') . '"'
] ]
]); ]
);
return $o; return $o;
} }
@ -223,17 +225,19 @@ class Temporal
bool $picktime = true, bool $picktime = true,
string $minfrom = '', string $minfrom = '',
string $maxfrom = '', string $maxfrom = '',
bool $required = false): string bool $required = false
{ ): string {
// First day of the week (0 = Sunday) // First day of the week (0 = Sunday)
$firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'first_day_of_week', 0); $firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'first_day_of_week') ?: 0;
$lang = DI::l10n()->toISO6391(DI::l10n()->getCurrentLang()); $lang = DI::l10n()->toISO6391(DI::l10n()->getCurrentLang());
// Check if the detected language is supported by the picker // Check if the detected language is supported by the picker
if (!in_array($lang, if (!in_array(
$lang,
['ar', 'ro', 'id', 'bg', 'fa', 'ru', 'uk', 'en', 'el', 'de', 'nl', 'tr', 'fr', 'es', 'th', 'pl', 'pt', 'ch', 'se', 'kr', ['ar', 'ro', 'id', 'bg', 'fa', 'ru', 'uk', 'en', 'el', 'de', 'nl', 'tr', 'fr', 'es', 'th', 'pl', 'pt', 'ch', 'se', 'kr',
'it', 'da', 'no', 'ja', 'vi', 'sl', 'cs', 'hu'])) { 'it', 'da', 'no', 'ja', 'vi', 'sl', 'cs', 'hu']
)) {
$lang = 'en'; $lang = 'en';
} }
@ -329,7 +333,7 @@ class Temporal
return $compare_time ? DI::l10n()->t('less than a second ago') : DI::l10n()->t('today'); return $compare_time ? DI::l10n()->t('less than a second ago') : DI::l10n()->t('today');
} }
if ($etime < 0){ if ($etime < 0) {
$etime = -$etime; $etime = -$etime;
$isfuture = true; $isfuture = true;
} }
@ -349,10 +353,9 @@ class Temporal
if ($d >= 1) { if ($d >= 1) {
$r = floor($d); $r = floor($d);
// translators - e.g. 22 hours ago, 1 minute ago // translators - e.g. 22 hours ago, 1 minute ago
if($isfuture){ if($isfuture) {
$format = DI::l10n()->t('in %1$d %2$s'); $format = DI::l10n()->t('in %1$d %2$s');
} } else {
else {
$format = DI::l10n()->t('%1$d %2$s ago'); $format = DI::l10n()->t('%1$d %2$s ago');
} }
@ -475,7 +478,7 @@ class Temporal
$str_month = DI::l10n()->getDay($mtab[$m]); $str_month = DI::l10n()->getDay($mtab[$m]);
$o = '<table class="calendar' . $class . '">'; $o = '<table class="calendar' . $class . '">';
$o .= "<caption>$str_month $y</caption><tr>"; $o .= "<caption>$str_month $y</caption><tr>";
for ($a = 0; $a < 7; $a ++) { for ($a = 0; $a < 7; $a++) {
$o .= '<th>' . mb_substr(DI::l10n()->getDay($dn[$a]), 0, 3, 'UTF-8') . '</th>'; $o .= '<th>' . mb_substr(DI::l10n()->getDay($dn[$a]), 0, 3, 'UTF-8') . '</th>';
} }
@ -496,13 +499,13 @@ class Temporal
$o .= $day; $o .= $day;
} }
$d ++; $d++;
} else { } else {
$o .= '&nbsp;'; $o .= '&nbsp;';
} }
$o .= '</td>'; $o .= '</td>';
$dow ++; $dow++;
if (($dow == 7) && ($d <= $l)) { if (($dow == 7) && ($d <= $l)) {
$dow = 0; $dow = 0;
$o .= '</tr><tr>'; $o .= '</tr><tr>';
@ -510,7 +513,7 @@ class Temporal
} }
if ($dow) { if ($dow) {
for ($a = $dow; $a < 7; $a ++) { for ($a = $dow; $a < 7; $a++) {
$o .= '<td>&nbsp;</td>'; $o .= '<td>&nbsp;</td>';
} }
} }

View File

@ -7,10 +7,12 @@
namespace Friendica\Worker; namespace Friendica\Worker;
use Friendica\Core\Worker;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\HTTPException\NotFoundException; use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Util\Network;
class AddContact class AddContact
{ {
@ -39,4 +41,20 @@ class AddContact
DI::logger()->notice('Imagick not found.', ['exception' => $e, 'uid' => $uid, 'url' => $url]); DI::logger()->notice('Imagick not found.', ['exception' => $e, 'uid' => $uid, 'url' => $url]);
} }
} }
/**
* @param array|int $run_parameters Priority constant or array of options described in Worker::add
* @param int $uid User ID
* @param string $url Contact link
* @return int
*/
public static function add($run_parameters, int $uid, string $url): int
{
if (Network::isUrlBlocked($url)) {
return 0;
}
DI::logger()->debug('Add contact', ['uid' => $uid, 'url' => $url]);
return Worker::add($run_parameters, 'AddContact', 0, $url);
}
} }

View File

@ -7,7 +7,6 @@
namespace Friendica\Worker; namespace Friendica\Worker;
use Friendica\Core\Addon;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
@ -145,7 +144,7 @@ class Cron
// Update "blocked" status of servers // Update "blocked" status of servers
Worker::add(Worker::PRIORITY_LOW, 'UpdateBlockedServers'); Worker::add(Worker::PRIORITY_LOW, 'UpdateBlockedServers');
Addon::reload(); DI::addonHelper()->reloadAddons();
DI::keyValue()->set('last_cron_daily', time()); DI::keyValue()->set('last_cron_daily', time());
} }

View File

@ -44,7 +44,7 @@ use Friendica\Database\DBA;
// This file is required several times during the test in DbaDefinition which justifies this condition // This file is required several times during the test in DbaDefinition which justifies this condition
if (!defined('DB_UPDATE_VERSION')) { if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1576); define('DB_UPDATE_VERSION', 1577);
} }
return [ return [
@ -1604,7 +1604,7 @@ return [
"indexes" => [ "indexes" => [
"PRIMARY" => ["id"], "PRIMARY" => ["id"],
"uid_uri-id" => ["UNIQUE", "uid", "uri-id"], "uid_uri-id" => ["UNIQUE", "uid", "uri-id"],
"uri-id" => ["uri-id"], "uri-id_origin_deleted" => ["uri-id", "origin", "deleted"],
"parent-uri-id" => ["parent-uri-id"], "parent-uri-id" => ["parent-uri-id"],
"thr-parent-id" => ["thr-parent-id"], "thr-parent-id" => ["thr-parent-id"],
"external-id" => ["external-id"], "external-id" => ["external-id"],

View File

@ -1763,7 +1763,8 @@ return [
], ],
"query" => "FROM `register` "query" => "FROM `register`
INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid` INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
INNER JOIN `user` ON `register`.`uid` = `user`.`uid`" INNER JOIN `user` ON `register`.`uid` = `user`.`uid`
WHERE `register`.`uid` != 0"
], ],
"tag-search-view" => [ "tag-search-view" => [
"fields" => [ "fields" => [

View File

@ -42,6 +42,12 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo
[Dice::INSTANCE => Dice::SELF], [Dice::INSTANCE => Dice::SELF],
], ],
], ],
\Friendica\Core\Addon\AddonHelper::class => [
'instanceOf' => \Friendica\Core\Addon\AddonProxy::class,
'constructParams' => [
$basepath . '/addon',
],
],
\Friendica\Util\BasePath::class => [ \Friendica\Util\BasePath::class => [
'constructParams' => [ 'constructParams' => [
$basepath, $basepath,
@ -81,6 +87,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo
'call' => [ 'call' => [
['createConfigFileManager', [ ['createConfigFileManager', [
$basepath, $basepath,
$basepath . '/addon',
$serverVars, $serverVars,
], Dice::CHAIN_CALL], ], Dice::CHAIN_CALL],
], ],
@ -182,6 +189,9 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo
['create', [], Dice::CHAIN_CALL], ['create', [], Dice::CHAIN_CALL],
], ],
], ],
\Psr\EventDispatcher\EventDispatcherInterface::class => [
'instanceOf' => \Friendica\Event\EventDispatcher::class,
],
\Friendica\Core\Logger\Capability\IHaveCallIntrospections::class => [ \Friendica\Core\Logger\Capability\IHaveCallIntrospections::class => [
'instanceOf' => \Friendica\Core\Logger\Util\Introspection::class, 'instanceOf' => \Friendica\Core\Logger\Util\Introspection::class,
'constructParams' => [ 'constructParams' => [

View File

@ -8,7 +8,7 @@
namespace Friendica\Test; namespace Friendica\Test;
use Friendica\Capabilities\ICanCreateResponses; use Friendica\Capabilities\ICanCreateResponses;
use Friendica\Core\Addon; use Friendica\Core\Addon\AddonHelper;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\DI; use Friendica\DI;
@ -201,7 +201,7 @@ abstract class ApiTestCase extends FixtureTestCase
'plugin_admin' => function_exists($addon . '_addon_admin'), 'plugin_admin' => function_exists($addon . '_addon_admin'),
]); ]);
Addon::loadAddons(); $this->dice->create(AddonHelper::class)->loadAddons();
Hook::loadHooks(); Hook::loadHooks();
} }
} }

View File

@ -44,7 +44,7 @@ trait FixtureTestTrait
->addRules(include __DIR__ . '/../static/dependencies.config.php') ->addRules(include __DIR__ . '/../static/dependencies.config.php')
->addRule(ConfigFileManager::class, [ ->addRule(ConfigFileManager::class, [
'instanceOf' => Config::class, 'instanceOf' => Config::class,
'call' => [['createConfigFileManager', [$this->root->url(), $server,], Dice::CHAIN_CALL]]]) 'call' => [['createConfigFileManager', [$this->root->url(), $this->root->url() . '/addon', $server,], Dice::CHAIN_CALL]]])
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]) ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
->addRule(IHandleSessions::class, ['instanceOf' => Memory::class, 'shared' => true, 'call' => null]) ->addRule(IHandleSessions::class, ['instanceOf' => Memory::class, 'shared' => true, 'call' => null])
->addRule(Arguments::class, [ ->addRule(Arguments::class, [

View File

@ -0,0 +1,55 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Test\Unit\Core\Addon;
use Friendica\Core\Addon\AddonInfo;
use PHPUnit\Framework\TestCase;
class AddonInfoTest extends TestCase
{
public function testFromArrayCreatesObject(): void
{
$data = [
'id' => '',
'name' => '',
'description' => '',
'authors' => [],
'maintainers' => [],
'version' => '',
'status' => '',
];
$this->assertInstanceOf(AddonInfo::class, AddonInfo::fromArray($data));
}
public function testGetterReturningCorrectValues(): void
{
$data = [
'id' => 'test',
'name' => 'Test-Addon',
'description' => 'This is an addon for tests',
'authors' => [['name' => 'Sam']],
'maintainers' => [['name' => 'Sam', 'link' => 'https://example.com']],
'version' => '0.1',
'status' => 'In Development',
];
$info = AddonInfo::fromArray($data);
$this->assertSame($data['id'], $info->getId());
$this->assertSame($data['name'], $info->getName());
$this->assertSame($data['description'], $info->getDescription());
$this->assertSame($data['description'], $info->getDescription());
$this->assertSame($data['authors'], $info->getAuthors());
$this->assertSame($data['maintainers'], $info->getMaintainers());
$this->assertSame($data['version'], $info->getVersion());
$this->assertSame($data['status'], $info->getStatus());
}
}

View File

@ -0,0 +1,176 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Test\Unit\Core\Hooks;
use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Core\Hooks\HookEventBridge;
use Friendica\Event\ArrayFilterEvent;
use Friendica\Event\ConfigLoadedEvent;
use Friendica\Event\Event;
use Friendica\Event\HtmlFilterEvent;
use PHPUnit\Framework\TestCase;
class HookEventBridgeTest extends TestCase
{
public function testGetStaticSubscribedEventsReturnsStaticMethods(): void
{
$expected = [
Event::INIT => 'onNamedEvent',
ConfigLoadedEvent::CONFIG_LOADED => 'onConfigLoadedEvent',
ArrayFilterEvent::APP_MENU => 'onArrayFilterEvent',
ArrayFilterEvent::NAV_INFO => 'onArrayFilterEvent',
ArrayFilterEvent::FEATURE_ENABLED => 'onArrayFilterEvent',
ArrayFilterEvent::FEATURE_GET => 'onArrayFilterEvent',
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent',
HtmlFilterEvent::PAGE_CONTENT_TOP => 'onHtmlFilterEvent',
HtmlFilterEvent::PAGE_END => 'onHtmlFilterEvent',
];
$this->assertSame(
$expected,
HookEventBridge::getStaticSubscribedEvents()
);
foreach ($expected as $methodName) {
$this->assertTrue(
method_exists(HookEventBridge::class, $methodName),
$methodName . '() is not defined'
);
$this->assertTrue(
(new \ReflectionMethod(HookEventBridge::class, $methodName))->isStatic(),
$methodName . '() is not static'
);
}
}
public static function getNamedEventData(): array
{
return [
['test', 'test'],
[Event::INIT, 'init_1'],
];
}
/**
* @dataProvider getNamedEventData
*/
public function testOnNamedEventCallsHook($name, $expected): void
{
$event = new Event($name);
$reflectionProperty = new \ReflectionProperty(HookEventBridge::class, 'mockedCallHook');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue(null, function (string $name, $data) use ($expected) {
$this->assertSame($expected, $name);
$this->assertSame('', $data);
return $data;
});
HookEventBridge::onNamedEvent($event);
}
public static function getConfigLoadedEventData(): array
{
return [
['test', 'test'],
[ConfigLoadedEvent::CONFIG_LOADED, 'load_config'],
];
}
/**
* @dataProvider getConfigLoadedEventData
*/
public function testOnConfigLoadedEventCallsHookWithCorrectValue($name, $expected): void
{
$config = $this->createStub(ConfigFileManager::class);
$event = new ConfigLoadedEvent($name, $config);
$reflectionProperty = new \ReflectionProperty(HookEventBridge::class, 'mockedCallHook');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue(null, function (string $name, $data) use ($expected, $config) {
$this->assertSame($expected, $name);
$this->assertSame($config, $data);
return $data;
});
HookEventBridge::onConfigLoadedEvent($event);
}
public static function getArrayFilterEventData(): array
{
return [
['test', 'test'],
[ArrayFilterEvent::APP_MENU, 'app_menu'],
[ArrayFilterEvent::NAV_INFO, 'nav_info'],
[ArrayFilterEvent::FEATURE_ENABLED, 'isEnabled'],
[ArrayFilterEvent::FEATURE_GET, 'get'],
];
}
/**
* @dataProvider getArrayFilterEventData
*/
public function testOnArrayFilterEventCallsHookWithCorrectValue($name, $expected): void
{
$event = new ArrayFilterEvent($name, ['original']);
$reflectionProperty = new \ReflectionProperty(HookEventBridge::class, 'mockedCallHook');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue(null, function (string $name, $data) use ($expected) {
$this->assertSame($expected, $name);
$this->assertSame(['original'], $data);
return $data;
});
HookEventBridge::onArrayFilterEvent($event);
}
public static function getHtmlFilterEventData(): array
{
return [
['test', 'test'],
[HtmlFilterEvent::HEAD, 'head'],
[HtmlFilterEvent::FOOTER, 'footer'],
[HtmlFilterEvent::PAGE_HEADER, 'page_header'],
[HtmlFilterEvent::PAGE_CONTENT_TOP, 'page_content_top'],
[HtmlFilterEvent::PAGE_END, 'page_end'],
];
}
/**
* @dataProvider getHtmlFilterEventData
*/
public function testOnHtmlFilterEventCallsHookWithCorrectValue($name, $expected): void
{
$event = new HtmlFilterEvent($name, 'original');
$reflectionProperty = new \ReflectionProperty(HookEventBridge::class, 'mockedCallHook');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue(null, function (string $name, $data) use ($expected) {
$this->assertSame($expected, $name);
$this->assertSame('original', $data);
return $data;
});
HookEventBridge::onHtmlFilterEvent($event);
}
}

View File

@ -0,0 +1,66 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Test\Unit\Event;
use Friendica\Event\ArrayFilterEvent;
use Friendica\Event\NamedEvent;
use PHPUnit\Framework\TestCase;
class ArrayFilterEventTest extends TestCase
{
public function testImplementationOfInstances(): void
{
$event = new ArrayFilterEvent('test', []);
$this->assertInstanceOf(NamedEvent::class, $event);
}
public static function getPublicConstants(): array
{
return [
[ArrayFilterEvent::APP_MENU, 'friendica.data.app_menu'],
];
}
/**
* @dataProvider getPublicConstants
*/
public function testPublicConstantsAreAvailable($value, $expected): void
{
$this->assertSame($expected, $value);
}
public function testGetNameReturnsName(): void
{
$event = new ArrayFilterEvent('test', []);
$this->assertSame('test', $event->getName());
}
public function testGetArrayReturnsCorrectString(): void
{
$data = ['original'];
$event = new ArrayFilterEvent('test', $data);
$this->assertSame($data, $event->getArray());
}
public function testSetArrayUpdatesHtml(): void
{
$event = new ArrayFilterEvent('test', ['original']);
$expected = ['updated'];
$event->setArray($expected);
$this->assertSame($expected, $event->getArray());
}
}

View File

@ -0,0 +1,56 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Test\Unit\Event;
use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Event\ConfigLoadedEvent;
use Friendica\Event\NamedEvent;
use PHPUnit\Framework\TestCase;
class ConfigLoadedEventTest extends TestCase
{
public function testImplementationOfInstances(): void
{
$event = new ConfigLoadedEvent('test', $this->createStub(ConfigFileManager::class));
$this->assertInstanceOf(NamedEvent::class, $event);
}
public static function getPublicConstants(): array
{
return [
[ConfigLoadedEvent::CONFIG_LOADED, 'friendica.config_loaded'],
];
}
/**
* @dataProvider getPublicConstants
*/
public function testPublicConstantsAreAvailable($value, $expected): void
{
$this->assertSame($expected, $value);
}
public function testGetNameReturnsName(): void
{
$event = new ConfigLoadedEvent('test', $this->createStub(ConfigFileManager::class));
$this->assertSame('test', $event->getName());
}
public function testGetConfigReturnsCorrectString(): void
{
$config = $this->createStub(ConfigFileManager::class);
$event = new ConfigLoadedEvent('test', $config);
$this->assertSame($config, $event->getConfig());
}
}

View File

@ -0,0 +1,37 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Test\Unit\Event;
use Friendica\Event\Event;
use Friendica\Event\EventDispatcher;
use Friendica\Event\NamedEvent;
use PHPUnit\Framework\TestCase;
use Psr\EventDispatcher\EventDispatcherInterface;
class EventDispatcherTest extends TestCase
{
public function testImplementationOfInstances(): void
{
$eventDispatcher = new EventDispatcher();
$this->assertInstanceOf(EventDispatcherInterface::class, $eventDispatcher);
}
public function testDispatchANamedEventUsesNameAsEventName(): void
{
$eventDispatcher = new EventDispatcher();
$eventDispatcher->addListener('test', function (NamedEvent $event) {
$this->assertSame('test', $event->getName());
});
$eventDispatcher->dispatch(new Event('test'));
}
}

View File

@ -0,0 +1,46 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Test\Unit\Event;
use Friendica\Event\Event;
use Friendica\Event\NamedEvent;
use PHPUnit\Framework\TestCase;
class EventTest extends TestCase
{
public function testImplementationOfInstances(): void
{
$event = new Event('test');
$this->assertInstanceOf(NamedEvent::class, $event);
}
public static function getPublicConstants(): array
{
return [
[Event::INIT, 'friendica.init'],
];
}
/**
* @dataProvider getPublicConstants
*/
public function testPublicConstantsAreAvailable($value, $expected): void
{
$this->assertSame($expected, $value);
}
public function testGetNameReturnsName(): void
{
$event = new Event('test');
$this->assertSame('test', $event->getName());
}
}

View File

@ -0,0 +1,69 @@
<?php
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace Friendica\Test\Unit\Event;
use Friendica\Event\HtmlFilterEvent;
use Friendica\Event\NamedEvent;
use PHPUnit\Framework\TestCase;
class HtmlFilterEventTest extends TestCase
{
public function testImplementationOfInstances(): void
{
$event = new HtmlFilterEvent('test', 'original');
$this->assertInstanceOf(NamedEvent::class, $event);
}
public static function getPublicConstants(): array
{
return [
[HtmlFilterEvent::HEAD, 'friendica.html.head'],
[HtmlFilterEvent::FOOTER, 'friendica.html.footer'],
[HtmlFilterEvent::PAGE_CONTENT_TOP, 'friendica.html.page_content_top'],
[HtmlFilterEvent::PAGE_END, 'friendica.html.page_end'],
];
}
/**
* @dataProvider getPublicConstants
*/
public function testPublicConstantsAreAvailable($value, $expected): void
{
$this->assertSame($expected, $value);
}
public function testGetNameReturnsName(): void
{
$event = new HtmlFilterEvent('test', '');
$this->assertSame('test', $event->getName());
}
public function testGetHtmlReturnsCorrectString(): void
{
$data = 'original';
$event = new HtmlFilterEvent('test', $data);
$this->assertSame($data, $event->getHtml());
}
public function testSetHtmlUpdatesHtml(): void
{
$event = new HtmlFilterEvent('test', 'original');
$expected = 'updated';
$event->setHtml($expected);
$this->assertSame($expected, $event->getHtml());
}
}

View File

@ -5,7 +5,7 @@
// //
// SPDX-License-Identifier: AGPL-3.0-or-later // SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types = 1); declare(strict_types=1);
namespace Friendica\Test\Unit\Util; namespace Friendica\Test\Unit\Util;

Some files were not shown because too many files have changed in this diff Show More