Skip to content

Commit

Permalink
Improved handling of serialized falsy values (like empty arrays)
Browse files Browse the repository at this point in the history
  • Loading branch information
biohzrdmx committed May 23, 2024
1 parent 1263107 commit d66f11e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vecode/caldera-orm",
"description": "Query builder and ORM layer, part of Vecode Caldera",
"version": "1.1.1",
"version": "1.1.2",
"type": "library",
"license": "MIT",
"authors": [
Expand Down
8 changes: 5 additions & 3 deletions src/Database/Model/AbstractMetaModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ function getMetadata(string $name = '', $default = '') {
->where('name', $name)
->first();
if ($row) {
$ret = @unserialize($row->value) ?: $row->value;
$unserialized = @unserialize($row->value);
$ret = $unserialized !== false ? $unserialized : $row->value;
}
} else {
$rows = QueryFactory::build(static::$meta_table)
Expand All @@ -64,7 +65,8 @@ function getMetadata(string $name = '', $default = '') {
if ($rows) {
$this->metadata = [];
foreach ($rows as $row) {
$this->metadata[$row->name] = @unserialize($row->value) ?: $row->value;
$unserialized = @unserialize($row->value);
$this->metadata[$row->name] = $unserialized !== false ? $unserialized : $row->value;
}
}
}
Expand Down Expand Up @@ -100,4 +102,4 @@ function setMetadata($name = null, $value = ''): void {
}
}
}
}
}

0 comments on commit d66f11e

Please sign in to comment.