You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Last find() tries to run but it can't because it doesn't know that is needs to make an join, because the fields are empty so no join and there is the error.
What you expected to happen
I would expect that $reset = true to bindTranslation() will just reset the fields to original after it run not to empty.
As a side note the doc is wrong https://api.cakephp.org/2.10/source-class-TranslateBehavior.html#643
According to the doc the second find() should fail but it was the third that failed.
Could you send a pull request with the change that would solve the issue you're having? If the current tests pass what you're expecting sounds reasonable to me.
This is a (multiple allowed):
bug
enhancement
feature-discussion (RFC)
CakePHP Version: 2.10.10
Platform and Target: Apache 2.4.23, PHP 7.1.14, MySQL 5.7.14, Windows 10 x64
What you did
I used Translate behavior to an model like so
And everything works as expected.
But given the use case:
What happened
The last call to find() will fail with:
So why does this happen?
https://api.cakephp.org/2.10/source-class-TranslateBehavior.html#349
$this->runtime[$Model->alias]['fields']
is set to empty.What you expected to happen
I would expect that $reset = true to bindTranslation() will just reset the fields to original after it run not to empty.
As a side note the doc is wrong https://api.cakephp.org/2.10/source-class-TranslateBehavior.html#643
According to the doc the second find() should fail but it was the third that failed.
As a fix we could replace this line https://github.com/cakephp/cakephp/blob/2.x/lib/Cake/Model/Behavior/TranslateBehavior.php#L347
with
$this->runtime[$Model->alias]['virtualFields'] = array();
So that if we use bindTranslation() the old fields will be used not empty. (not 100% about this fix, clearly there are multiple ways to fix this)
Or all of this could be intended and I just lost 1 day for nothing 😢
The text was updated successfully, but these errors were encountered: