Propel ORM: originating save() re-triggered in cascaded save
===

I have two Propel-based (Propel 1.6) model classes, FileUpload and Image:

    <table name="file_upload">
      <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
      <column name="name" type="varchar" size="500" required="false" />
      <column name="mime_type" type="varchar" size="100" required="true" />
      <column name="data" type="blob" required="false" lazyLoad="true" />
    </table>

    <table name="image">
      <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
      <column name="file_upload_id" type="integer" required="true" />
      <foreign-key foreignTable="file_upload" onDelete="restrict">
        <reference local="file_upload_id" foreign="id" />	
      </foreign-key>
    </table>

When I instantiate a new Image $image, new FileUpload $upload, register $upload under $image and saving $image hoping for a cascaded save of both $image (second) and $upload (first) ...

    $image = new Image();
    $upload = new FileUpload();
    // [set required properties in both models]
    $image->setFileUpload( $image );
    $image->save();

I get a foreign key violation error:

> Unable to execute UPDATE statement [UPDATE `image` SET `FILE_UPLOAD_ID`=:p1, `UPDATED_AT`=:p2 WHERE image.ID=:p3] [wrapped: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`DATABASENAME`.`image`, CONSTRAINT `image_FK_1` FOREIGN KEY (`file_upload_id`) REFERENCES `file_upload` (`id`))]

I found that that error is caused because $upload->save() invokes BaseFileUpload->doSave(), which, among other things, re-triggers $image->save():

    if ($this->collImages !== null) {
      foreach ($this->collImages as $referrerFK) {
        if (!$referrerFK->isDeleted()) {
          $affectedRows += $referrerFK->save($con);
        }
      }
    }

... which means that FileUpload mirrors reverse references to it from other objects even though it itself is only ever _referenced_, not _referencing_ anything else.

When I override Image->save() to first clear all mirrored references on linked FileUpload and and then call parent::save(), problem goes away:

    public function save( PropelPDO $con = null )
    {
      $upload = $this->getFileUpload();
      if ( null !== $upload && $upload->isModified() ) {
        $upload->clearAllReferences();
        $upload->save( $con );
        $this->setFileUpload( $upload );
      }
      return parent::save( $con );
    }

This approach works but feels hacky. It could also only be used here because I'm easily able to restore external references once the $upload object is saved - in other cases it might not be as simple.

Is there any clean way to prevent re-triggering saving of $image->save() from $upload->save() - without interfering with Propel's default behaviour too much? Thanks.