Removed error filtering and fixed notice errors.

pull/21/head
Mike Cao 12 years ago
parent d081879379
commit 1d84913d7f

@ -74,9 +74,6 @@ class Flight {
// Handle exceptions internally // Handle exceptions internally
set_exception_handler(array(__CLASS__, 'handleException')); set_exception_handler(array(__CLASS__, 'handleException'));
// Turn off notices
error_reporting (E_ALL ^ E_NOTICE);
// Fix magic quotes // Fix magic quotes
if (get_magic_quotes_gpc()) { if (get_magic_quotes_gpc()) {
$func = function ($value) use (&$func) { $func = function ($value) use (&$func) {
@ -132,9 +129,7 @@ class Flight {
* @param int $errline Error file line number * @param int $errline Error file line number
*/ */
public static function handleError($errno, $errstr, $errfile, $errline) { public static function handleError($errno, $errstr, $errfile, $errline) {
if (in_array($errno, array(E_USER_ERROR, E_RECOVERABLE_ERROR))) { static::handleException(new ErrorException($errstr, $errno, 0, $errfile, $errline));
static::handleException(new ErrorException($errstr, 0, $errno, $errfile, $errline));
}
} }
/** /**
@ -320,9 +315,13 @@ class Flight {
* @param object $e Exception * @param object $e Exception
*/ */
public static function _error(Exception $e) { public static function _error(Exception $e) {
$msg = '<h1>500 Internal Server Error</h1>'. $msg = sprintf('<h1>500 Internal Server Error</h1>'.
'<h3>'.$e->getMessage().'</h3>'. '<h3>%s (%s)</h3>'.
'<pre>'.$e->getTraceAsString().'</pre>'; '<pre>%s</pre>',
$e->getMessage(),
$e->getCode(),
$e->getTraceAsString()
);
try { try {
self::response(false) self::response(false)
@ -417,7 +416,8 @@ class Flight {
self::response()->header('ETag', $id); 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); self::halt(304);
} }
} }
@ -430,7 +430,8 @@ class Flight {
public static function _lastModified($time) { public static function _lastModified($time) {
self::response()->header('Last-Modified', date(DATE_RFC1123, $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); self::halt(304);
} }
} }

@ -34,7 +34,7 @@ class Loader {
* *
* @var array * @var array
*/ */
protected $dirs = array(); protected $dirs = array('.', __DIR__);
/** /**
* Registers a class. * Registers a class.
@ -164,9 +164,8 @@ class Loader {
*/ */
public function autoload($class) { public function autoload($class) {
$class_file = str_replace('\\', '/', str_replace('_', '/', $class)).'.php'; $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; $file = $dir.'/'.$class_file;
if (file_exists($file)) { if (file_exists($file)) {
require $file; require $file;
@ -175,7 +174,8 @@ class Loader {
} }
// Allow other autoloaders to run before raising an error // 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__) { if (is_array($loader) && $loader[0] == __CLASS__ && $loader[1] == __FUNCTION__) {
throw new Exception('Unable to load file: '.$class_file); throw new Exception('Unable to load file: '.$class_file);
} }

Loading…
Cancel
Save