From 557acce98b12e9c79e8d642fe0f372d326c28808 Mon Sep 17 00:00:00 2001 From: pawelkania Date: Mon, 19 Oct 2020 12:05:34 +0200 Subject: [PATCH] Fix postgres rule unserialization Yii2 migration for Postgres uses bytea for field "data" (see: https://github.com/yiisoft/yii2/commit/23790272dc561aacf2070cbbda396f49e44cbb7d#diff-9dc218c5c0834622090067e24bb745073a454b843a5e150d1498af80ebdd73fa) and bytea is resource in php so unserialize will throw error. This code is taken from Yii2 DbManager: https://github.com/yiisoft/yii2/blob/master/framework/rbac/DbManager.php#L449 --- src/User/resources/views/rule/index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/User/resources/views/rule/index.php b/src/User/resources/views/rule/index.php index 7e5e15d7..b26f0837 100644 --- a/src/User/resources/views/rule/index.php +++ b/src/User/resources/views/rule/index.php @@ -35,9 +35,11 @@ 'attribute' => 'className', 'label' => Yii::t('usuario', 'Class'), 'value' => function ($row) { - $rule = unserialize($row['data']); + if (!isset($row['data']) || ($data = @unserialize(is_resource($row['data']) ? stream_get_contents($row['data']) : $row['data'])) === false) { + $data = null; + } - return get_class($rule); + return get_class($data); }, 'options' => [ 'style' => 'width: 20%'