ccampbell / sonic

fast, lightweight PHP 5.3 MVC framework
http://www.sonicframework.com
Apache License 2.0
63 stars 11 forks source link

classes are not loaded in correct order after installing an extension #6

Closed ccampbell closed 13 years ago

ccampbell commented 13 years ago

On some operating systems using DirectoryIterator does not keep the files in alphabetical order. Therefore when installing an extension such as the "Database" extension the files are written out with QueryCached.php before Query.php. Since QueryCached depends on Query it causes a fatal error.

This can be solved in a few ways.

  1. Adding include/require statements at the top of the files that have dependencies to include their dependencies.
  2. On extension install resolve class dependencies and reorder the files in the correct order in extensions/installed.json.
  3. Sort the array in alphabetical order in the application when Sonic\App::loadExtension() is called.

Option 1 is probably the simplest to implement, but option 2 seems to make the most sense.

ccampbell commented 13 years ago

This is a temporary fix, but I confirmed that it works with all current extensions. When extensions can be loaded using a single Core file then this will no longer be an issue anyway other than for development.