From 89bbdae6c11ad1666c646257dac1ede9d8bae508 Mon Sep 17 00:00:00 2001 From: resurtm Date: Thu, 23 May 2013 22:34:37 +0600 Subject: [PATCH 01/10] Initial version of the new error/exception page. --- apps/bootstrap/controllers/SiteController.php | 1 + apps/bootstrap/www/index.php | 5 +- framework/yii/base/ErrorHandler.php | 215 +++--------------- framework/yii/views/errorHandler.php | 303 ++++++++++++++++++++++++++ 4 files changed, 333 insertions(+), 191 deletions(-) create mode 100644 framework/yii/views/errorHandler.php diff --git a/apps/bootstrap/controllers/SiteController.php b/apps/bootstrap/controllers/SiteController.php index ff3b8b4..4c00cea 100644 --- a/apps/bootstrap/controllers/SiteController.php +++ b/apps/bootstrap/controllers/SiteController.php @@ -20,6 +20,7 @@ class SiteController extends Controller public function actionIndex() { + throw new \yii\base\HttpException(500, 'Test exception'); echo $this->render('index'); } diff --git a/apps/bootstrap/www/index.php b/apps/bootstrap/www/index.php index 3b7b2fc..cb363a0 100644 --- a/apps/bootstrap/www/index.php +++ b/apps/bootstrap/www/index.php @@ -3,8 +3,9 @@ // comment out the following line to disable debug mode defined('YII_DEBUG') or define('YII_DEBUG', true); -require(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php'); -require(__DIR__ . '/../vendor/autoload.php'); +//require(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php'); +//require(__DIR__ . '/../vendor/autoload.php'); +require(__DIR__ . '/../../../framework/yii/Yii.php'); $config = require(__DIR__ . '/../config/main.php'); diff --git a/framework/yii/base/ErrorHandler.php b/framework/yii/base/ErrorHandler.php index 8340723..09e4a59 100644 --- a/framework/yii/base/ErrorHandler.php +++ b/framework/yii/base/ErrorHandler.php @@ -7,6 +7,8 @@ namespace yii\base; +use Yii; + /** * ErrorHandler handles uncaught PHP errors and exceptions. * @@ -31,28 +33,25 @@ class ErrorHandler extends Component */ public $discardExistingOutput = true; /** - * @var string the route (eg 'site/error') to the controller action that will be used to display external errors. - * Inside the action, it can retrieve the error information by \Yii::$app->errorHandler->error. - * This property defaults to null, meaning ErrorHandler will handle the error display. + * @var string the route (e.g. 'site/error') to the controller action that will be used + * to display external errors. Inside the action, it can retrieve the error information + * by Yii::$app->errorHandler->error. This property defaults to null, meaning ErrorHandler + * will handle the error display. */ public $errorAction; /** - * @var string the path of the view file for rendering exceptions - */ - public $exceptionView = '@yii/views/exception.php'; - /** - * @var string the path of the view file for rendering errors + * @var string the path of the view file for rendering exceptions and errors. */ - public $errorView = '@yii/views/error.php'; + public $view = '@yii/views/errorHandler.php'; /** - * @var \Exception the exception that is being handled currently + * @var \Exception the exception that is being handled currently. */ public $exception; /** - * Handles exception - * @param \Exception $exception + * Handles exception. + * @param \Exception $exception to be handled. */ public function handle($exception) { @@ -66,14 +65,16 @@ class ErrorHandler extends Component } /** - * Renders exception - * @param \Exception $exception + * Renders exception. + * @param \Exception $exception to be handled. */ protected function renderException($exception) { if ($this->errorAction !== null) { - \Yii::$app->runAction($this->errorAction); - } elseif (\Yii::$app instanceof \yii\web\Application) { + Yii::$app->runAction($this->errorAction); + } elseif (!(Yii::$app instanceof \yii\web\Application)) { + Yii::$app->renderException($exception); + } else { if (!headers_sent()) { if ($exception instanceof HttpException) { header('HTTP/1.0 ' . $exception->statusCode . ' ' . $exception->getName()); @@ -82,7 +83,7 @@ class ErrorHandler extends Component } } if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') { - \Yii::$app->renderException($exception); + Yii::$app->renderException($exception); } else { // if there is an error during error rendering it's useful to // display PHP error in debug mode instead of a blank screen @@ -90,177 +91,25 @@ class ErrorHandler extends Component ini_set('display_errors', 1); } - $view = new View; - if (!YII_DEBUG || $exception instanceof UserException) { - $viewName = $this->errorView; - } else { - $viewName = $this->exceptionView; - } - echo $view->renderFile($viewName, array( - 'exception' => $exception, - ), $this); - } - } else { - \Yii::$app->renderException($exception); - } - } - - /** - * Returns server and Yii version information. - * @return string server version information. - */ - public function getVersionInfo() - { - $version = 'Yii Framework/' . \Yii::getVersion(); - if (isset($_SERVER['SERVER_SOFTWARE'])) { - $version = $_SERVER['SERVER_SOFTWARE'] . ' ' . $version; - } - return $version; - } - - /** - * Converts arguments array to its string representation - * - * @param array $args arguments array to be converted - * @return string string representation of the arguments array - */ - public function argumentsToString($args) - { - $isAssoc = $args !== array_values($args); - $count = 0; - foreach ($args as $key => $value) { - $count++; - if ($count >= 5) { - if ($count > 5) { - unset($args[$key]); - } else { - $args[$key] = '...'; - } - continue; - } - - if (is_object($value)) { - $args[$key] = get_class($value); - } elseif (is_bool($value)) { - $args[$key] = $value ? 'true' : 'false'; - } elseif (is_string($value)) { - if (strlen($value) > 64) { - $args[$key] = '"' . substr($value, 0, 64) . '..."'; - } else { - $args[$key] = '"' . $value . '"'; - } - } elseif (is_array($value)) { - $args[$key] = 'array(' . $this->argumentsToString($value) . ')'; - } elseif ($value === null) { - $args[$key] = 'null'; - } elseif (is_resource($value)) { - $args[$key] = 'resource'; - } - - if (is_string($key)) { - $args[$key] = '"' . $key . '" => ' . $args[$key]; - } elseif ($isAssoc) { - $args[$key] = $key . ' => ' . $args[$key]; + $view = new View(); + echo $view->renderFile($this->view, array('e' => $exception), $this); } } - return implode(', ', $args); } /** - * Returns a value indicating whether the call stack is from application code. - * @param array $trace the trace data - * @return boolean whether the call stack is from application code. + * Converts special characters to HTML entities. + * @param string $text to encode. + * @return string encoded text. */ - public function isCoreCode($trace) - { - if (isset($trace['file'])) { - return $trace['file'] === 'unknown' || strpos(realpath($trace['file']), YII_PATH . DIRECTORY_SEPARATOR) === 0; - } - return false; - } - - /** - * Renders the source code around the error line. - * @param string $file source file path - * @param integer $errorLine the error line number - * @param integer $maxLines maximum number of lines to display - */ - public function renderSourceCode($file, $errorLine, $maxLines) + public function htmlEncode($text) { - $errorLine--; // adjust line number to 0-based from 1-based - if ($errorLine < 0 || ($lines = @file($file)) === false || ($lineCount = count($lines)) <= $errorLine) { - return; - } - - $halfLines = (int)($maxLines / 2); - $beginLine = $errorLine - $halfLines > 0 ? $errorLine - $halfLines : 0; - $endLine = $errorLine + $halfLines < $lineCount ? $errorLine + $halfLines : $lineCount - 1; - $lineNumberWidth = strlen($endLine + 1); - - $output = ''; - for ($i = $beginLine; $i <= $endLine; ++$i) { - $isErrorLine = $i === $errorLine; - $code = sprintf("%0{$lineNumberWidth}d %s", $i + 1, $this->htmlEncode(str_replace("\t", ' ', $lines[$i]))); - if (!$isErrorLine) { - $output .= $code; - } else { - $output .= '' . $code . ''; - } - } - echo '
' . $output . '
'; + return htmlspecialchars($text, ENT_QUOTES, Yii::$app->charset); } /** - * Renders calls stack trace - * @param array $trace + * Removes all output echoed before calling this method. */ - public function renderTrace($trace) - { - $count = 0; - echo "\n"; - foreach ($trace as $n => $t) { - if ($this->isCoreCode($t)) { - $cssClass = 'core collapsed'; - } elseif (++$count > 3) { - $cssClass = 'app collapsed'; - } else { - $cssClass = 'app expanded'; - } - - $hasCode = isset($t['file']) && $t['file'] !== 'unknown' && is_file($t['file']); - echo "\n"; - } - echo '
#$n"; - echo '
'; - if ($hasCode) { - echo '
+
-
'; - } - echo ' '; - if (isset($t['file'])) { - echo $this->htmlEncode($t['file']) . '(' . $t['line'] . '): '; - } - if (!empty($t['class'])) { - echo '' . $t['class'] . '' . $t['type']; - } - echo '' . $t['function'] . ''; - echo '(' . (empty($t['args']) ? '' : $this->htmlEncode($this->argumentsToString($t['args']))) . ')'; - echo '
'; - if ($hasCode) { - $this->renderSourceCode($t['file'], $t['line'], $this->maxTraceSourceLines); - } - echo "
'; - } - - /** - * Converts special characters to HTML entities - * @param string $text text to encode - * @return string - */ - public function htmlEncode($text) - { - return htmlspecialchars($text, ENT_QUOTES, \Yii::$app->charset); - } - public function clearOutput() { // the following manual level counting is to deal with zlib.output_compression set to On @@ -268,16 +117,4 @@ class ErrorHandler extends Component @ob_end_clean(); } } - - /** - * @param \Exception $exception - */ - public function renderAsHtml($exception) - { - $view = new View; - $name = !YII_DEBUG || $exception instanceof HttpException ? $this->errorView : $this->exceptionView; - echo $view->renderFile($name, array( - 'exception' => $exception, - ), $this); - } } diff --git a/framework/yii/views/errorHandler.php b/framework/yii/views/errorHandler.php new file mode 100644 index 0000000..92aa812 --- /dev/null +++ b/framework/yii/views/errorHandler.php @@ -0,0 +1,303 @@ +context; +$title = $c->htmlEncode($e instanceof \yii\base\Exception ? $e->getName() : get_class($e)); +?> + + + + + + + <?php echo $title; ?> + + + + + + + +
+ Attention +

