Skip to content

Commit

Permalink
fix incorrect decimal sql warning on new ticket form
Browse files Browse the repository at this point in the history
  • Loading branch information
cconard96 committed Nov 1, 2023
1 parent e0bf6d4 commit d143798
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ The present file will list all changes made to the project; according to the
- `showSystemInformations` method for `$CFG_GLPI['systeminformations_types']` types renamed to `getSystemInformation` and should return an array with a label and content.
- `DisplayPreference` config form POST handling moved to `ajax/displaypreference.php` script. The front file is for displaying the tabs only.
- `Document::send()` signature changed. The `$context` parameter has been removed.
- `CommonITILActor::getActors()` signature changed. The `$items_id` parameter must strictly be an integer.

#### Deprecated
- Usage of `GLPI_USE_CSRF_CHECK` constant.
Expand Down
14 changes: 10 additions & 4 deletions src/CommonITILActor.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,18 @@ public function isAttach2Valid(array &$input)


/**
* @param $items_id
* @param int $items_id
* @phpstan-param positive-int $items_id
* @return array Array of actors
**/
public function getActors($items_id)
public function getActors(int $items_id): array
{
/** @var \DBmysql $DB */
global $DB;

$users = [];
$iterator = $DB->request([
'FROM' => $this->getTable(),
'FROM' => static::getTable(),
'WHERE' => [static::getItilObjectForeignKey() => $items_id],
'ORDER' => 'id ASC'
]);
Expand Down Expand Up @@ -363,7 +365,11 @@ public function prepareInputForAdd($input)
return false;
}

$existing_actors = $this->getActors($input[static::getItilObjectForeignKey()] ?? 0);
$itil_items_id = $input[static::getItilObjectForeignKey()];
$existing_actors = [];
if (is_numeric($itil_items_id) && $itil_items_id > 0) {
$existing_actors = $this->getActors((int) $itil_items_id);
}
$existing_ids = array_column($existing_actors[$current_type] ?? [], $fk_field);

// actor already exists
Expand Down

0 comments on commit d143798

Please sign in to comment.