Skip to content

Commit

Permalink
fix: Undefined array key 2
Browse files Browse the repository at this point in the history
Was seeing the following errors in the log:
  PHP Warning:  Undefined array key 2 in /var/www/html/Domain/ReservationItemView.php on line 490

The issue was caused by `array_splice()`

After using `array_splice` then `$name_parts` is now only a single
element array, as all other elements have been removed and used to
generate `$firstnames`
  • Loading branch information
JohnVillalovos committed May 31, 2024
1 parent a27ce5b commit 103cc3e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Domain/ReservationItemView.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ public function __construct(
# more than just one first and one last name
$lastIndex = count($name_parts) - 1;
$firstnames = implode(' ', array_splice($name_parts, 0, $lastIndex));
$lastnames = $name_parts[$lastIndex];
$lastnames = $name_parts[0];
// could be extended to guess which is a middle name etc.
}
$this->ParticipantIds[] = $id;
Expand Down

0 comments on commit 103cc3e

Please sign in to comment.