Przeglądaj źródła

Fix: handle missing session gracefully in SessionStorage (#5254)

* Fix FileGator 7.13.4 session migrate incompatibility in Hestia

FileGator 7.13.4 introduced the migrate() method on the session storage,
and Hestia’s bundled SessionStorage adapter was not updated accordingly.
As a result, FileGator attempted to call migrate() on the storage, which
did not exist in Hestia’s version, causing a 500 Internal Server Error.

This commit adds the missing migrate($destroy = false, $lifetime = null)
method to the SessionStorage adapter and proxies the call to the underlying
Session instance, restoring compatibility with FileGator 7.13.4 and
preventing the 500 error.

* Bump FileGator version to 7.13.4

* fix: handle missing session gracefully in SessionStorage

Wrap getSession() call in a try-catch to handle SessionNotFoundException, returning null instead of throwing when no session is available.

Without this fix, trying to access filemanager gives this error:

```
2026/03/10 07:30:45 [error] 774#0: *3 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Symfony\Component\HttpFoundation\Exception\SessionNotFoundException: Session has not been set. in /usr/local/hestia/web/fm/vendor/symfony/http-foundation/Request.php:758
Stack trace:
  thrown in /usr/local/hestia/web/fm/vendor/symfony/http-foundation/Request.php on line 758" while reading response header from upstream, client: 192.168.2.3, server: _, request: "GET /fm/ HTTP/2.0", upstream: "fastcgi://unix:/run/hestia-php.sock:", host: "192.168.2.201:8083", referrer: "https://192.168.2.201:8083/list/user/"
```

Maybe it should be fixed in `backend/Services/Auth/Adapters/HestiaAuth.php` but my PHP knowdledge is 0 and this fix works fine with Symfony 8 and compiling Hestia with PHP 8.4.

Related PR #5241
sahsanu 3 dni temu
rodzic
commit
8b47bff6cd

+ 9 - 1
install/deb/filemanager/filegator/backend/Services/Session/Adapters/SessionStorage.php

@@ -59,7 +59,15 @@ class SessionStorage implements Service, SessionStorageInterface {
 	}
 
 	private function getSession(): ?Session {
-		return $this->request->getSession();
+		try {
+			return $this->request->getSession();
+		} catch (\Symfony\Component\HttpFoundation\Exception\SessionNotFoundException $e) {
+			return null;
+		}
+	}
+
+	public function migrate($destroy = false, $lifetime = null): bool {
+		return $this->request->getSession()->migrate($destroy, $lifetime);
 	}
 
 	public function migrate($destroy = false, $lifetime = null): bool {