Commit 084d3554 by Alexander Makarov

Fixes #5402: Debugger was not loading when there were closures, resources or PDO…

Fixes #5402: Debugger was not loading when there were closures, resources or PDO instances in the logged data
parent 9061874b
......@@ -4,6 +4,7 @@ Yii Framework 2 debug extension Change Log
2.0.1 under development
-----------------------
- Bug #5402: Debugger was not loading when there were closures, resources or PDO instances in the logged data (samdark)
- Enh #5600: Allow configuring debug panels in `yii\debug\Module::panels` as panel class name strings (qiangxue)
......
......@@ -55,13 +55,54 @@ class LogTarget extends Target
$data[$id] = $panel->save();
}
$data['summary'] = $summary;
file_put_contents($dataFile, serialize($data));
file_put_contents($dataFile, serialize($this->replaceUnserializable($data)));
$indexFile = "$path/index.data";
$this->updateIndexFile($indexFile, $summary);
}
/**
* Replacing everything that is not serializable with its text representation
*
* @param mixed $value
* @return mixed
*/
private function replaceUnserializable($value)
{
if (is_scalar($value) || $value === null) {
return $value;
}
if (is_array($value)) {
foreach ($value as &$row) {
$row = $this->replaceUnserializable($row);
}
return $value;
}
if ($value instanceof \Closure) {
return '\Closure';
}
if (is_resource($value)) {
return 'resource';
}
if ($value instanceof \PDO) {
return '\PDO';
}
$properties = (new \ReflectionObject($value))->getProperties();
foreach ($properties as &$property) {
$property->setAccessible(true);
$propertyValue = $property->getValue($value);
$property->setValue($value, $this->replaceUnserializable($propertyValue));
}
return $value;
}
/**
* Updates index file with summary log data
*
* @param string $indexFile path to index file
......
......@@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.1 under development
-----------------------
- Bug #5402: Debugger was not loading when there were closures, resources or PDO instances in the logged data (samdark)
- Bug #5584: `yii\rbac\DbRbacManager` should not delete items when deleting a rule on a database not supporting cascade update (mdmunir)
- Bug #5601: Simple conditions in Query::where() and ActiveQuery::where() did not allow `yii\db\Expression` to be used as the value (cebe, stevekr)
- Bug: Gii console command help information does not contain global options (qiangxue)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment