From ae6ee95973da87afccd1959144edce7aeb2c3635 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Wed, 15 Mar 2023 08:54:50 +0100 Subject: [PATCH] avoid using posix-extension function before requirement-check can test for it and inform user Signed-off-by: Michael Kaufmann --- lib/Froxlor/PhpHelper.php | 2 +- lib/formfields/install/formfield.install.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Froxlor/PhpHelper.php b/lib/Froxlor/PhpHelper.php index 5db40948..b4af5b62 100644 --- a/lib/Froxlor/PhpHelper.php +++ b/lib/Froxlor/PhpHelper.php @@ -331,7 +331,7 @@ class PhpHelper * @return string */ public static function sizeReadable( - int $size, + $size, ?string $max = '', string $system = 'si', string $retstring = '%01.2f %s' diff --git a/lib/formfields/install/formfield.install.php b/lib/formfields/install/formfield.install.php index 9a424d06..2dbe0a1f 100644 --- a/lib/formfields/install/formfield.install.php +++ b/lib/formfields/install/formfield.install.php @@ -25,6 +25,13 @@ use Froxlor\Froxlor; +$httpuser = ''; +$httpgroup = ''; +if (extension_loaded('posix')) { + $httpuser = posix_getpwuid(posix_getuid())['name'] ?? ''; + $httpgroup = posix_getgrgid(posix_getgid())['name'] ?? ''; +} + return [ 'install' => [ 'title' => 'install', @@ -194,7 +201,7 @@ return [ 'placeholder' => lng('admin.webserver_user'), 'type' => 'text', 'mandatory' => true, - 'value' => old('httpuser', posix_getpwuid(posix_getuid())['name'] ?? '', 'installation'), + 'value' => old('httpuser', $httpuser, 'installation'), 'advanced' => true, ], 'httpgroup' => [ @@ -202,7 +209,7 @@ return [ 'placeholder' => lng('admin.webserver_group'), 'type' => 'text', 'mandatory' => true, - 'value' => old('httpgroup', posix_getgrgid(posix_getgid())['name'] ?? '', 'installation'), + 'value' => old('httpgroup', $httpgroup, 'installation'), 'advanced' => true, ], 'activate_newsfeed' => [