diff --git a/framework/yii/base/Application.php b/framework/yii/base/Application.php index 0381e16..0b14a8c 100644 --- a/framework/yii/base/Application.php +++ b/framework/yii/base/Application.php @@ -475,6 +475,8 @@ abstract class Application extends Module */ public function handleFatalError() { + unset($this->_memoryReserve); + // load ErrorException manually here because autoloading them will not work // when error occurs while autoloading a class if (!class_exists('\\yii\\base\\Exception', false)) { @@ -487,7 +489,6 @@ abstract class Application extends Module $error = error_get_last(); if (ErrorException::isFatalError($error)) { - unset($this->_memoryReserve); $exception = new ErrorException($error['message'], $error['type'], $error['type'], $error['file'], $error['line']); // use error_log because it's too late to use Yii log error_log($exception); diff --git a/framework/yii/base/ErrorHandler.php b/framework/yii/base/ErrorHandler.php index 39c87b0..99428fc 100644 --- a/framework/yii/base/ErrorHandler.php +++ b/framework/yii/base/ErrorHandler.php @@ -192,11 +192,16 @@ class ErrorHandler extends Component */ public function renderFile($_file_, $_params_) { - ob_start(); - ob_implicit_flush(false); - extract($_params_, EXTR_OVERWRITE); - require(Yii::getAlias($_file_)); - return ob_get_clean(); + $_params_['handler'] = $this; + if ($this->exception instanceof ErrorException) { + ob_start(); + ob_implicit_flush(false); + extract($_params_, EXTR_OVERWRITE); + require(Yii::getAlias($_file_)); + return ob_get_clean(); + } else { + return Yii::$app->getView()->renderFile($_file_, $_params_, $this); + } } /** diff --git a/framework/yii/views/errorHandler/callStackItem.php b/framework/yii/views/errorHandler/callStackItem.php index 2cbced0..20ad398 100644 --- a/framework/yii/views/errorHandler/callStackItem.php +++ b/framework/yii/views/errorHandler/callStackItem.php @@ -8,19 +8,19 @@ * @var string[] $lines * @var integer $begin * @var integer $end - * @var \yii\base\ErrorHandler $this + * @var \yii\base\ErrorHandler $handler */ ?> -
  • . - htmlEncode($file); ?> + htmlEncode($file); ?> - addTypeLinks($class) . '::'; ?>addTypeLinks($method . '()'); ?> + addTypeLinks($class) . '::'; ?>addTypeLinks($method . '()'); ?> @@ -36,7 +36,7 @@
    htmlEncode($lines[$i]);
    +						echo (trim($lines[$i]) == '') ? " \n" : $handler->htmlEncode($lines[$i]);
     					}
     				?>
    diff --git a/framework/yii/views/errorHandler/error.php b/framework/yii/views/errorHandler/error.php index 4765bdd..46ba47f 100644 --- a/framework/yii/views/errorHandler/error.php +++ b/framework/yii/views/errorHandler/error.php @@ -1,9 +1,9 @@ htmlEncode($exception instanceof \yii\base\Exception ? $exception->getName() : get_class($exception)); +$title = $handler->htmlEncode($exception instanceof \yii\base\Exception ? $exception->getName() : get_class($exception)); ?> @@ -50,16 +50,17 @@ $title = $this->htmlEncode($exception instanceof \yii\base\Exception ? $exceptio -

    -

    htmlEncode($exception->getMessage()))?>

    -

    - The above error occurred while the Web server was processing your request. -

    -

    - Please contact us if you think this is a server error. Thank you. -

    -
    - -
    +

    +

    htmlEncode($exception->getMessage()))?>

    +

    + The above error occurred while the Web server was processing your request. +

    +

    + Please contact us if you think this is a server error. Thank you. +

    +
    + +
    + endBody(); // to allow injecting code into body (mostly by Yii Debug Toolbar) ?> diff --git a/framework/yii/views/errorHandler/exception.php b/framework/yii/views/errorHandler/exception.php index 8c6612a..7c3d277 100644 --- a/framework/yii/views/errorHandler/exception.php +++ b/framework/yii/views/errorHandler/exception.php @@ -1,7 +1,7 @@ @@ -12,11 +12,11 @@ <?php if ($exception instanceof \yii\web\HttpException) { - echo (int) $exception->statusCode . ' ' . $this->htmlEncode($exception->getName()); + echo (int) $exception->statusCode . ' ' . $handler->htmlEncode($exception->getName()); } elseif ($exception instanceof \yii\base\Exception) { - echo $this->htmlEncode($exception->getName() . ' – ' . get_class($exception)); + echo $handler->htmlEncode($exception->getName() . ' – ' . get_class($exception)); } else { - echo $this->htmlEncode(get_class($exception)); + echo $handler->htmlEncode(get_class($exception)); } ?> @@ -353,32 +353,32 @@ pre .diff .change{ Gears

    - htmlEncode($exception->getName()); ?> - – addTypeLinks(get_class($exception)); ?> + htmlEncode($exception->getName()); ?> + – addTypeLinks(get_class($exception)); ?>

    Attention

    ' . $this->createHttpStatusLink($exception->statusCode, $this->htmlEncode($exception->getName())) . ''; - echo ' – ' . $this->addTypeLinks(get_class($exception)); + echo '' . $handler->createHttpStatusLink($exception->statusCode, $handler->htmlEncode($exception->getName())) . ''; + echo ' – ' . $handler->addTypeLinks(get_class($exception)); } elseif ($exception instanceof \yii\base\Exception) { - echo '' . $this->htmlEncode($exception->getName()) . ''; - echo ' – ' . $this->addTypeLinks(get_class($exception)); + echo '' . $handler->htmlEncode($exception->getName()) . ''; + echo ' – ' . $handler->addTypeLinks(get_class($exception)); } else { - echo '' . $this->htmlEncode(get_class($exception)) . ''; + echo '' . $handler->htmlEncode(get_class($exception)) . ''; } ?>

    -

    htmlEncode($exception->getMessage()); ?>

    - renderPreviousExceptions($exception); ?> +

    htmlEncode($exception->getMessage()); ?>

    + renderPreviousExceptions($exception); ?>
    @@ -386,15 +386,15 @@ pre .diff .change{
    - renderRequest(); ?> + renderRequest(); ?>
    + endBody(); // to allow injecting code into body (mostly by Yii Debug Toolbar) ?> diff --git a/framework/yii/views/errorHandler/previousException.php b/framework/yii/views/errorHandler/previousException.php index d56f6dd..e6dcf87 100644 --- a/framework/yii/views/errorHandler/previousException.php +++ b/framework/yii/views/errorHandler/previousException.php @@ -1,7 +1,7 @@