Commit 843fef04 authored by Thomas Müller's avatar Thomas Müller
Browse files

Handle session initialization errors and display error page - fixes #15053

parent a87cc90d
...@@ -415,6 +415,7 @@ class OC { ...@@ -415,6 +415,7 @@ class OC {
} }
// if session cant be started break with http 500 error // if session cant be started break with http 500 error
} catch (Exception $e) { } catch (Exception $e) {
\OCP\Util::logException('base', $e);
//show the user a detailed error page //show the user a detailed error page
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR); OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
OC_Template::printExceptionErrorPage($e); OC_Template::printExceptionErrorPage($e);
......
...@@ -18,7 +18,9 @@ namespace OC\Session; ...@@ -18,7 +18,9 @@ namespace OC\Session;
class Internal extends Session { class Internal extends Session {
public function __construct($name) { public function __construct($name) {
session_name($name); session_name($name);
set_error_handler(array($this, 'trapError'));
session_start(); session_start();
restore_error_handler();
if (!isset($_SESSION)) { if (!isset($_SESSION)) {
throw new \Exception('Failed to start session'); throw new \Exception('Failed to start session');
} }
...@@ -82,7 +84,11 @@ class Internal extends 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.'); 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) { if ($this->sessionClosed) {
throw new \Exception('Session has been closed - no further changes to the session as allowed'); throw new \Exception('Session has been closed - no further changes to the session as allowed');
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment