Merge branch 'develop' into deprecate-strategies-via-addons

This commit is contained in:
Art4 2025-02-07 15:24:37 +00:00
commit 5beeda612a
13 changed files with 54 additions and 41 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

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

@ -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

@ -116,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 +173,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"
} }
} }

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.

View file

@ -87,7 +87,7 @@ Clone the addon repository (separately):
Install the dependencies: Install the dependencies:
bin/composer.phar install --no-dev 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* Make sure the folder *view/smarty3* exists and is writable by the webserver user, in this case *www-data*
@ -98,7 +98,7 @@ Make sure the folder *view/smarty3* exists and is writable by the webserver user
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

@ -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

@ -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

@ -21,10 +21,11 @@ class CryptoTest extends TestCase
{ {
$random_int = $this->getFunctionMock('Friendica\Util', 'random_int'); $random_int = $this->getFunctionMock('Friendica\Util', 'random_int');
$random_int->expects($this->any())->willReturnCallback(function ($min, $max) { $random_int->expects($this->any())->willReturnCallback(function ($min, $max) {
return 12345678; return 1;
}); });
self::assertSame(12345678, Crypto::randomDigits(8)); self::assertSame('1', Crypto::randomDigits(1));
self::assertSame('11111111', Crypto::randomDigits(8));
} }
public function testDiasporaPubRsaToMe() public function testDiasporaPubRsaToMe()

View file

@ -8,7 +8,7 @@
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
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 install" on the command line in the web root.');
} }
require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../vendor/autoload.php';