diff --git a/flight/Flight.php b/flight/Flight.php index 7a707b5..65f1a45 100644 --- a/flight/Flight.php +++ b/flight/Flight.php @@ -74,9 +74,6 @@ class Flight { // Handle exceptions internally set_exception_handler(array(__CLASS__, 'handleException')); - // Turn off notices - error_reporting (E_ALL ^ E_NOTICE); - // Fix magic quotes if (get_magic_quotes_gpc()) { $func = function ($value) use (&$func) { @@ -132,9 +129,7 @@ class Flight { * @param int $errline Error file line number */ public static function handleError($errno, $errstr, $errfile, $errline) { - if (in_array($errno, array(E_USER_ERROR, E_RECOVERABLE_ERROR))) { - static::handleException(new ErrorException($errstr, 0, $errno, $errfile, $errline)); - } + static::handleException(new ErrorException($errstr, $errno, 0, $errfile, $errline)); } /** @@ -320,9 +315,13 @@ class Flight { * @param object $e Exception */ public static function _error(Exception $e) { - $msg = '

500 Internal Server Error

'. - '

'.$e->getMessage().'

'. - '
'.$e->getTraceAsString().'
'; + $msg = sprintf('

500 Internal Server Error

'. + '

%s (%s)

'. + '
%s
', + $e->getMessage(), + $e->getCode(), + $e->getTraceAsString() + ); try { self::response(false) @@ -417,7 +416,8 @@ class Flight { self::response()->header('ETag', $id); - if ($_SERVER['HTTP_IF_NONE_MATCH'] === $id) { + if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && + $_SERVER['HTTP_IF_NONE_MATCH'] === $id) { self::halt(304); } } @@ -430,7 +430,8 @@ class Flight { public static function _lastModified($time) { self::response()->header('Last-Modified', date(DATE_RFC1123, $time)); - if (strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === $time) { + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && + strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === $time) { self::halt(304); } } diff --git a/flight/core/Loader.php b/flight/core/Loader.php index b398f09..32de4c5 100644 --- a/flight/core/Loader.php +++ b/flight/core/Loader.php @@ -34,7 +34,7 @@ class Loader { * * @var array */ - protected $dirs = array(); + protected $dirs = array('.', __DIR__); /** * Registers a class. @@ -164,9 +164,8 @@ class Loader { */ public function autoload($class) { $class_file = str_replace('\\', '/', str_replace('_', '/', $class)).'.php'; - $dirs = array_merge($this->dirs, array(__DIR__, '.')); - foreach ($dirs as $dir) { + foreach ($this->dirs as $dir) { $file = $dir.'/'.$class_file; if (file_exists($file)) { require $file; @@ -175,7 +174,8 @@ class Loader { } // Allow other autoloaders to run before raising an error - $loader = array_pop(spl_autoload_functions()); + $loaders = spl_autoload_functions(); + $loader = array_pop($loaders); if (is_array($loader) && $loader[0] == __CLASS__ && $loader[1] == __FUNCTION__) { throw new Exception('Unable to load file: '.$class_file); }