debug panel : change json_encode/decode to serialise/unserialise to prevent non-UTF characters error

This commit is contained in:
Eugene Kuzminov
2013-10-17 15:24:52 +03:00
parent f716bdd70d
commit b9de474cce
3 changed files with 6 additions and 6 deletions

View File

@@ -49,7 +49,7 @@ class LogTarget extends Target
if (!is_file($indexFile)) {
$manifest = array();
} else {
$manifest = json_decode(file_get_contents($indexFile), true);
$manifest = unserialize(file_get_contents($indexFile));
}
$request = Yii::$app->getRequest();
$manifest[$this->tag] = $summary = array(
@@ -68,8 +68,8 @@ class LogTarget extends Target
$data[$id] = $panel->save();
}
$data['summary'] = $summary;
file_put_contents($dataFile, json_encode($data));
file_put_contents($indexFile, json_encode($manifest));
file_put_contents($dataFile, serialize($data));
file_put_contents($indexFile, serialize($manifest));
}
/**

View File

@@ -76,7 +76,7 @@ class DefaultController extends Controller
if ($this->_manifest === null) {
$indexFile = $this->module->dataPath . '/index.json';
if (is_file($indexFile)) {
$this->_manifest = array_reverse(json_decode(file_get_contents($indexFile), true), true);
$this->_manifest = array_reverse(unserialize(file_get_contents($indexFile)), true);
} else {
$this->_manifest = array();
}
@@ -89,7 +89,7 @@ class DefaultController extends Controller
$manifest = $this->getManifest();
if (isset($manifest[$tag])) {
$dataFile = $this->module->dataPath . "/$tag.json";
$data = json_decode(file_get_contents($dataFile), true);
$data = unserialize(file_get_contents($dataFile));
foreach ($this->module->panels as $id => $panel) {
if (isset($data[$id])) {
$panel->tag = $tag;

View File

@@ -151,7 +151,7 @@ EOD;
}
$rows = array();
foreach ($values as $name => $value) {
$rows[] = '<tr><th style="width: 200px;">' . Html::encode($name) . '</th><td>' . Html::encode(var_export($value, true)) . '</td></tr>';
$rows[] = '<tr><th style="width: 200px;">' . Html::encode($name) . '</th><td>' . htmlspecialchars(var_export($value, true), ENT_QUOTES|ENT_SUBSTITUTE, \Yii::$app->charset, TRUE) . '</td></tr>';
}
$rows = implode("\n", $rows);
return <<<EOD