Browse Source

use json format.

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
abb349361b
  1. 6
      extensions/gii/Generator.php
  2. 6
      framework/yii/helpers/BaseSecurity.php

6
extensions/gii/Generator.php

@ -193,7 +193,7 @@ abstract class Generator extends Model
$attributes[] = 'template'; $attributes[] = 'template';
$path = $this->getStickyDataFile(); $path = $this->getStickyDataFile();
if (is_file($path)) { if (is_file($path)) {
$result = unserialize(file_get_contents($path)); $result = json_decode(file_get_contents($path), true);
if (is_array($result)) { if (is_array($result)) {
foreach ($stickyAttributes as $name) { foreach ($stickyAttributes as $name) {
if (isset($result[$name])) { if (isset($result[$name])) {
@ -218,7 +218,7 @@ abstract class Generator extends Model
} }
$path = $this->getStickyDataFile(); $path = $this->getStickyDataFile();
@mkdir(dirname($path), 0755, true); @mkdir(dirname($path), 0755, true);
file_put_contents($path, serialize($values)); file_put_contents($path, json_encode($values));
} }
/** /**
@ -227,7 +227,7 @@ abstract class Generator extends Model
*/ */
public function getStickyDataFile() public function getStickyDataFile()
{ {
return Yii::$app->getRuntimePath() . '/gii-' . Yii::getVersion() . '/' . str_replace('\\', '-', get_class($this)) . '.data'; return Yii::$app->getRuntimePath() . '/gii-' . Yii::getVersion() . '/' . str_replace('\\', '-', get_class($this)) . '.json';
} }
/** /**

6
framework/yii/helpers/BaseSecurity.php

@ -184,16 +184,16 @@ class BaseSecurity
public static function getSecretKey($name, $length = 32) public static function getSecretKey($name, $length = 32)
{ {
static $keys; static $keys;
$keyFile = Yii::$app->getRuntimePath() . '/keys.data'; $keyFile = Yii::$app->getRuntimePath() . '/keys.json';
if ($keys === null) { if ($keys === null) {
$keys = []; $keys = [];
if (is_file($keyFile)) { if (is_file($keyFile)) {
$keys = unserialize(file_get_contents($keyFile)); $keys = json_decode(file_get_contents($keyFile), true);
} }
} }
if (!isset($keys[$name])) { if (!isset($keys[$name])) {
$keys[$name] = static::generateRandomKey($length); $keys[$name] = static::generateRandomKey($length);
file_put_contents($keyFile, serialize($keys)); file_put_contents($keyFile, json_encode($keys));
} }
return $keys[$name]; return $keys[$name];
} }

Loading…
Cancel
Save