Skip to content

Fix AD group import TypeError on PHP 8.1+#46

Open
nicdavidson wants to merge 1 commit into
developfrom
fix/ad-group-import-array-wrap
Open

Fix AD group import TypeError on PHP 8.1+#46
nicdavidson wants to merge 1 commit into
developfrom
fix/ad-group-import-array-wrap

Conversation

@nicdavidson

Copy link
Copy Markdown
Contributor

Summary

  • Wraps the role_adldap_by_role_id relation value in an additional array so BaseModel::setAttribute() iterates an array of records instead of string values
  • Fixes fatal TypeError: Model::__construct(): Argument #1 ($attributes) must be of type array, string given when running php artisan df:ad-group-import on PHP 8.1+
  • Regression from commit ab15144 (2017) that flattened the array; only surfaced now because PHP 8.1+ enforces strict type hints that PHP 7.x treated as soft warnings

Test plan

  • Run php artisan df:ad-group-import <service> against an AD server with groups
  • Verify roles are created with correct role_adldap relation (DN stored)
  • Confirm no TypeError on PHP 8.1/8.2/8.3/8.4

The role_adldap_by_role_id relation value must be an array of arrays
(one record per related model). The flat array caused BaseModel to
iterate string values into Model::__construct(), which fatally fails
under PHP 8.1+ strict typing.

Regression introduced in ab15144 (2017).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant