Doctrine 1
  1. Doctrine 1
  2. DC-603

Doctrine model loading broken on Centos/RHEL 5

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Doctrine 1.1.5 on Centos 5.4

      Description

      The loading of models fails on Centos 5 systems because loadModels() relies on RecursiveDirectoryIterator which seems to return filenames in different orders on different operating systems (see this older doctrine bug: http://trac.doctrine-project.org/ticket/1688 ).

      The result is that Doctrine tries to load the model class before it's base class which fails because the base-class is not yet known at that time.

      Example:

      I setup the auto-loading like this:

      spl_autoload_register( array('Doctrine', 'autoload') );
      Doctrine::loadModels('/data/models');

      and "/data" looks like this:
      /data/models/ftp/FtpTransfers.php
      /data/models/ftp/FtpTransfersTable.php
      /data/models/ftp/generated/BaseFtpTransfers.php

      However when I run a test app I get the following error:
      PHP Fatal error: Class 'BaseFtpTransfers' not found in /data/models/
      ftp/FtpTransfers.php on line 13

      Executing the same code works fine on Fedora.

      This is the order in which loadModels() tries to load the files on both systems:

      Centos 5:
      /data/models/ftp/ftp_logs/FtpTransfers.php
      /data/models/ftp/ftp_logs/FtpStatsHour.php
      /data/models/ftp/ftp_logs/FtpStatsDayTable.php
      /data/models/ftp/ftp_logs/FtpTransfersTable.php
      /data/models/ftp/ftp_logs/generated/BaseFtpStatsHour.php
      /data/models/ftp/ftp_logs/generated/BaseFtpTransfers.php
      /data/models/ftp/ftp_logs/generated/BaseFtpStatsDay.php
      /data/models/ftp/ftp_logs/FtpStatsHourTable.php
      /data/models/ftp/ftp_logs/FtpStatsDay.php

      Fedora 11:
      /data/models/ftp/ftp_logs/generated/BaseFtpStatsHour.php
      /data/models/ftp/ftp_logs/generated/BaseFtpTransfers.php
      /data/models/ftp/ftp_logs/generated/BaseFtpStatsDay.php
      /data/models/ftp/ftp_logs/FtpStatsHourTable.php
      /data/models/ftp/ftp_logs/FtpStatsDayTable.php
      /data/models/ftp/ftp_logs/FtpTransfers.php
      /data/models/ftp/ftp_logs/FtpStatsHour.php
      /data/models/ftp/ftp_logs/FtpStatsDay.php
      /data/models/ftp/ftp_logs/FtpTransfersTable.php

        Activity

        Hide
        Jonathan H. Wage added a comment -

        The aggressive model loading can only be used if you handle the dependencies between classes yourself or you don't have any dependencies and it is no problem to aggressively require all files it finds in a directory. It sounds like you need to use conservative or pear style model loading.

        Show
        Jonathan H. Wage added a comment - The aggressive model loading can only be used if you handle the dependencies between classes yourself or you don't have any dependencies and it is no problem to aggressively require all files it finds in a directory. It sounds like you need to use conservative or pear style model loading.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: