Skip to content

Commit

Permalink
fix: prevent exception in setFieldData when value 0/empty
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Jun 2, 2023
1 parent 20f44e4 commit 9093b20
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions RockMigrations.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -3191,7 +3191,7 @@ public function setFieldData($field, $data, $template = null)
foreach ($data as $key => $val) {

// this makes it possible to set the template via name
if ($key === "template_id") {
if ($key === "template_id" and is_string($val) and $val !== '') {
$tpl = $this->getTemplate($val);
if (!$tpl) throw new WireException("Invalid template_id");
$data[$key] = $tpl->id;
Expand All @@ -3200,7 +3200,7 @@ public function setFieldData($field, $data, $template = null)

// support defining parent_id as page path
// eg 'parent_id' => '/comments'
if ($key === "parent_id") {
if ($key === "parent_id" and is_string($val) and $val !== '') {
$parent = $this->getPage($val);
if (!$parent) throw new WireException("Invalid parent_id");
$data[$key] = $parent->id;
Expand Down

0 comments on commit 9093b20

Please sign in to comment.