Doctrine 1
  1. Doctrine 1
  2. DC-221

Doctrine_Migration fail when used two times

    Details

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

      Description

      The second Doctrine_Migration instance is unusable.

      It is very easy to reproduce the bug :

      // first instance
      $migration = new Doctrine_Migration('/path/to/migration/classes');
      print_r($migration->getMigrationClasses()); // will work, and show the migration classes as expected
      
      // same code, second instance
      $migration = new Doctrine_Migration('/path/to/migration/classes');
      print_r($migration->getMigrationClasses()); // will not work. No more migration classes displayed.
      

      This is due to the fact that Doctrine_Migration->loadMigrationClassesFromDirectory only registers classes that are not already loaded :

      Doctrine_Migration->loadMigrationClassesFromDirectory
      $array = array_diff(get_declared_classes(), $classes);
      $className = end($array);
      

      If a migration class is already declared ( ie the second time we use Doctrine_Migration ), it will not be recognized.

      Thank you for your great work.

        Activity

        Hide
        Jonathan H. Wage added a comment -

        I fixed Doctrine_Migration but this will still exist if you had previously loaded the class manually.

        $array = array_diff(get_declared_classes(), $classes);
        $className = end($array);
        

        This is the only way we have to know what class is in a file, since the class name and file name aren't the same thing.

        Show
        Jonathan H. Wage added a comment - I fixed Doctrine_Migration but this will still exist if you had previously loaded the class manually. $array = array_diff(get_declared_classes(), $classes); $className = end($array); This is the only way we have to know what class is in a file, since the class name and file name aren't the same thing.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: