Skip to content

Commit b5b6ddf

Browse files
author
Alex Schmitz
committed
Add additional empty checks after field protection.
1 parent 3685755 commit b5b6ddf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

system/BaseModel.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,13 @@ public function insert($data = null, bool $returnID = true)
728728
// strip out created_at values.
729729
$data = $this->doProtectFields($data);
730730

731+
// doProtectFields() can further remove elements from
732+
// $data so we need to check for empty dataset again
733+
if (empty($data))
734+
{
735+
throw DataException::forEmptyDataset('insert');
736+
}
737+
731738
// Set created_at and updated_at with same time
732739
$date = $this->setDate();
733740

@@ -866,6 +873,13 @@ public function update($id = null, $data = null): bool
866873
// strip out updated_at values.
867874
$data = $this->doProtectFields($data);
868875

876+
// doProtectFields() can further remove elements from
877+
// $data so we need to check for empty dataset again
878+
if (empty($data))
879+
{
880+
throw DataException::forEmptyDataset('update');
881+
}
882+
869883
if ($this->useTimestamps && $this->updatedField && ! array_key_exists($this->updatedField, $data))
870884
{
871885
$data[$this->updatedField] = $this->setDate();

0 commit comments

Comments
 (0)