Skip to content

Fix redundant instantiations and uncached reflection in model internals#246

Merged
techmahedy merged 1 commit intodoppar:3.xfrom
techmahedy:techmahedy-3.x
Apr 16, 2026
Merged

Fix redundant instantiations and uncached reflection in model internals#246
techmahedy merged 1 commit intodoppar:3.xfrom
techmahedy:techmahedy-3.x

Conversation

@techmahedy
Copy link
Copy Markdown
Member

Three performance issues found and fixed in InteractsWithModelQueryProcessing:

  1. update() — reflection ran on every callpropertyHasAttribute() creates a ReflectionClass internally. It was called on every update() with no caching, so a model that is updated 100 times in a request paid the reflection cost 100 times.

  2. saveMany() — 3 model instances created, only 1 needed(new static())->propertyHasAttribute(new static(), ...) allocated two extra model instances when the already-created $model variable was sitting right there.

  3. getClassProperty() — called deprecated setAccessible()ReflectionProperty::setAccessible() has been a no-op since PHP 8.1 and triggers a deprecation notice in PHP 8.3. The call was removed.

@techmahedy techmahedy merged commit 2f5de6e into doppar:3.x Apr 16, 2026
27 checks passed
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