Skip to content
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

Fixed Model\Manager::getRelations() and getRelationsBetween() #14509

Merged
merged 2 commits into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- Fixed `Phalcon\Mvc\Model` to include correct model instances in messages metadata [#14510](https://github.com/phalcon/cphalcon/pull/14502)
- Fixed `Phalcon\Di\Injectable::__get()` to return shared instance by default [#14491](https://github.com/phalcon/cphalcon/issues/14491)
- Fixed `Phalcon\Mvc\View::loadTemplateEngines()` to not share engine with other views by default [#14491](https://github.com/phalcon/cphalcon/issues/14491)
- Fixed `Phalcon\Mvc\Model\Manager::getRelations()` and `getRelationsBetween()` to return many-to-many relations correctly [#14509](https://github.com/phalcon/cphalcon/pull/14509)

## Removed

Expand Down
9 changes: 8 additions & 1 deletion phalcon/Mvc/Model/Manager.zep
Original file line number Diff line number Diff line change
Expand Up @@ -1860,7 +1860,7 @@ class Manager implements ManagerInterface, InjectionAwareInterface, EventsAwareI
/**
* Get many-to-many relations
*/
if fetch relations, this->hasManyToMany[entityName] {
if fetch relations, this->hasManyToManySingle[entityName] {
for relation in relations {
let allRelations[] = relation;
}
Expand Down Expand Up @@ -1907,6 +1907,13 @@ class Manager implements ManagerInterface, InjectionAwareInterface, EventsAwareI
return relations;
}

/**
* Check whether it's a has-many-to-many relationship
*/
if fetch relations, this->hasManyToMany[keyRelation] {
return relations;
}

return false;
}

Expand Down