]> source.dussan.org Git - nextcloud-server.git/commitdiff
Handle session initialization errors and display error page - fixes #15053
authorThomas Müller <thomas.mueller@tmit.eu>
Fri, 20 Mar 2015 11:21:03 +0000 (12:21 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Fri, 20 Mar 2015 11:21:03 +0000 (12:21 +0100)
lib/base.php
lib/private/session/internal.php

index 00117918c87695734aeb0aa7b4cdf218cdc9a423..da4b3a47c75a509b9d538ccdaf534fca6ee4b1cf 100644 (file)
@@ -415,6 +415,7 @@ class OC {
                        }
                        // if session cant be started break with http 500 error
                } catch (Exception $e) {
+                       \OCP\Util::logException('base', $e);
                        //show the user a detailed error page
                        OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
                        OC_Template::printExceptionErrorPage($e);
index 8fda6b3b3ee6ef770374adb24810a16bf1f8d2d6..acd93630f40acd1a14de53e1905b14d38c69bfce 100644 (file)
@@ -18,7 +18,9 @@ namespace OC\Session;
 class Internal extends Session {
        public function __construct($name) {
                session_name($name);
+               set_error_handler(array($this, 'trapError'));
                session_start();
+               restore_error_handler();
                if (!isset($_SESSION)) {
                        throw new \Exception('Failed to start session');
                }
@@ -82,7 +84,11 @@ class Internal extends Session {
         throw new \Exception('The session cannot be reopened - reopen() is ony to be used in unit testing.');
     }
 
-    private function validateSession() {
+       public function trapError($errorNumber, $errorString) {
+               throw new \ErrorException($errorString);
+       }
+
+       private function validateSession() {
                if ($this->sessionClosed) {
                        throw new \Exception('Session has been closed - no further changes to the session as allowed');
                }