Permalink
Browse files

Fixes #1924: CLogFilter::$dumper added.

  • Loading branch information...
1 parent b9df23c commit 975a368429ba2482ea0628ebe00588b9b7e1e9c3 @resurtm resurtm committed May 29, 2013
Showing with 20 additions and 4 deletions.
  1. +1 −0 CHANGELOG
  2. +19 −4 framework/logging/CLogFilter.php
View
@@ -20,6 +20,7 @@ Version 1.1.14 work in progress
- Bug #1911: MigrateCommand does not rely on cached value about migration table existance anymore as this info could be outdated in testing enviroment (cebe)
- Bug #1915: CDataProviderIterator: fixed init in case of disabled pagination (antoncpu)
- Bug #1916: CMssqlSchema::findColumns() issues an "invalid object name" error (resurtm)
+- Bug #1924: CLogFilter::$dumper added: this property can be used to get around circular reference issue when using standard `var_export` dumper by changing it to `print_r` (resurtm)
- Bug #1933: fixed using "multiple" parameter with a value of false in CHtml::activeDropDownList, CHtml::ListBox and CHtml::DropDownList (adminnu)
- Bug #1941: yiiactiveform.js form reset now uses CHtml::errorCss instead of a hardcoded value (mdomba)
- Bug #1942: CActiveForm client/ajax validation will now remove error class from server side validation (mdomba)
@@ -42,6 +42,14 @@ class CLogFilter extends CComponent implements ILogFilter
* Note that a variable must be accessible via $GLOBALS. Otherwise it won't be logged.
*/
public $logVars=array('_GET','_POST','_FILES','_COOKIE','_SESSION','_SERVER');
+ /**
+ * @var callable or function which will be used to dump context information.
+ * Defaults to `var_export`. If you're having problems with circular references
+ * problem change it to `print_r`. Any kind of callable (static methods, user defined
+ * functions, lambdas, etc.) could also be used.
+ * @since 1.1.14
+ */
+ public $dumper='var_export';
/**
@@ -94,12 +102,19 @@ protected function getContext()
if($this->logUser && ($user=Yii::app()->getComponent('user',false))!==null)
$context[]='User: '.$user->getName().' (ID: '.$user->getId().')';
- foreach($this->logVars as $name)
+ if($this->dumper==='var_export' || $this->dumper==='print_r')
+ {
+ foreach($this->logVars as $name)
+ if(!empty($GLOBALS[$name]))
+ $context[]="\${$name}=".call_user_func($this->dumper,$GLOBALS[$name],true);
+ }
+ else
{
- if(!empty($GLOBALS[$name]))
- $context[]="\${$name}=".var_export($GLOBALS[$name],true);
+ foreach($this->logVars as $name)
+ if(!empty($GLOBALS[$name]))
+ $context[]="\${$name}=".call_user_func($this->dumper,$GLOBALS[$name]);
}
return implode("\n\n",$context);
}
-}
+}

0 comments on commit 975a368

Please sign in to comment.