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

Incorrect xPDOObjects::_getRelatedObjectsByFK() (getMany()) #9768

Closed
Fi1osof opened this Issue Apr 3, 2013 · 0 comments

Comments

Projects
None yet
1 participant
@Fi1osof
Contributor

Fi1osof commented Apr 3, 2013

fi1osof created Redmine issue ID 9768

@

getObject('modResource', 107)){return '';} // get all related objects $vars = $room->getMany('Variables'); print count($room->_relatedObjects['Variables']); // 2 objects // get one related object $var = current($room->_relatedObjects['Variables']); // add to object $room->addMany($var); print count($room->_relatedObjects['Variables']); // !!! 3 objects @ Reason: array_merge not save IDs, but create numbered array. To understand it we can try this: @ 'object' ); $b = array_merge($a, array( 5=>'object', 7 => 'object', )); print_r($b); @ We got this: Array ( [0] => object [1] => object [2] => object ) To fix this we must in xPDOObjects::_getRelatedObjectsByFK() do foreach(){} Error line: $this->_relatedObjects[$alias]= array_merge($this->_relatedObjects[$alias], $collection); https://github.com/modxcms/revolution/blob/develop/core/xpdo/om/xpdoobject.class.php#L2197

enigmatic-user pushed a commit to enigmatic-user/revolution that referenced this issue Feb 13, 2014

[modxcms#9768] Fix array merge in xPDOObject::getMany()
Updates xPDO Core to 2.2.7-pl

Merge remote-tracking branch 'xpdo/master' into xpdo-227

* xpdo/master:
  Bump version for 2.2.7-pl release
  [#6271] Limit reserved class_key column to inherit="single"
  [#9793] Preserve keys in xPDOObject::getMany()
  Bump version for 2.2.7-dev
  Update copyright dates

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment