Versionable behaviour mishandles 1:1 relationships. #451

Fartlek opened this Issue Aug 17, 2012 · 3 comments

4 participants


When creating a 1:1 relationship using the guide at and if both tables are versionable, then the addVersion function in BookstoreEmployee will get the condition

if ($relateds = $this->getBookstoreEmployeeAccounts()->toKeyValue('EmployeeId', 'Version')) {

BookstoreEmployee has no such method getBookstoreEmployeeAccounts(), so calling save() on a BookstoreEmployee will throw a Call to undefined method: getBookstoreEmployeeAccounts error.

The problem stems from VersionableBehaviorObjectBuilderModifier.php's addAddVersion method where

foreach ($this->behavior->getVersionableReferrers() as $fk) {
    $fkGetter = $this->builder->getRefFKPhpNameAffix($fk, $plural = true);
    $idsColumn = $this->behavior->getReferrerIdsColumn($fk);
    $versionsColumn = $this->behavior->getReferrerVersionsColumn($fk);
    $script .= "
if (\$relateds = \$this->get{$fkGetter}(\$con)->toKeyValue('{$fk->getTable()->getFirstPrimaryKeyColumn()->getPhpName()}', 'Version')) {

is assuming that all versionable referrers are part of a many (*) relationship and so everything is plural.

The BookstoreEmployeeVersion class also has plural references to the BookstoreEmployeeAccount.


Just mentioned this bug yesterday by myself, too. I wrote a working bugfix, which I would pull request soon.

Propel member

@mrackwitz time to pull request?

Propel member

Hi, @mrackwitz you got the PR?
I just encountered the error, too. Please send the PR, if it's working :-)

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