New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undesired notice in Model.php _prepareUpdateFields for counterCache #3469
Comments
Did you try switching the order?
That would assert that the counterCache key as well as others are properly set up through the constructor - as it is meant to work. If you need to do it manually afterwards, the bindModel() method would be the way to go. |
Sure, let me give a couple things a try. Thanks! |
Both those work. The parent constructors should fire first (in my opinion), but this style works nice too: parent::__construct($id, $table, $ds);
$this->bindModel(array('belongsTo' =>
array('Post' => array(
'className' => 'Post', 'foreignKey' => 'parent_id')
)
)); You can close or add the extra safety check anyway. Either works for me. Thanks! |
Closing as there is an open PR to continue the discussion: #3470 . Thank you for your quick reply. We will look into it. |
Fixes #3469, explicit isset check for counterCache
For some models, I aggregate associations programmatically through constructors and the class hierarchy like this:
This can lead to some noisy notice messages in Model.php:
It can be worked around in the definition by including counterCache and setting false explicitly:
However, the framework could catch this more elegantly with an isset check:
The text was updated successfully, but these errors were encountered: