Doctrine 1
  1. Doctrine 1
  2. DC-191

Doctrine_Migration->loadMigrationClassesFromDirectory fail when launched 2 times

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.0-ALPHA2
    • Fix Version/s: 1.2.0-BETA2
    • Component/s: Migrations
    • Labels:
      None
    • Environment:
      daily symfony 1.3 svn

      Description

      When I need to create a Doctrine_Migration twice during a same php processus, the migrations version numbers get wrong.

      In Doctrine_Migration->loadMigrationClassesFromDirectory method, I see :

              if (isset(self::$_migrationClassesForDirectories[$directory])) {
                  $migrationClasses = (array) self::$_migrationClassesForDirectories[$directory];
                  $this->_migrationClasses = array_merge($migrationClasses, $this->_migrationClasses);
              }
      

      The problem is that array_merge loose the array keys. In the $this->_migrationClasses context, array keys are very important because they are the version numbers.

      So when if (isset(self::$_migrationClassesForDirectories[$directory])) is true ( ie the second time we use the Doctrine_Migration classs ) all the migrations versions get wrong.

      I hope my description is clear enough.

        Activity

        Hide
        Jonathan H. Wage added a comment -

        After looking at it, that code didn't make sense and it could never work, you are right. I removed it. Now if you call that function twice it will reset everything and reload the classes from the configured directories.

        Show
        Jonathan H. Wage added a comment - After looking at it, that code didn't make sense and it could never work, you are right. I removed it. Now if you call that function twice it will reset everything and reload the classes from the configured directories.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            thibault duplessis
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: