Skip to content

Commit

Permalink
Merge pull request #15062 from owncloud/fix-15053-master
Browse files Browse the repository at this point in the history
Handle session initialization errors and display error page
  • Loading branch information
DeepDiver1975 committed Mar 20, 2015
2 parents 7ea5c47 + 843fef0 commit 0b1c4bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ public static function initSession() {
}
// 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);
Expand Down
8 changes: 7 additions & 1 deletion lib/private/session/internal.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
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');
}
Expand Down Expand Up @@ -82,7 +84,11 @@ public function reopen() {
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');
}
Expand Down

0 comments on commit 0b1c4bf

Please sign in to comment.