Skip to content

Commit

Permalink
* (Fixes issue 479) Changed the order of imported directories in the …
Browse files Browse the repository at this point in the history
…include paths.
  • Loading branch information
qiang.xue committed Aug 6, 2009
1 parent 4a6a5e8 commit 1ad98b9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -29,6 +29,7 @@ Version 1.0.8 To be released
- New: Added CExistValidator.criteria property (Qiang)
- New: Improved CHtml::statefulForm() to make it XHTML-compliant (Qinag)
- New: Added CBaseUserIdentity::clearState() (Qiang)
- Chg #479: Imported path aliases now have precedence over existing include paths (Qiang)
- Chg: Modified the count() method of relational AR to support counting composite keys (Qiang)
- Chg: Reverted back the support for assigning a related object to an AR object (Qiang)

Expand Down
10 changes: 10 additions & 0 deletions UPGRADE
Expand Up @@ -12,6 +12,16 @@ for both A and B.

Upgrading from v1.0.7
---------------------
- A directory imported using Yii::import() will have precedence over
any existing include paths. For example, if we import 'application.models.*',
then the corresponding directory will be searched before any other
existing include paths. This also means, a directory imported later will
have precedence over directories imported earlier. Previously, this order
was reversed. This change may affect you if you have several classes with
the same name and they are imported via different directories. You will need
to adjust the import order of these directories to make sure your existing
applications are not broken due to this change.


Upgrading from v1.0.6
---------------------
Expand Down
10 changes: 9 additions & 1 deletion framework/YiiBase.php
Expand Up @@ -54,6 +54,7 @@ class YiiBase
private static $_aliases=array('system'=>YII_PATH); // alias => path
private static $_imports=array(); // alias => class name or directory
private static $_classes=array();
private static $_includePaths; // list of include paths
private static $_app;
private static $_logger;

Expand Down Expand Up @@ -249,7 +250,14 @@ public static function import($alias,$forceInclude=false)
}
else // a directory
{
set_include_path(get_include_path().PATH_SEPARATOR.$path);
if(self::$_includePaths===null)
{
self::$_includePaths=array_unique(explode(PATH_SEPARATOR,get_include_path()));
if(($pos=array_search('.',self::$_includePaths,true))!==false)
unset(self::$_includePaths[$pos]);
}
array_unshift(self::$_includePaths,$path);
set_include_path('.'.PATH_SEPARATOR.implode(PATH_SEPARATOR,self::$_includePaths));
return self::$_imports[$alias]=$path;
}
}
Expand Down

0 comments on commit 1ad98b9

Please sign in to comment.