#12687 Initialize result

This commit is contained in:
Daniel Maya 2024-02-12 15:27:56 +01:00
parent 15382049b8
commit a43b2b1c59
1 changed files with 38 additions and 32 deletions

View File

@ -1633,13 +1633,6 @@ class Prd
'tservice_element' => ['rules'], 'tservice_element' => ['rules'],
]; ];
$this->result = [
'status' => true,
'items' => [],
'errors' => [],
'info' => []
];
$this->currentItem = [ $this->currentItem = [
'table' => '', 'table' => '',
'value' => '', 'value' => '',
@ -1652,6 +1645,22 @@ class Prd
} }
/**
* Initialize result
*
* @return void
*/
private function initializeResult()
{
$this->result = [
'status' => true,
'items' => [],
'errors' => [],
'info' => [],
];
}
/** /**
* Fills result with status. * Fills result with status.
* *
@ -1681,6 +1690,7 @@ class Prd
]; ];
} }
/** /**
* Fills result with info message. * Fills result with info message.
* *
@ -1693,6 +1703,7 @@ class Prd
$this->result['info'][] = $msg; $this->result['info'][] = $msg;
} }
/** /**
* Fills result with error message. * Fills result with error message.
* *
@ -1955,12 +1966,13 @@ class Prd
} }
} }
$lastIndex = count($keys) - 1; $lastIndex = (count($keys) - 1);
$updated_data = &$data; $updated_data = &$data;
for ($i = 0; $i < $lastIndex; $i++) { for ($i = 0; $i < $lastIndex; $i++) {
$updated_data = &$updated_data[$keys[$i]]; $updated_data = &$updated_data[$keys[$i]];
} }
$updated_data[$keys[$lastIndex]] = $newValue; $updated_data[$keys[$lastIndex]] = $newValue;
} }
@ -2083,7 +2095,6 @@ class Prd
if ($this->evalConditionalRef($compare_value, $condition['when']) === true if ($this->evalConditionalRef($compare_value, $condition['when']) === true
&& empty($value) === false && empty($value) === false
) { ) {
$ref = $condition['ref']; $ref = $condition['ref'];
if (isset($ref['join']) === true) { if (isset($ref['join']) === true) {
$join_array = $this->recursiveJoin( $join_array = $this->recursiveJoin(
@ -2146,8 +2157,8 @@ class Prd
$value $value
); );
} }
} }
return; return;
} }
} }
@ -2656,6 +2667,8 @@ class Prd
{ {
global $config; global $config;
$this->initializeResult();
if (empty($data_file['prd_data']) === false) { if (empty($data_file['prd_data']) === false) {
$type = $data_file['prd_data']['type']; $type = $data_file['prd_data']['type'];
$name = io_safe_input($data_file['prd_data']['name']); $name = io_safe_input($data_file['prd_data']['name']);
@ -2902,6 +2915,7 @@ class Prd
return $result; return $result;
} }
/** /**
* Eval autocreate Item. * Eval autocreate Item.
* *
@ -2911,7 +2925,8 @@ class Prd
* *
* @return boolean * @return boolean
*/ */
private function evalAutocreateItem(array $ref, string $value='', string $column='') { private function evalAutocreateItem(array $ref, string $value='', string $column='')
{
if (isset($ref['autocreate_item']) === true) { if (isset($ref['autocreate_item']) === true) {
$this->autocreateItem( $this->autocreateItem(
$ref, $ref,
@ -2926,6 +2941,7 @@ class Prd
return true; return true;
} }
/** /**
* Autocreate Item. * Autocreate Item.
* *
@ -3157,9 +3173,7 @@ class Prd
[ [
'table' => 'tgrupo', 'table' => 'tgrupo',
'id' => ['id_grupo'], 'id' => ['id_grupo'],
'fields' => [ 'fields' => ['nombre' => $found_value],
'nombre' => $found_value,
],
], ],
], ],
]; ];
@ -3171,9 +3185,7 @@ class Prd
[ [
'table' => 'tmodule_group', 'table' => 'tmodule_group',
'id' => ['id_mg'], 'id' => ['id_mg'],
'fields' => [ 'fields' => ['name' => $found_value],
'name' => $found_value,
],
], ],
], ],
]; ];
@ -3185,9 +3197,7 @@ class Prd
[ [
'table' => 'tconfig_os', 'table' => 'tconfig_os',
'id' => ['id_os'], 'id' => ['id_os'],
'fields' => [ 'fields' => ['name' => $found_value],
'name' => $found_value,
],
], ],
], ],
]; ];
@ -3199,9 +3209,7 @@ class Prd
[ [
'table' => 'tcategory', 'table' => 'tcategory',
'id' => ['id'], 'id' => ['id'],
'fields' => [ 'fields' => ['name' => $found_value],
'name' => $found_value,
],
], ],
], ],
]; ];
@ -3213,9 +3221,7 @@ class Prd
[ [
'table' => 'ttag', 'table' => 'ttag',
'id' => ['id_tag'], 'id' => ['id_tag'],
'fields' => [ 'fields' => ['name' => $found_value],
'name' => $found_value,
],
], ],
], ],
]; ];