Commit 75ee05b9 by Qiang Xue

more null fixes.

parent 4c2aaee4
......@@ -216,7 +216,7 @@ class DbManager extends Manager
->queryAll();
$children = [];
foreach ($rows as $row) {
if (($data = @unserialize($row['data'])) === false) {
if (!isset($row['data']) || ($data = @unserialize($row['data'])) === false) {
$data = null;
}
$children[$row['name']] = new Item([
......@@ -251,7 +251,7 @@ class DbManager extends Manager
'user_id' => $userId,
'item_name' => $itemName,
'biz_rule' => $bizRule,
'data' => serialize($data),
'data' => $data === null ? null : serialize($data),
])
->execute();
return new Assignment([
......@@ -319,7 +319,7 @@ class DbManager extends Manager
->createCommand($this->db)
->queryOne();
if ($row !== false) {
if (($data = @unserialize($row['data'])) === false) {
if (!isset($row['data']) || ($data = @unserialize($row['data'])) === false) {
$data = null;
}
return new Assignment([
......@@ -349,7 +349,7 @@ class DbManager extends Manager
->queryAll();
$assignments = [];
foreach ($rows as $row) {
if (($data = @unserialize($row['data'])) === false) {
if (!isset($row['data']) || ($data = @unserialize($row['data'])) === false) {
$data = null;
}
$assignments[$row['item_name']] = new Assignment([
......@@ -372,7 +372,7 @@ class DbManager extends Manager
$this->db->createCommand()
->update($this->assignmentTable, [
'biz_rule' => $assignment->bizRule,
'data' => serialize($assignment->data),
'data' => $assignment->data === null ? null : serialize($assignment->data),
], [
'user_id' => $assignment->userId,
'item_name' => $assignment->itemName,
......@@ -411,7 +411,7 @@ class DbManager extends Manager
}
$items = [];
foreach ($command->queryAll() as $row) {
if (($data = @unserialize($row['data'])) === false) {
if (!isset($row['data']) || ($data = @unserialize($row['data'])) === false) {
$data = null;
}
$items[$row['name']] = new Item([
......@@ -537,7 +537,7 @@ class DbManager extends Manager
'type' => $item->type,
'description' => $item->description,
'biz_rule' => $item->bizRule,
'data' => serialize($item->data),
'data' => $item->data === null ? null : serialize($item->data),
], [
'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