Skip to content

Commit

Permalink
Improve session error if it fails to start
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Apr 14, 2018
1 parent 02555ba commit b8c61e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion system/src/Grav/Common/Data/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static function filter($value, array $field)
$method = 'filter' . ucfirst(strtr($type, '-', '_'));

// If this is a YAML field validate/filter as such
if ($type != 'yaml' && isset($field['yaml']) && $field['yaml'] === true) {
if ($type !== 'yaml' && isset($field['yaml']) && $field['yaml'] === true) {
$method = 'filterYaml';
}

Expand Down
7 changes: 5 additions & 2 deletions system/src/Grav/Framework/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,11 @@ public function start($readonly = false)

$options = $readonly ? ['read_and_close' => '1'] : [];

if (!session_start($options)) {
throw new \RuntimeException('Failed to start session.', 500);
$success = @session_start($options);
if (!$success) {
$last = error_get_last();
$error = $last ? $last['message'] : 'Unknown error';
throw new \RuntimeException('Failed to start session: ' . $error, 500);
}

$params = session_get_cookie_params();
Expand Down

0 comments on commit b8c61e3

Please sign in to comment.