Commit 6a794f6b by Alexander Makarov

Simpler fix for #5402

parent 084d3554
...@@ -4,7 +4,7 @@ Yii Framework 2 debug extension Change Log ...@@ -4,7 +4,7 @@ Yii Framework 2 debug extension Change Log
2.0.1 under development 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 #5402: Debugger was not loading when there were closures in asset classes (samdark)
- Enh #5600: Allow configuring debug panels in `yii\debug\Module::panels` as panel class name strings (qiangxue) - Enh #5600: Allow configuring debug panels in `yii\debug\Module::panels` as panel class name strings (qiangxue)
......
...@@ -55,54 +55,13 @@ class LogTarget extends Target ...@@ -55,54 +55,13 @@ class LogTarget extends Target
$data[$id] = $panel->save(); $data[$id] = $panel->save();
} }
$data['summary'] = $summary; $data['summary'] = $summary;
file_put_contents($dataFile, serialize($this->replaceUnserializable($data))); file_put_contents($dataFile, serialize($data));
$indexFile = "$path/index.data"; $indexFile = "$path/index.data";
$this->updateIndexFile($indexFile, $summary); $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 * Updates index file with summary log data
* *
* @param string $indexFile path to index file * @param string $indexFile path to index file
......
...@@ -57,7 +57,14 @@ class AssetPanel extends Panel ...@@ -57,7 +57,14 @@ class AssetPanel extends Panel
$data = []; $data = [];
foreach ($bundles as $name => $bundle) { foreach ($bundles as $name => $bundle) {
if ($bundle instanceof AssetBundle) { if ($bundle instanceof AssetBundle) {
$data[$name] = (array) $bundle; $bundleData = (array) $bundle;
if (isset($bundleData['publishOptions']['beforeCopy']) && $bundleData['publishOptions']['beforeCopy'] instanceof \Closure) {
$bundleData['publishOptions']['beforeCopy'] = '\Closure';
}
if (isset($bundleData['publishOptions']['afterCopy']) && $bundleData['publishOptions']['afterCopy'] instanceof \Closure) {
$bundleData['publishOptions']['afterCopy'] = '\Closure';
}
$data[$name] = $bundleData;
} }
} }
return $data; return $data;
......
...@@ -4,7 +4,7 @@ Yii Framework 2 Change Log ...@@ -4,7 +4,7 @@ Yii Framework 2 Change Log
2.0.1 under development 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 #5402: Debugger was not loading when there were closures in asset classes (samdark)
- Bug #5584: `yii\rbac\DbRbacManager` should not delete items when deleting a rule on a database not supporting cascade update (mdmunir) - 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 #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) - 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