Part of the EllisLab Network
   
 
Directory Separator bug with APPPATH and load_class
Posted: 03 January 2009 11:43 AM   [ Ignore ]  
Summer Student
Total Posts:  6
Joined  11-25-2008

In index.php:

if (strpos($system_folder, '/') === FALSE)
{
    
if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
    
{
        $system_folder
= realpath(dirname(__FILE__)).'/'.$system_folder;
    
}
}
else
{
    
// Swap directory separators to Unix style for consistency
    
$system_folder = str_replace("\\", "/", $system_folder);
}

and in Common.php:

if (file_exists(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT))
    
{
        
require(BASEPATH.'libraries/'.$class.EXT);
        require(
APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT);
        
$is_subclass = TRUE;
    
}
    
else
    
{
        
if (file_exists(APPPATH.'libraries/'.$class.EXT))
        
{
            
require(APPPATH.'libraries/'.$class.EXT);
            
$is_subclass = FALSE;
        
}
        
else
        
{
            
require(BASEPATH.'libraries/'.$class.EXT);
            
$is_subclass = FALSE;
        
}
    }

Both of these have the directory separator “/” hardcoded into strings rather than using DIRECTORY_SEPARATOR.  Because of this, using xampp on windows, I cannot load auto config files because the path isn’t correct and it switches between using / and \.

I’m pretty sure this is a bug but any insight would be great.  I can’t think of how to fix this other than changing all of these to DIRECTORY_SEPARATOR.

Thanks.

Profile
 
 
Posted: 03 January 2009 03:31 PM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  740
Joined  08-03-2006

I have never encountered any problems with using “/” on windows instead of backslash.

It is even possible to use / in the command prompt.

 Signature 

RapidDataMapper: My new ORM, is now released!

IgnitedRecord: Old ORM

MPTtree: A model to handle trees in a database.

YAYParser - Yet Another YAML Parser

Profile
 
 
Posted: 07 January 2009 08:45 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  6
Joined  11-25-2008

You’re completely right! I found the problem and I think that it is a bug in the documentation.

This took me over a week of really learning the codeigniter code but the problem was that I was extending the native Email.php library but I wasn’t passing the config object from my constructor to the original constructor. 

I took what I needed to do directly out of the documentation because the docs discusses extending CI_Email but it doesn’t mention passing the config to the constructor at all.

Profile
 
 
Posted: 08 January 2009 12:54 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Avatar
Total Posts:  23
Joined  08-27-2006

Actually, still could be a bug.

I prefer to keep my system_folder below webroot so I did

line 26: $system_folder = realpath(dirname(__FILE__) . "/../system");

which on windows creates

$system_folder = 'D:\xampplite\htdocs\ominian.com\system'

So

if (strpos($system_folder, '/') === FALSE )

evaluates as a false postive.

Modified line ~63 to read

if (strpos($system_folder, '/') === FALSE && strpos($system_folder, '\\') === FALSE)

Furthermore the entire condition clause makes the assumption that realpath is going to a / delimited path instead of \, which isn’t true on windows. :(

 Signature 

Beware of “experimental code”, the minute you put your guard down and think it’s safe… thats when it pilfers your wallet, knocks your daughter up, and humiliates you infront of a critical audience. -DjW

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120132 Total Logged-in Users: 35
Total Topics: 126279 Total Anonymous Users: 3
Total Replies: 664137 Total Guests: 319
Total Posts: 790416    
Members ( View Memberlist )