Doctrine 1
  1. Doctrine 1
  2. DC-863

Connection.UnitOfWork::buildFlushTree when loading data from yml file, Incorrect ordering of tables by their relations

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.0, 1.2.1, 1.2.2, 1.2.3
    • Fix Version/s: None
    • Component/s: Connection, Data Fixtures
    • Labels:
      None
    • Environment:
      symfony 1.4.6, windows 7, apache2.2, php5.3.3, mySQL 5.1.49-community

      Description

      I don't know where exactly to start, I'm new here, and i'm not even sure this is a bug. BUT

      We have a database structure with most important tables' PK's as string fields, which function as FK on other tables the basic structure is:

      Artist
      -Album
      -Song
      -Comments

      each artist has multiple songs
      each artist has multiple albums
      each album has multiple songs that belong to the same artist as the album belongs to
      each song has multiple comments

      thus, the UnitOfWork - builtFlushTree should generate

      [0]=>Artist
      [1]=>Album
      [2]=>Song
      [3]=>Comments

      but instead i get:
      [0] => Album
      [1] => Artist
      [2] => Song
      [3] => Lyrics

      which in turn generates:

      QLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`lyrics`.`album`, CONSTRAINT `album_artist_fk_stripped_name_artist_stripped_name` FOREIGN KEY (`artist_fk_stripped_name`) REFERENCES `artist` (`stripped_name`) ON DELETE CASCADE ON UPDATE CASC)
      obviously.

      I've been going through symfony/doctrine code for a whole day trying to figure out why I can't load-data. in the end i get to this buildFlushTree function.
      probably have to go deeper. but so far this is it

      PS. It's my decision to use string fields as PK's and FK even though it's a bad practice, but just because it is a bad practice I shouldn't be unable to work with it.

      1. schema.yml
        6 kB
        Ochoo
      2. test.yml
        1 kB
        Ochoo

        Activity

        Hide
        Ochoo added a comment - - edited

        found a tiny BUG, submitting the fix.

        EDIT: scratch the rest from here.

        <!-----------
        still, fixing the bug does not resolve the issue
        BECAUSE:
        the whole logic of ordering the tables is flawed! it can be proved, don't have time to do so. but trying to come up with a fix myself

        instead of looping through the tables and then through each tables' related tables, either have a recursive function OR implement user defined array sort function, latter of which seems like the proper and correct way to go
        -->

        Show
        Ochoo added a comment - - edited found a tiny BUG, submitting the fix. EDIT: scratch the rest from here. <!----------- still, fixing the bug does not resolve the issue BECAUSE: the whole logic of ordering the tables is flawed! it can be proved, don't have time to do so. but trying to come up with a fix myself instead of looping through the tables and then through each tables' related tables, either have a recursive function OR implement user defined array sort function, latter of which seems like the proper and correct way to go -->
        Hide
        Ochoo added a comment -

        unfortunately i'm unable to commit any changes i have made. just me being a newbie, any help is appreciated

        Show
        Ochoo added a comment - unfortunately i'm unable to commit any changes i have made. just me being a newbie, any help is appreciated
        Hide
        Ochoo added a comment - - edited

        on UnitOfWork.php of Doctrine ORM 1.2.3
        Revision 7684
        right after the line 752:
        array_splice($flushList, $index, 0, $relatedClassName);
        there should be:
        $index++;

        Show
        Ochoo added a comment - - edited on UnitOfWork.php of Doctrine ORM 1.2.3 Revision 7684 right after the line 752: array_splice($flushList, $index, 0, $relatedClassName); there should be: $index++;
        Hide
        atali daoud added a comment -

        @Ochoo: Even with your bugfix, it doesn't seem to work.

        Show
        atali daoud added a comment - @Ochoo: Even with your bugfix, it doesn't seem to work.
        Hide
        Ochoo added a comment -

        thanks atali, i haven't checked it on 1.2.3, just did and you're right. the "bug fix" worked on 1.2.0 but not on 1.2.3. I'm gonna look into it, at least i'll try. but this is a bug right?

        Show
        Ochoo added a comment - thanks atali, i haven't checked it on 1.2.3, just did and you're right. the "bug fix" worked on 1.2.0 but not on 1.2.3. I'm gonna look into it, at least i'll try. but this is a bug right?

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Ochoo
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: