Fixes #13501: Fixed yii\rbac\DbManager::getRule() and yii\rbac\DbManager::getRules() to properly handle resource data came from Rule table when using PostgreSQL

This commit is contained in:
Alexander
2017-02-04 17:51:12 +05:00
committed by Alexander Makarov
parent 25b78aa615
commit 97c43c2480
2 changed files with 15 additions and 3 deletions

View File

@ -631,7 +631,15 @@ class DbManager extends BaseManager
->from($this->ruleTable)
->where(['name' => $name])
->one($this->db);
return $row === false ? null : unserialize($row['data']);
if ($row === false) {
return null;
}
$data = $row['data'];
if (is_resource($data)) {
$data = stream_get_contents($data);
}
return unserialize($data);
}
/**
@ -647,7 +655,11 @@ class DbManager extends BaseManager
$rules = [];
foreach ($query->all($this->db) as $row) {
$rules[$row['name']] = unserialize($row['data']);
$data = $row['data'];
if (is_resource($data)) {
$data = stream_get_contents($data);
}
$rules[$row['name']] = unserialize($data);
}
return $rules;