Skip to content

[#14810] Call model setters during ORM hydration in cloneResultMap()#16906

Merged
niden merged 4 commits intophalcon:5.0.xfrom
niden-code:T14810-model-setters-hydration
Apr 23, 2026
Merged

[#14810] Call model setters during ORM hydration in cloneResultMap()#16906
niden merged 4 commits intophalcon:5.0.xfrom
niden-code:T14810-model-setters-hydration

Conversation

@niden
Copy link
Copy Markdown
Member

@niden niden commented Apr 22, 2026

Hello!

In raising this pull request, I confirm the following:

  • I have read and understood the Contributing Guidelines
  • I have checked that another pull request for this purpose does not exist
  • I wrote some tests for this PR
  • I have updated the relevant CHANGELOG
  • I have created a PR for the documentation about this change

Small description of change:

Root Cause

cloneResultMap() — used internally by findFirst(), find() and all hydration paths — was directly assigning DB values to model properties, bypassing any user-defined setter methods (e.g. setName()). This was inconsistent with assign(), which respects setters.

Fix

Added the same setter-checking logic as assign() to all three property-assignment paths in cloneResultMap(), gated by the existing orm.disable_assign_setters setting (default false, meaning setters are called). Internal Phalcon setters listed in localMethods (e.g. setDirtyState, setSource) are excluded to avoid interference with the ORM's own lifecycle.

Files Changed

  • phalcon/Mvc/Model.zep — setter-calling logic added to cloneResultMap() at all three assignment points
  • tests/support/Models/InvoicesWithSetters.php — new test support model with setters that transform values
  • tests/database/Mvc/Model/CloneResultMapTest.php — new testMvcModelCloneResultMapCallsSetters test (alphabetically ordered)
  • CHANGELOG-5.0.md — added entry for [BUG]: Model setters do not call during hydration #14810

Thanks

@niden niden added bug A bug report status: medium Medium 5.0 The issues we want to solve in the 5.0 release labels Apr 22, 2026
@niden niden self-assigned this Apr 22, 2026
@niden niden requested a review from Jeckerson April 22, 2026 14:55
@niden niden marked this pull request as ready for review April 22, 2026 14:56
@niden niden merged commit 18a6c1e into phalcon:5.0.x Apr 23, 2026
3 checks passed
@niden niden deleted the T14810-model-setters-hydration branch April 23, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants