Clarify cache behavior affecting entity Mutators and Accessors

When I add or modify mutator methods (e.g., _setX) in an Entity class, these changes may not be recognized immediately due to cached model metadata stored in tmp/cache/models/. This can lead to confusion and wasted development time, especially when debugging why a new mutator isn’t being triggered.

This behavior is not clearly documented, and developers may spend significant time debugging issues that are simply due to stale cache.

Now I know this issue and I always delete files in tmp/cache/models/ to solve this issue.

Making this explicit in the documentation would improve developer experience and reduce frustration. I suggest to add a note to the Entities documentation page.

Thank you.

You are confusing a few things here. The cache you are mentioning is about the structure of the tables (DB table column schema), not the content.
So when you modify via mutator, it modifies actually neither the structure, nor the DB table row (data).

It only modifies an entity and its content.
Unless you save it afterwards, then it saves that to the DB.

But that still has nothing to do with the schema and cache. It works independently from that.

But here is my experience : in my “EntityData” entity class, I added a new setter :

    protected function _setValue($value) {
        $this->value_fr = trim(strip_tags($value));
        $this->value_nl = trim(strip_tags($value));
        $this->value_en = trim(strip_tags($value));
    }

This setter works fine in my development environment.
But once deployed in acceptance or production, this setter is ignored until I delete this file :

\tmp\cache\models\myapp_cake_model_default_entity_data

Having a setter is irrelevant here. The value (and/or the value_xx) fields would be ignored when saving the data if they are not present in the cached table schema.

Regenerating schema cache when deploying is deployment 101.