Commit 75ee05b9 by Qiang Xue

more null fixes.

parent 4c2aaee4
...@@ -216,7 +216,7 @@ class DbManager extends Manager ...@@ -216,7 +216,7 @@ class DbManager extends Manager
->queryAll(); ->queryAll();
$children = []; $children = [];
foreach ($rows as $row) { foreach ($rows as $row) {
if (($data = @unserialize($row['data'])) === false) { if (!isset($row['data']) || ($data = @unserialize($row['data'])) === false) {
$data = null; $data = null;
} }
$children[$row['name']] = new Item([ $children[$row['name']] = new Item([
...@@ -251,7 +251,7 @@ class DbManager extends Manager ...@@ -251,7 +251,7 @@ class DbManager extends Manager
'user_id' => $userId, 'user_id' => $userId,
'item_name' => $itemName, 'item_name' => $itemName,
'biz_rule' => $bizRule, 'biz_rule' => $bizRule,
'data' => serialize($data), 'data' => $data === null ? null : serialize($data),
]) ])
->execute(); ->execute();
return new Assignment([ return new Assignment([
...@@ -319,7 +319,7 @@ class DbManager extends Manager ...@@ -319,7 +319,7 @@ class DbManager extends Manager
->createCommand($this->db) ->createCommand($this->db)
->queryOne(); ->queryOne();
if ($row !== false) { if ($row !== false) {
if (($data = @unserialize($row['data'])) === false) { if (!isset($row['data']) || ($data = @unserialize($row['data'])) === false) {
$data = null; $data = null;
} }
return new Assignment([ return new Assignment([
...@@ -349,7 +349,7 @@ class DbManager extends Manager ...@@ -349,7 +349,7 @@ class DbManager extends Manager
->queryAll(); ->queryAll();
$assignments = []; $assignments = [];
foreach ($rows as $row) { foreach ($rows as $row) {
if (($data = @unserialize($row['data'])) === false) { if (!isset($row['data']) || ($data = @unserialize($row['data'])) === false) {
$data = null; $data = null;
} }
$assignments[$row['item_name']] = new Assignment([ $assignments[$row['item_name']] = new Assignment([
...@@ -372,7 +372,7 @@ class DbManager extends Manager ...@@ -372,7 +372,7 @@ class DbManager extends Manager
$this->db->createCommand() $this->db->createCommand()
->update($this->assignmentTable, [ ->update($this->assignmentTable, [
'biz_rule' => $assignment->bizRule, 'biz_rule' => $assignment->bizRule,
'data' => serialize($assignment->data), 'data' => $assignment->data === null ? null : serialize($assignment->data),
], [ ], [
'user_id' => $assignment->userId, 'user_id' => $assignment->userId,
'item_name' => $assignment->itemName, 'item_name' => $assignment->itemName,
...@@ -411,7 +411,7 @@ class DbManager extends Manager ...@@ -411,7 +411,7 @@ class DbManager extends Manager
} }
$items = []; $items = [];
foreach ($command->queryAll() as $row) { foreach ($command->queryAll() as $row) {
if (($data = @unserialize($row['data'])) === false) { if (!isset($row['data']) || ($data = @unserialize($row['data'])) === false) {
$data = null; $data = null;
} }
$items[$row['name']] = new Item([ $items[$row['name']] = new Item([
...@@ -537,7 +537,7 @@ class DbManager extends Manager ...@@ -537,7 +537,7 @@ class DbManager extends Manager
'type' => $item->type, 'type' => $item->type,
'description' => $item->description, 'description' => $item->description,
'biz_rule' => $item->bizRule, 'biz_rule' => $item->bizRule,
'data' => serialize($item->data), 'data' => $item->data === null ? null : serialize($item->data),
], [ ], [
'name' => $oldName === null ? $item->getName() : $oldName, 'name' => $oldName === null ? $item->getName() : $oldName,
]) ])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment