Skip to content

Commit

Permalink
Merge branch 'master' of github.com:yiisoft/yii into 873-stat-relatio…
Browse files Browse the repository at this point in the history
…n-scopes
  • Loading branch information
klimov-paul committed Oct 4, 2013
2 parents aba776e + 4873682 commit 2618b5c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Version 1.1.15 under development
- Enh #106: Added getters to CGridColumn to allow getting cell contents for extended use cases of CGridView (cebe)
- Enh #182: CSort: allow arrays in asc/desc keys of virtual attributes (nineinchnick)
- Enh #640: Introduce bigpk and bigint column types in each class extending CDbSchema (nineinchnick)
- Enh #1593: Allow access to exception currently processed by CErrorHandler (klimov-paul)
- Enh #873: CStatRelation (CActiveRecord::STAT) now supports scopes (resurtm, klimov-paul)
- Enh #2540: Enable CJSON to use JsonSerializable interface when serializing objects (sammousa)
- Enh #2737: CFileCache: added cachePathMode and cacheFileMode options to set modes used by chmod() for cache directory and files (ujovlado)
Expand Down
19 changes: 16 additions & 3 deletions framework/base/CErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* {@link CApplication::getErrorHandler()}.
*
* @property array $error The error details. Null if there is no error.
* @property Exception|null $exception exception instance. Null if there is no exception.
*
* @author Qiang Xue <[email protected]>
* @package system.base
Expand Down Expand Up @@ -82,6 +83,7 @@ class CErrorHandler extends CApplicationComponent
public $errorAction;

private $_error;
private $_exception;

/**
* Handles the exception/error event.
Expand Down Expand Up @@ -150,6 +152,15 @@ public function getError()
return $this->_error;
}

/**
* Returns the instance of the exception that is currently being handled.
* @return Exception|null exception instance. Null if there is no exception.
*/
public function getException()
{
return $this->_exception;
}

/**
* Handles the exception.
* @param Exception $exception the exception captured
Expand Down Expand Up @@ -186,6 +197,7 @@ protected function handleException($exception)
unset($trace[$i]['object']);
}

$this->_exception=$exception;
$this->_error=$data=array(
'code'=>($exception instanceof CHttpException)?$exception->statusCode:500,
'type'=>get_class($exception),
Expand All @@ -200,7 +212,7 @@ protected function handleException($exception)
if(!headers_sent())
header("HTTP/1.0 {$data['code']} ".$this->getHttpHeader($data['code'], get_class($exception)));

$this->renderException($exception);
$this->renderException();
}
else
$app->displayException($exception);
Expand Down Expand Up @@ -262,6 +274,7 @@ protected function handleError($event)
default:
$type = 'PHP error';
}
$this->_exception=null;
$this->_error=array(
'code'=>500,
'type'=>$type,
Expand Down Expand Up @@ -323,10 +336,10 @@ protected function render($view,$data)
/**
* Renders the exception information.
* This method will display information from current {@link error} value.
* @param Exception $exception exception object.
*/
protected function renderException(Exception $exception)
protected function renderException()
{
$exception=$this->getException();
if($exception instanceof CHttpException || !YII_DEBUG)
$this->renderError();
else
Expand Down
4 changes: 2 additions & 2 deletions framework/web/widgets/captcha/CCaptchaAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ protected function renderImageGD($code)
$this->foreColor % 0x100);

if($this->fontFile === null)
$this->fontFile = dirname(__FILE__) . '/SpicyRice.ttf';
$this->fontFile = dirname(__FILE__).DIRECTORY_SEPARATOR.'SpicyRice.ttf';

$length = strlen($code);
$box = imagettfbbox(30,0,$this->fontFile,$code);
Expand Down Expand Up @@ -301,7 +301,7 @@ protected function renderImageImagick($code)
$image->newImage($this->width,$this->height,$backColor);

if($this->fontFile===null)
$this->fontFile=dirname(__FILE__).'/SpicyRice.ttf';
$this->fontFile=dirname(__FILE__).DIRECTORY_SEPARATOR.'SpicyRice.ttf';

$draw=new ImagickDraw();
$draw->setFont($this->fontFile);
Expand Down

0 comments on commit 2618b5c

Please sign in to comment.