Exceptionyii\base\HttpException – 404

+

Requested user cannot be found!

+
+ +
+
+
$_GET = [
+	'show-post' => 100,
+	'refresh-page' => 'yes',
+	'ascending-sort' => 1,
+];
+
+$_POST = [
+	'blog-post-form' => [
+		'title' => 'hello',
+		'author_id' => '12',
+	],
+];
+
+$_SERVER = [
+	'DOCUMENT_ROOT' => '/home/resurtm/work/data',
+	'REMOTE_ADDR' => '::1',
+	'REMOTE_PORT' => '52694',
+	'SERVER_SOFTWARE' => 'PHP 5.4.3 Development Server',
+	'SERVER_PROTOCOL' => 'HTTP/1.1',
+	'SERVER_NAME' => 'localhost',
+	'SERVER_PORT' => '8000',
+	'REQUEST_URI' => '/index.php?post-form[title]=hello&post-form[author_id]=12',
+	'REQUEST_METHOD' => 'GET',
+	'SCRIPT_NAME' => '/index.php',
+	'SCRIPT_FILENAME' => '/home/resurtm/work/data/index.php',
+	'PHP_SELF' => '/index.php',
+	'QUERY_STRING' => 'post-form[title]=hello&post-form[author_id]=12',
+	'HTTP_HOST' => 'localhost:8000',
+	'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0',
+	'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
+	'HTTP_ACCEPT_LANGUAGE' => 'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3',
+	'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
+	'HTTP_CONNECTION' => 'keep-alive',
+	'REQUEST_TIME_FLOAT' => 1369146454.0856,
+	'REQUEST_TIME' => 1369146454,
+];
+
+ + + + + + + + + + + From 0963cf8b7b034740776c050545a01d0a94dbfdaf Mon Sep 17 00:00:00 2001 From: resurtm Date: Thu, 23 May 2013 22:53:17 +0600 Subject: [PATCH 02/10] Minor enhancements. --- framework/yii/views/errorHandler.php | 41 ++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/framework/yii/views/errorHandler.php b/framework/yii/views/errorHandler.php index 92aa812..a7fe09a 100644 --- a/framework/yii/views/errorHandler.php +++ b/framework/yii/views/errorHandler.php @@ -147,12 +147,21 @@ $title = $c->htmlEncode($e instanceof \yii\base\Exception ? $e->getName() : get_ } /* code */ + #code-wrap{ + overflow: hidden; + position: relative; + } #code-highlighter{ background-color: #ffffff; position: fixed; width: 100%; z-index: 100; } + #code-inner-wrap{ + min-width: 860px; /* padding compensation: 960px - 50px * 2 */ + max-width: 1100px; /* padding compensation: 1200px - 50px * 2 */ + margin: 0 auto; + } pre{ display: inline; color: #505050; @@ -223,8 +232,10 @@ $title = $c->htmlEncode($e instanceof \yii\base\Exception ? $e->getName() : get_
-
-
$_GET = [
+		
+
+
+
$_GET = [
 	'show-post' => 100,
 	'refresh-page' => 'yes',
 	'ascending-sort' => 1,
@@ -260,6 +271,8 @@ $_SERVER = [
 	'REQUEST_TIME_FLOAT' => 1369146454.0856,
 	'REQUEST_TIME' => 1369146454,
 ];
+
+
- - + + - - + +
+
+
+
+ + 10
11
12
13
14
15
16
17
18
19
20
21
22
+ 23
24
25
26
27
28
29
30
31
32
33
34 +
+
	{
+		return array(
+			'captcha' => array(
+				'class' => 'yii\web\CaptchaAction',
+			),
+		);
+	}
+
+	public function actionIndex()
+	{
+//		throw new \yii\base\HttpException(500);
+		$x = null;
+		$x->y = 1;
+
+		echo $this->render('index');
+	}
+
+	public function actionLogin()
+	{
+		$model = new LoginForm();
+		if ($this->populate($_POST, $model) && $model->login()) {
+			Yii::$app->response->redirect(array('site/index'));
+		} else {
+			echo $this->render('login', array(
+				'model' => $model,
+
+
+ +
- Attention -

Exceptionyii\base\HttpException – 404

+ Attention +

Exceptionyii\base\HttpException – 404

Requested user cannot be found!

+
+
    +
  • +
    +
    + 1. + in C:\_work\jetbrains\yii2\apps\bootstrap\protected\controllers\SiteController.php + at line + 22 +
    +
    + +
  • +
  • +
    +
    + 2. + at C:\_work\jetbrains\yii2\yii\base\InlineAction.php – + call_user_func_array() + at line + 47 +
    +
    + +
  • +
  • +
    +
    + 3. + at C:\_work\jetbrains\yii2\yii\base\Controller.php – + yii\base\InlineActionrunWithParams() + at line + 117 +
    +
    + +
  • +
  • +
    +
    + 4. + at C:\_work\jetbrains\yii2\yii\web\Application.php – + yii\base\ModulerunAction() + at line + 35 +
    +
    + +
  • +
  • +
    +
    + 5. + at C:\_work\jetbrains\yii2\yii\web\Application.php – + yii\base\ModulerunAction() + at line + 35 +
    +
    + +
  • +
  • +
    +
    + 6. + at C:\_work\jetbrains\yii2\yii\base\Application.php – + yii\web\ApplicationprocessRequest() + at line + 146 +
    +
    + +
  • +
  • +
    +
    + 7. + at C:\_work\jetbrains\yii2\apps\bootstrap\index.php – + yii\base\Applicationrun() + at line + 14 +
    +
    + +
  • +
+
+ +
@@ -264,7 +188,6 @@ $_SERVER = [ 'QUERY_STRING' => 'post-form[title]=hello&post-form[author_id]=12', 'HTTP_HOST' => 'localhost:8000', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0', - 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_LANGUAGE' => 'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_CONNECTION' => 'keep-alive', @@ -273,46 +196,14 @@ $_SERVER = [ ]; - + */ ?> - - - - From fa0022e7e11089d6490c1d1f3d9be550f45affcf Mon Sep 17 00:00:00 2001 From: resurtm Date: Sat, 25 May 2013 20:54:20 +0600 Subject: [PATCH 04/10] New error/exception page WIP. --- apps/bootstrap/controllers/SiteController.php | 1 + apps/bootstrap/www/tmp/main.css | 99 ++++------ apps/bootstrap/www/tmp/main.js | 81 ++++---- framework/yii/base/ErrorHandler.php | 119 +++++++++++- framework/yii/views/errorHandler.php | 209 --------------------- framework/yii/views/errorHandler/callStackItem.php | 34 ++++ framework/yii/views/errorHandler/main.php | 101 ++++++++++ 7 files changed, 322 insertions(+), 322 deletions(-) delete mode 100644 framework/yii/views/errorHandler.php create mode 100644 framework/yii/views/errorHandler/callStackItem.php create mode 100644 framework/yii/views/errorHandler/main.php diff --git a/apps/bootstrap/controllers/SiteController.php b/apps/bootstrap/controllers/SiteController.php index 4c00cea..4652430 100644 --- a/apps/bootstrap/controllers/SiteController.php +++ b/apps/bootstrap/controllers/SiteController.php @@ -21,6 +21,7 @@ class SiteController extends Controller public function actionIndex() { throw new \yii\base\HttpException(500, 'Test exception'); + $x = 1; echo $this->render('index'); } diff --git a/apps/bootstrap/www/tmp/main.css b/apps/bootstrap/www/tmp/main.css index 334bc82..69ca6f7 100644 --- a/apps/bootstrap/www/tmp/main.css +++ b/apps/bootstrap/www/tmp/main.css @@ -50,9 +50,6 @@ h1,h2,p,img,ul li{ font-family: Arial,sans-serif; color: #505050; } -body,html{ - /*overflow-x: hidden;*/ -} /* header */ .header{ @@ -85,70 +82,70 @@ body,html{ text-shadow: 0 1px 0 #cacaca; } -/* traceback */ -.traceback{ +/* call stack */ +.call-stack{ margin-top: 30px; margin-bottom: 40px; } -.traceback ul li{ +.call-stack ul li{ margin: 1px 0; } -.traceback ul li .li-wrap{ +.call-stack ul li .element-wrap{ cursor: pointer; padding: 15px 0; } -.traceback ul li.application .li-wrap{ +.call-stack ul li.application .element-wrap{ background-color: #fafafa; } -.traceback ul li .li-wrap:hover{ +.call-stack ul li .element-wrap:hover{ background-color: #edf9ff; } -.traceback ul li .li{ +.call-stack ul li .element{ min-width: 860px; /* 960px - 50px * 2 */ max-width: 1100px; /* 1200px - 50px * 2 */ margin: 0 auto; padding: 0 50px; position: relative; } -.traceback ul li a{ +.call-stack ul li a{ color: #505050; } -.traceback ul li a:hover{ +.call-stack ul li a:hover{ color: #000000; text-shadow: 0 1px 0 #cacaca; } -.traceback ul li .number{ +.call-stack ul li .number{ width: 45px; display: inline-block; } -.traceback ul li .text{ +.call-stack ul li .text{ color: #bbbbbb; } -.traceback ul li.application .text{ +.call-stack ul li.application .text{ color: #505050; } -.traceback ul li .at{ +.call-stack ul li .at{ position: absolute; right: 110px; /* 50px + 60px */ color: #bbbbbb; } -.traceback ul li.application .at{ +.call-stack ul li.application .at{ color: #505050; } -.traceback ul li .line{ +.call-stack ul li .line{ position: absolute; right: 50px; width: 60px; text-align: right; } -.traceback ul li .code-wrap{ +.call-stack ul li .code-wrap{ display: none; position: relative; } -.traceback ul li.application .code-wrap{ +.call-stack ul li.application .code-wrap{ display: block; } -.traceback ul li .error-line{ +.call-stack ul li .error-line,.call-stack ul li .hover-line{ background-color: #ffebeb; position: absolute; width: 100%; @@ -156,29 +153,36 @@ body,html{ z-index: 100; margin-top: 15px; } -.traceback ul li .code{ +.call-stack ul li .hover-line{ + background: none; +} +.call-stack ul li .hover-line.hover,.call-stack ul li .hover-line:hover{ + background: #edf9ff !important; +} +.call-stack ul li .code{ min-width: 860px; /* 960px - 50px * 2 */ max-width: 1100px; /* 1200px - 50px * 2 */ margin: 0 auto; padding: 15px 50px; position: relative; } -.traceback ul li .code .lines{ +.call-stack ul li .code .lines{ position: absolute; z-index: 200; left: 50px; line-height: 18px; font-size: 14px; - font-family: Consolas, Courier New, monospaced; + font-family: Consolas, Courier New, monospace; color: #bbbbbb; } -.traceback ul li .code pre{ +.call-stack ul li .code pre{ position: relative; z-index: 200; left: 50px; line-height: 18px; font-size: 14px; - font-family: Consolas, Courier New, monospaced; + font-family: Consolas, Courier New, monospace; + display: inline; } /* request */ @@ -190,15 +194,15 @@ body,html{ margin-bottom: 1px; } .request pre{ - font-family: Consolas, Courier New, monospaced; + font-family: Consolas, Courier New, monospace; } /* footer */ .footer{ position: relative; height: 222px; - min-width: 860px; /* padding compensation: 960px - 50px * 2 */ - max-width: 1100px; /* padding compensation: 1200px - 50px * 2 */ + min-width: 860px; /* 960px - 50px * 2 */ + max-width: 1100px; /* 1200px - 50px * 2 */ padding: 0 50px; margin: 1px auto 0 auto; } @@ -223,30 +227,7 @@ body,html{ right: -50px; } -/* code */ -#code-wrap{ - overflow: hidden; - position: relative; -} -#code-highlighter{ - background-color: #ffffff; - position: fixed; - width: 100%; - z-index: 100; -} -#code-inner-wrap{ - min-width: 860px; /* padding compensation: 960px - 50px * 2 */ - max-width: 1100px; /* padding compensation: 1200px - 50px * 2 */ - margin: 0 auto; -} -pre{ - display: inline; - color: #505050; - font-size: 14px; - line-height: 18px; - z-index: 200; - position: relative; -} +/* highlight.js */ pre .subst,pre .title{ font-weight: normal; color: #505050; @@ -255,16 +236,16 @@ pre .comment,pre .template_comment,pre .javadoc,pre .diff .header{ color: #808080; font-style: italic; } -pre .annotation,pre .decorator,pre .preprocessor,pre .doctype,pre .pi,pre .chunk,pre .shebang, -pre .apache .cbracket,pre .prompt,pre .http .title{ +pre .annotation,pre .decorator,pre .preprocessor,pre .doctype,pre .pi,pre .chunk,pre .shebang,pre .apache .cbracket, +pre .prompt,pre .http .title{ color: #808000; } pre .tag,pre .pi{ background: #efefef; } -pre .tag .title,pre .id,pre .attr_selector,pre .pseudo,pre .literal,pre .keyword,pre .hexcolor, -pre .css .function,pre .ini .title,pre .css .class,pre .list .title,pre .clojure .title,pre .nginx .title, -pre .tex .command,pre .request,pre .status{ +pre .tag .title,pre .id,pre .attr_selector,pre .pseudo,pre .literal,pre .keyword,pre .hexcolor,pre .css .function, +pre .ini .title,pre .css .class,pre .list .title,pre .clojure .title,pre .nginx .title,pre .tex .command, +pre .request,pre .status{ color: #000080; } pre .attribute,pre .rules .keyword,pre .number,pre .date,pre .regexp,pre .tex .special{ @@ -273,7 +254,7 @@ pre .attribute,pre .rules .keyword,pre .number,pre .date,pre .regexp,pre .tex .s pre .number,pre .regexp{ font-weight: normal; } -pre .string,pre .value,pre .filter .argument,pre .css .function .params,pre .apache .tag { +pre .string,pre .value,pre .filter .argument,pre .css .function .params,pre .apache .tag{ color: #00aa00; } pre .symbol,pre .ruby .symbol .string,pre .char,pre .tex .formula{ diff --git a/apps/bootstrap/www/tmp/main.js b/apps/bootstrap/www/tmp/main.js index 2bd4980..020ce41 100644 --- a/apps/bootstrap/www/tmp/main.js +++ b/apps/bootstrap/www/tmp/main.js @@ -1,58 +1,43 @@ -/*; - -var lines = null; -var line = document.getElementById('code-highlighter') - -var updateLines = function() { - lines = document.getElementById('code').getClientRects(); -}; -updateLines(); -window.onresize = updateLines; -window.onscroll = updateLines; - -document.onmousemove = function(e) { - var event = e || window.event; - var x = event.clientX, y = event.clientY; - for (var i = 0, max = lines.length; i < max; i++) { - if (y > lines[i].top && y < lines[i].bottom) { - line.style.height = parseInt(lines[i].bottom - lines[i].top + 1) + 'px'; - line.style.top = parseInt(lines[i].top) + 'px'; - break; - } - } -} -*/ - window.onload = function() { - var i, j, max, max2, + var i, imax, codeBlocks = Sizzle('pre'), - traceBackItems = Sizzle('.trace-back-item'); + callStackItems = Sizzle('.call-stack-item'); - // highlight code - for (i = 0, max = codeBlocks.length; i < max; i++) { + // highlight code blocks + for (i = 0, imax = codeBlocks.length; i < imax; ++i) { hljs.highlightBlock(codeBlocks[i], ' '); } - // error lines -// var updateErrorLines = function() { -// for (i = 0, max = codeBlocks.length; i < max; i++) { -// var lines = codeBlocks[i].getClientRects(), -// errorLine = codeBlocks[i].getAttribute('data-error-line'), -// top = 0; -// if (errorLine > lines.length - 1) { -// errorLine = lines.length - 1; -// } -// for (j = 0; j < errorLine; j++) { -// top += lines[j].height; -// } -// Sizzle('.error-line', codeBlocks[i].parentNode.parentNode)[0].style.marginTop = top + 'px'; -// } -// }; -// updateErrorLines(); + // + document.onmousemove = function(e) { + var lines, i, imax, j, jmax, k, kmax, + event = e || window.event, + y = event.clientY, + lineFound = false; + for (i = 0, imax = codeBlocks.length; i < imax; ++i) { + lines = codeBlocks[i].getClientRects(); + for (j = 0, jmax = lines.length; j < jmax; ++j) { + if (y > lines[j].top && y < lines[j].bottom) { + lineFound = true; + break; + } + } + if (lineFound) { + break; + } + } + var hoverLines = Sizzle('.hover-line'); + for (k = 0, kmax = hoverLines.length; k < kmax; ++k) { + hoverLines[k].className = 'hover-line'; + } + if (lineFound) { + Sizzle('.call-stack-item:eq(' + i + ') .hover-line:eq(' + j + ')')[0].className = 'hover-line hover'; + } + } - // toggle code block visibility of each trace back item - for (i = 0, max = traceBackItems.length; i < max; i++) { - Sizzle('.li-wrap', traceBackItems[i])[0].addEventListener('click', function() { + // toggle code block visibility + for (i = 0, imax = callStackItems.length; i < imax; i++) { + Sizzle('.element-wrap', callStackItems[i])[0].addEventListener('click', function() { var code = Sizzle('.code-wrap', this.parentNode)[0]; code.style.display = window.getComputedStyle(code).display == 'block' ? 'none' : 'block'; }); diff --git a/framework/yii/base/ErrorHandler.php b/framework/yii/base/ErrorHandler.php index 09e4a59..4c6e8eb 100644 --- a/framework/yii/base/ErrorHandler.php +++ b/framework/yii/base/ErrorHandler.php @@ -16,6 +16,7 @@ use Yii; * nature of the errors and the mode the application runs at. * * @author Qiang Xue + * @author Timur Ruziev * @since 2.0 */ class ErrorHandler extends Component @@ -42,7 +43,11 @@ class ErrorHandler extends Component /** * @var string the path of the view file for rendering exceptions and errors. */ - public $view = '@yii/views/errorHandler.php'; + public $mainView = '@yii/views/errorHandler/main.php'; + /** + * @var string the path of the view file for rendering exceptions and errors call stack element. + */ + public $callStackItemView = '@yii/views/errorHandler/callStackItem.php'; /** * @var \Exception the exception that is being handled currently. */ @@ -56,11 +61,9 @@ class ErrorHandler extends Component public function handle($exception) { $this->exception = $exception; - if ($this->discardExistingOutput) { $this->clearOutput(); } - $this->renderException($exception); } @@ -90,9 +93,8 @@ class ErrorHandler extends Component if (YII_DEBUG) { ini_set('display_errors', 1); } - $view = new View(); - echo $view->renderFile($this->view, array('e' => $exception), $this); + echo $view->renderFile($this->mainView, array('e' => $exception), $this); } } } @@ -100,7 +102,7 @@ class ErrorHandler extends Component /** * Converts special characters to HTML entities. * @param string $text to encode. - * @return string encoded text. + * @return string encoded original text. */ public function htmlEncode($text) { @@ -117,4 +119,109 @@ class ErrorHandler extends Component @ob_end_clean(); } } + + /** + * Adds informational links to the given PHP type/class. + * @param string $code type/class name to be linkified. + * @return string linkified with HTML type/class name. + */ + public function addTypeLinks($code) + { + $html = ''; + if (strpos($code, '\\') !== false) { + // namespaced class + foreach (explode('\\', $code) as $part) { + $html .= '' . $this->htmlEncode($part) . '\\'; + } + $html = rtrim($html, '\\'); + } + return $html; + } + + /** + * Creates HTML containing link to the page with the information on given HTTP status code. + * @param integer $statusCode to be used to generate information link. + * @return string generated HTML with HTTP status code information. + */ + public function createHttpStatusLink($statusCode) + { + return '' . (int)$statusCode . ''; + } + + /** + * Renders a single call stack element. + * @param string $file name where call has happened. + * @param integer $line number on which call has happened. + * @param integer $index number of the call stack element. + * @return string HTML content of the rendered call stack element. + */ + public function renderCallStackItem($file, $line, $index) + { + $line--; // adjust line number from one-based to zero-based + $lines = @file($file); + if ($line < 0 || $lines === false || ($lineCount = count($lines)) < $line + 1) { + return ''; + } + + $half = (int)(($index == 0 ? $this->maxSourceLines : $this->maxTraceSourceLines) / 2); + $begin = $line - $half > 0 ? $line - $half : 0; + $end = $line + $half < $lineCount ? $line + $half : $lineCount - 1; + + $view = new View(); + return $view->renderFile($this->callStackItemView, array( + 'file' => $file, + 'line' => $line, + 'index' => $index, + 'lines' => $lines, + 'begin' => $begin, + 'end' => $end, + ), $this); + } + + /** + * Determines whether given name of the file belongs to the framework. + * @param string $file name to be checked. + * @return boolean whether given name of the file belongs to the framework. + */ + public function isCoreFile($file) + { + return $file === 'unknown' || strpos(realpath($file), YII_PATH . DIRECTORY_SEPARATOR) === 0; + } + + /** + * Creates string containing HTML link which refers to the home page of determined web-server software + * and its full name. + * @return string server software information hyperlink. + */ + public function createServerInformationLink() + { + static $serverUrls = array( + 'http://httpd.apache.org/' => array('apache'), + 'http://nginx.org/' => array('nginx'), + 'http://lighttpd.net/' => array('lighttpd'), + 'http://gwan.com/' => array('g-wan', 'gwan'), + 'http://iis.net/' => array('iis', 'services'), + 'http://php.net/manual/en/features.commandline.webserver.php' => array('development'), + ); + if (isset($_SERVER['SERVER_SOFTWARE'])) { + foreach ($serverUrls as $url => $keywords) { + foreach ($keywords as $keyword) { + if (stripos($_SERVER['SERVER_SOFTWARE'], $keyword) !== false ) { + return '' . $this->htmlEncode($_SERVER['SERVER_SOFTWARE']) . ''; + } + } + } + } + return ''; + } + + /** + * Creates string containing HTML link which refers to the page with the current version + * of the framework and version number text. + * @return string framework version information hyperlink. + */ + public function createFrameworkVersionLink() + { + return '' . $this->htmlEncode(Yii::getVersion()) . ''; + } } diff --git a/framework/yii/views/errorHandler.php b/framework/yii/views/errorHandler.php deleted file mode 100644 index 7589a96..0000000 --- a/framework/yii/views/errorHandler.php +++ /dev/null @@ -1,209 +0,0 @@ -context; -?> - - - - - - - - - - - - - - - - -
-
-
-
- - 10
11
12
13
14
15
16
17
18
19
20
21
22
- 23
24
25
26
27
28
29
30
31
32
33
34 -
-
	{
-		return array(
-			'captcha' => array(
-				'class' => 'yii\web\CaptchaAction',
-			),
-		);
-	}
-
-	public function actionIndex()
-	{
-//		throw new \yii\base\HttpException(500);
-		$x = null;
-		$x->y = 1;
-
-		echo $this->render('index');
-	}
-
-	public function actionLogin()
-	{
-		$model = new LoginForm();
-		if ($this->populate($_POST, $model) && $model->login()) {
-			Yii::$app->response->redirect(array('site/index'));
-		} else {
-			echo $this->render('login', array(
-				'model' => $model,
-
-
- - - -
- Attention -

Exceptionyii\base\HttpException – 404

-

Requested user cannot be found!

-
- -
-
    -
  • -
    -
    - 1. - in C:\_work\jetbrains\yii2\apps\bootstrap\protected\controllers\SiteController.php - at line - 22 -
    -
    - -
  • -
  • -
    -
    - 2. - at C:\_work\jetbrains\yii2\yii\base\InlineAction.php – - call_user_func_array() - at line - 47 -
    -
    - -
  • -
  • -
    -
    - 3. - at C:\_work\jetbrains\yii2\yii\base\Controller.php – - yii\base\InlineActionrunWithParams() - at line - 117 -
    -
    - -
  • -
  • -
    -
    - 4. - at C:\_work\jetbrains\yii2\yii\web\Application.php – - yii\base\ModulerunAction() - at line - 35 -
    -
    - -
  • -
  • -
    -
    - 5. - at C:\_work\jetbrains\yii2\yii\web\Application.php – - yii\base\ModulerunAction() - at line - 35 -
    -
    - -
  • -
  • -
    -
    - 6. - at C:\_work\jetbrains\yii2\yii\base\Application.php – - yii\web\ApplicationprocessRequest() - at line - 146 -
    -
    - -
  • -
  • -
    -
    - 7. - at C:\_work\jetbrains\yii2\apps\bootstrap\index.php – - yii\base\Applicationrun() - at line - 14 -
    -
    - -
  • -
-
- - -
-
-
-
$_GET = [
-	'show-post' => 100,
-	'refresh-page' => 'yes',
-	'ascending-sort' => 1,
-];
-
-$_POST = [
-	'blog-post-form' => [
-		'title' => 'hello',
-		'author_id' => '12',
-	],
-];
-
-$_SERVER = [
-	'DOCUMENT_ROOT' => '/home/resurtm/work/data',
-	'REMOTE_ADDR' => '::1',
-	'REMOTE_PORT' => '52694',
-	'SERVER_SOFTWARE' => 'PHP 5.4.3 Development Server',
-	'SERVER_PROTOCOL' => 'HTTP/1.1',
-	'SERVER_NAME' => 'localhost',
-	'SERVER_PORT' => '8000',
-	'REQUEST_URI' => '/index.php?post-form[title]=hello&post-form[author_id]=12',
-	'REQUEST_METHOD' => 'GET',
-	'SCRIPT_NAME' => '/index.php',
-	'SCRIPT_FILENAME' => '/home/resurtm/work/data/index.php',
-	'PHP_SELF' => '/index.php',
-	'QUERY_STRING' => 'post-form[title]=hello&post-form[author_id]=12',
-	'HTTP_HOST' => 'localhost:8000',
-	'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0',
-	'HTTP_ACCEPT_LANGUAGE' => 'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3',
-	'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
-	'HTTP_CONNECTION' => 'keep-alive',
-	'REQUEST_TIME_FLOAT' => 1369146454.0856,
-	'REQUEST_TIME' => 1369146454,
-];
-
- - */ ?> - - - - - diff --git a/framework/yii/views/errorHandler/callStackItem.php b/framework/yii/views/errorHandler/callStackItem.php new file mode 100644 index 0000000..e4ac1bf --- /dev/null +++ b/framework/yii/views/errorHandler/callStackItem.php @@ -0,0 +1,34 @@ +context; +?> + +
  • +
    +
    + . + in htmlEncode($file); ?> + at line + +
    +
    +
    +
    + +
    + +
    + '; ?> +
    htmlEncode($lines[$i]); ?>
    +
    +
    +
  • diff --git a/framework/yii/views/errorHandler/main.php b/framework/yii/views/errorHandler/main.php new file mode 100644 index 0000000..4ff8c8d --- /dev/null +++ b/framework/yii/views/errorHandler/main.php @@ -0,0 +1,101 @@ +context; +?> + + + + + + + + <?php echo $c->htmlEncode($e->getName() . ' – ' . get_class($e)); ?> + + <?php echo $c->htmlEncode(get_class($e)); ?> + + + + + + + + + + +
    + Attention +

    + ExceptionaddTypeLinks(get_class($e)); ?> + + – createHttpStatusLink($e->statusCode); ?> + +

    +

    htmlEncode($e->getName()); ?>

    +
    + +
    +
      + renderCallStackItem($e->getFile(), $e->getLine(), 1); ?> + getTrace(), $length = count($trace); $i < $length; ++$i): ?> + renderCallStackItem($trace[$i]['file'], $trace[$i]['line'], $i + 1); ?> + +
    +
    + + +
    +
    +
    +
    $_GET = [
    +	'show-post' => 100,
    +	'refresh-page' => 'yes',
    +	'ascending-sort' => 1,
    +];
    +
    +$_POST = [
    +	'blog-post-form' => [
    +		'title' => 'hello',
    +		'author_id' => '12',
    +	],
    +];
    +
    +$_SERVER = [
    +	'DOCUMENT_ROOT' => '/home/resurtm/work/data',
    +	'REMOTE_ADDR' => '::1',
    +	'REMOTE_PORT' => '52694',
    +	'SERVER_SOFTWARE' => 'PHP 5.4.3 Development Server',
    +	'SERVER_PROTOCOL' => 'HTTP/1.1',
    +	'SERVER_NAME' => 'localhost',
    +	'SERVER_PORT' => '8000',
    +	'REQUEST_URI' => '/index.php?post-form[title]=hello&post-form[author_id]=12',
    +	'REQUEST_METHOD' => 'GET',
    +	'SCRIPT_NAME' => '/index.php',
    +	'SCRIPT_FILENAME' => '/home/resurtm/work/data/index.php',
    +	'PHP_SELF' => '/index.php',
    +	'QUERY_STRING' => 'post-form[title]=hello&post-form[author_id]=12',
    +	'HTTP_HOST' => 'localhost:8000',
    +	'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0',
    +	'HTTP_ACCEPT_LANGUAGE' => 'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3',
    +	'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
    +	'HTTP_CONNECTION' => 'keep-alive',
    +	'REQUEST_TIME_FLOAT' => 1369146454.0856,
    +	'REQUEST_TIME' => 1369146454,
    +];
    +
    + + */ ?> + + + + + From 731cbf8980a339cf75b1dfc8a6658cb832df543c Mon Sep 17 00:00:00 2001 From: resurtm Date: Sat, 25 May 2013 21:40:11 +0600 Subject: [PATCH 05/10] New error page WIP. --- apps/bootstrap/controllers/SiteController.php | 4 +- apps/bootstrap/www/tmp/gears.png | Bin 0 -> 4579 bytes apps/bootstrap/www/tmp/main.css | 15 ++++- apps/bootstrap/www/tmp/main.js | 7 +- framework/yii/base/ErrorHandler.php | 16 ++++- framework/yii/views/errorHandler/callStackItem.php | 2 +- framework/yii/views/errorHandler/main.php | 71 +++++++-------------- 7 files changed, 60 insertions(+), 55 deletions(-) create mode 100644 apps/bootstrap/www/tmp/gears.png diff --git a/apps/bootstrap/controllers/SiteController.php b/apps/bootstrap/controllers/SiteController.php index 4652430..a6731f9 100644 --- a/apps/bootstrap/controllers/SiteController.php +++ b/apps/bootstrap/controllers/SiteController.php @@ -20,8 +20,10 @@ class SiteController extends Controller public function actionIndex() { + $x = null; + $x->y = 100; throw new \yii\base\HttpException(500, 'Test exception'); - $x = 1; +// $x = 1; echo $this->render('index'); } diff --git a/apps/bootstrap/www/tmp/gears.png b/apps/bootstrap/www/tmp/gears.png new file mode 100644 index 0000000000000000000000000000000000000000..7eaa41ce13c91790b33d25e0e3aa51425d2e48e9 GIT binary patch literal 4579 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 zSJPyp+Pa#+~{IXrenderFile($this->mainView, array('e' => $exception), $this); + $request = array(); + if (count($_GET) > 0) { + $request[] = '$_GET = ' . var_export($_GET, true) . ';'; + } + if (count($_POST) > 0) { + $request[] = '$_POST = ' . var_export($_POST, true) . ';'; + } + $request[] = '$_SERVER = ' . var_export($_SERVER, true) . ';'; + $request = implode("\n\n", $request); + echo $view->renderFile($this->mainView, array( + 'e' => $exception, + 'request' => $request, + 'requestLinesCount' => substr_count($request, "\n"), + ), $this); } } } diff --git a/framework/yii/views/errorHandler/callStackItem.php b/framework/yii/views/errorHandler/callStackItem.php index e4ac1bf..b319d16 100644 --- a/framework/yii/views/errorHandler/callStackItem.php +++ b/framework/yii/views/errorHandler/callStackItem.php @@ -1,13 +1,13 @@ context; ?> diff --git a/framework/yii/views/errorHandler/main.php b/framework/yii/views/errorHandler/main.php index 4ff8c8d..0ea82e1 100644 --- a/framework/yii/views/errorHandler/main.php +++ b/framework/yii/views/errorHandler/main.php @@ -2,6 +2,8 @@ /** * @var \yii\base\View $this * @var \Exception $e + * @var string $request + * @var integer $requestLinesCount * @var \yii\base\ErrorHandler $c */ $c = $this->context; @@ -27,14 +29,23 @@ $c = $this->context;
    - Attention -

    - ExceptionaddTypeLinks(get_class($e)); ?> - - – createHttpStatusLink($e->statusCode); ?> - -

    -

    htmlEncode($e->getName()); ?>

    + + Gears +

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

    +

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

    + + Attention +

    + ExceptionaddTypeLinks(get_class($e)); ?> + + – createHttpStatusLink($e->statusCode); ?> + +

    +

    htmlEncode($e->getName()); ?>

    +
    @@ -46,49 +57,11 @@ $c = $this->context;
    - -
    -
    -
    -
    $_GET = [
    -	'show-post' => 100,
    -	'refresh-page' => 'yes',
    -	'ascending-sort' => 1,
    -];
    -
    -$_POST = [
    -	'blog-post-form' => [
    -		'title' => 'hello',
    -		'author_id' => '12',
    -	],
    -];
    -
    -$_SERVER = [
    -	'DOCUMENT_ROOT' => '/home/resurtm/work/data',
    -	'REMOTE_ADDR' => '::1',
    -	'REMOTE_PORT' => '52694',
    -	'SERVER_SOFTWARE' => 'PHP 5.4.3 Development Server',
    -	'SERVER_PROTOCOL' => 'HTTP/1.1',
    -	'SERVER_NAME' => 'localhost',
    -	'SERVER_PORT' => '8000',
    -	'REQUEST_URI' => '/index.php?post-form[title]=hello&post-form[author_id]=12',
    -	'REQUEST_METHOD' => 'GET',
    -	'SCRIPT_NAME' => '/index.php',
    -	'SCRIPT_FILENAME' => '/home/resurtm/work/data/index.php',
    -	'PHP_SELF' => '/index.php',
    -	'QUERY_STRING' => 'post-form[title]=hello&post-form[author_id]=12',
    -	'HTTP_HOST' => 'localhost:8000',
    -	'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0',
    -	'HTTP_ACCEPT_LANGUAGE' => 'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3',
    -	'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
    -	'HTTP_CONNECTION' => 'keep-alive',
    -	'REQUEST_TIME_FLOAT' => 1369146454.0856,
    -	'REQUEST_TIME' => 1369146454,
    -];
    +
    +
    htmlEncode($request); ?>
    -
    - */ ?> +