|
@@ -73,17 +73,23 @@
|
|
$verb = Request::get_verb();
|
|
$verb = Request::get_verb();
|
|
$url = Request::get_url();
|
|
$url = Request::get_url();
|
|
$data = Request::get_body();
|
|
$data = Request::get_body();
|
|
|
|
+ if(ob_get_level() > 0){
|
|
|
|
+ ob_clean();
|
|
|
|
+ }
|
|
foreach(static::$apps as $k => $app){
|
|
foreach(static::$apps as $k => $app){
|
|
if($app instanceof App){
|
|
if($app instanceof App){
|
|
$app->handle($verb, $url, $data)->shutdown();
|
|
$app->handle($verb, $url, $data)->shutdown();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ while(ob_get_level() > 0){
|
|
|
|
+ ob_end_flush();
|
|
|
|
+ }
|
|
if(is_callable('parent::__destruct')){
|
|
if(is_callable('parent::__destruct')){
|
|
parent::__destruct();
|
|
parent::__destruct();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
public static function shutdown_error($error){
|
|
public static function shutdown_error($error){
|
|
- if(count(ob_list_handlers())){
|
|
|
|
|
|
+ while(ob_get_level() > 0){
|
|
ob_end_clean();
|
|
ob_end_clean();
|
|
}
|
|
}
|
|
if(count(static::$apps)){
|
|
if(count(static::$apps)){
|
|
@@ -95,6 +101,7 @@
|
|
$app->onerror($app->request, $app->response, $error);
|
|
$app->onerror($app->request, $app->response, $error);
|
|
$app->response->shutdown();
|
|
$app->response->shutdown();
|
|
}
|
|
}
|
|
|
|
+ flush();
|
|
}else{
|
|
}else{
|
|
$res =new Response();
|
|
$res =new Response();
|
|
$res->code(500)
|
|
$res->code(500)
|
|
@@ -126,7 +133,7 @@
|
|
while(is_string($router)){
|
|
while(is_string($router)){
|
|
$router = $this->domains[$router];
|
|
$router = $this->domains[$router];
|
|
}
|
|
}
|
|
- $router->handle($url["path"], $req, $res, null, $onerror);
|
|
|
|
|
|
+ $router->handle($url['path'], $req, $res, null, $onerror);
|
|
$handled = $handled || $router->handled;
|
|
$handled = $handled || $router->handled;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -140,7 +147,7 @@
|
|
// Base router for non-prefixed paths
|
|
// Base router for non-prefixed paths
|
|
$this->router->handle($url["path"], $req, $res, function($req, $res) use($handled, $self, $url){
|
|
$this->router->handle($url["path"], $req, $res, function($req, $res) use($handled, $self, $url){
|
|
if(!$handled){
|
|
if(!$handled){
|
|
- $self->onerror($req, $res, new Exception("{$url['scheme']}://{$url['host']}{$url["path"]} Not Found", 404));
|
|
|
|
|
|
+ $self->onerror($req, $res, new \Exception("{$url['scheme']}://{$url['host']}{$url["path"]} Not Found", 404));
|
|
}
|
|
}
|
|
}, $onerror);
|
|
}, $onerror);
|
|
$this->fire('afterhandle', $req, $res);
|
|
$this->fire('afterhandle', $req, $res);
|
|
@@ -213,7 +220,7 @@
|
|
if(is_callable($fn)){
|
|
if(is_callable($fn)){
|
|
$fn($req, $res, $error);
|
|
$fn($req, $res, $error);
|
|
}
|
|
}
|
|
- }catch(Exception $e){
|
|
|
|
|
|
+ }catch(\Exception $e){
|
|
die("Error handlers failed {$e}");
|
|
die("Error handlers failed {$e}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -228,14 +235,18 @@
|
|
App::shutdown_error($error);
|
|
App::shutdown_error($error);
|
|
});
|
|
});
|
|
set_error_handler(function($errno, $errstr, $errfile, $errline){
|
|
set_error_handler(function($errno, $errstr, $errfile, $errline){
|
|
- App::shutdown_error(App\Exception($errstr, $errno, null, $errfile, $errline, debug_backtrace()));
|
|
|
|
- }, E_ALL & ~E_WARNING);
|
|
|
|
|
|
+ // ignore warnings
|
|
|
|
+ if($errno &~ E_WARNING){
|
|
|
|
+ App::shutdown_error(new Exception($errstr, $errno, null, $errfile, $errline, debug_backtrace()));
|
|
|
|
+ die();
|
|
|
|
+ }
|
|
|
|
+ }, E_ALL);
|
|
register_shutdown_function(function(){
|
|
register_shutdown_function(function(){
|
|
- error_reporting(E_ALL & ~E_WARNING);
|
|
|
|
- ini_set('display_errors', 'On');
|
|
|
|
|
|
+ error_reporting(E_ALL &~ E_WARNING);
|
|
|
|
+ ini_set('display_errors', 'Off');
|
|
App::shutdown();
|
|
App::shutdown();
|
|
});
|
|
});
|
|
- error_reporting(E_ALL & ~E_WARNING);
|
|
|
|
- ini_set('display_errors', 'On');
|
|
|
|
|
|
+ error_reporting(E_ALL &~ E_WARNING);
|
|
|
|
+ ini_set('display_errors', 'Off');
|
|
gc_enable();
|
|
gc_enable();
|
|
?>
|
|
?>
|