From dc44d51479ebb15a9eac6f51392fae81ac51e2a0 Mon Sep 17 00:00:00 2001 From: Greg Sarjeant Date: Sun, 27 Jul 2025 15:33:15 -0400 Subject: [PATCH] Add posix_getuid detection to the right place. --- src/Framework/Prerequisites/Prerequisites.php | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/Framework/Prerequisites/Prerequisites.php b/src/Framework/Prerequisites/Prerequisites.php index c0929b4..b107fe2 100644 --- a/src/Framework/Prerequisites/Prerequisites.php +++ b/src/Framework/Prerequisites/Prerequisites.php @@ -171,13 +171,22 @@ class Prerequisites { private function checkStoragePermissions() { // Issue a warning if running as root in CLI context - if ($this->isCli && posix_getuid() === 0) { + // Write out guidance for storage directory permissions + // if running the CLI script as root (since it will always appear to be writable) + if ($this->isCli && function_exists('posix_getuid') && posix_getuid() === 0) { $this->addCheck( 'Root User Warning', false, 'Running as root - permission checks may be inaccurate. After setup, ensure storage/ is owned by your web server user', 'warning' ); + } elseif ($this->isCli && !function_exists('posix_getuid')) { + $this->addCheck( + 'POSIX Extension', + false, + 'POSIX extension not available - cannot detect if running as root', + 'warning' + ); } $storageDirs = array( @@ -526,24 +535,6 @@ class Prerequisites { } } - // Write out guidance for storage directory permissions - // if running the CLI script as root (since it will always appear to be writable) - if ($this->isCli && function_exists('posix_getuid') && posix_getuid() === 0) { - $this->addCheck( - 'Root User Warning', - false, - 'Running as root - permission checks may be inaccurate. After setup, ensure storage/ is owned by your web server user', - 'warning' - ); - } elseif ($this->isCli && !function_exists('posix_getuid')) { - $this->addCheck( - 'POSIX Extension', - false, - 'POSIX extension not available - cannot detect if running as root', - 'warning' - ); - } - if ($this->isCli && function_exists('posix_getuid') && posix_getuid() === 0) { $this->log("\nšŸ“‹ ROOT USER SETUP RECOMMENDATIONS:"); $this->log("After uploading to your web server,");