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

@ -4,9 +4,9 @@ Yii Framework 2 Change Log
2.0.11.2 under development 2.0.11.2 under development
-------------------------- --------------------------
- Bug #13501: Fixed `yii\rbac\DbManager::getRule()` and `yii\rbac\DbManager::getRules()` to properly handle resource data came from Rule table when using PostgreSQL (StalkAlex)
- Bug #13508: Fixed duplicate attachment of behavior BC break (cebe) - Bug #13508: Fixed duplicate attachment of behavior BC break (cebe)
2.0.11.1 February 02, 2017 2.0.11.1 February 02, 2017
------------------------ ------------------------

View File

@ -631,7 +631,15 @@ class DbManager extends BaseManager
->from($this->ruleTable) ->from($this->ruleTable)
->where(['name' => $name]) ->where(['name' => $name])
->one($this->db); ->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 = []; $rules = [];
foreach ($query->all($this->db) as $row) { 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; return $rules;