Skip to content

Commit 9b311e3

Browse files
authored
Merge pull request scoumbourdis#453 from scoumbourdis/bugfix/replace_isset_with_array_key_exists
Bugfix/replace isset with array key exists
2 parents b1b7cf4 + bc78485 commit 9b311e3

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

application/libraries/Grocery_CRUD.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ protected function db_update_validation()
853853
$this->basic_model->where($primary_key,$state_info->primary_key);
854854
$row = $this->basic_model->get_row();
855855

856-
if(!isset($row->$field_name)) {
856+
if(!property_exists($row, $field_name)) {
857857
throw new Exception("The field name doesn't exist in the database. ".
858858
"Please use the unique fields only for fields ".
859859
"that exist in the database");
@@ -950,7 +950,7 @@ protected function db_insert($state_info)
950950
$post_data[$field->field_name] = array();
951951
}
952952

953-
if(isset($post_data[$field->field_name]) && !isset($this->relation_n_n[$field->field_name]))
953+
if(array_key_exists($field->field_name, $post_data) && !isset($this->relation_n_n[$field->field_name]))
954954
{
955955
if(isset($types[$field->field_name]->db_null) && $types[$field->field_name]->db_null && is_array($post_data[$field->field_name]) && empty($post_data[$field->field_name]))
956956
{
@@ -1075,7 +1075,7 @@ protected function db_update($state_info)
10751075
$post_data[$field->field_name] = array();
10761076
}
10771077

1078-
if(isset($post_data[$field->field_name]) && !isset($this->relation_n_n[$field->field_name]))
1078+
if(array_key_exists($field->field_name, $post_data) && !isset($this->relation_n_n[$field->field_name]))
10791079
{
10801080
if(isset($types[$field->field_name]->db_null) && $types[$field->field_name]->db_null && is_array($post_data[$field->field_name]) && empty($post_data[$field->field_name]))
10811081
{

0 commit comments

Comments
 (0)