Skip to content

Commit

Permalink
Bug in autoloader if WB_PATH contained Capital letters.
Browse files Browse the repository at this point in the history
The autoloader enforces  the use of non capital letters in classes loaded
by directory selection. The strtolower function did too much and lowered the
Path too ...
  • Loading branch information
NorHei committed Nov 18, 2015
1 parent 15a191d commit ca2f33a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions wbce/framework/class.autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ class WbAuto{
public static $Files=array(); // Class filename combinations for loader

//Search templates to search for files in the directories
public static $Types=array('%s.class.php',
public static $Types=array('class.%s.php',
'%s.class.php',
'%s.class.inc',
'%s.php',
'%s.inc',
'%s.inc.php',
'class.%s.php',
'%s.inc.php',
'class.%s.inc');

// The function actually registered to PHP autoloading
static function Loader($ClassName){
//already loaded, never mind
//echo $ClassName;
//echo $ClassName."<br />";
if (class_exists($ClassName, FALSE)) return FALSE;

//if there is an fileentry for this class
Expand All @@ -35,11 +35,10 @@ static function Loader($ClassName){
//Search dirs for matching class files
foreach (WbAuto::$Dirs as $sDirVal) {
foreach (WbAuto::$Types as $sTypeVal) {
$sTestFile= $sDirVal. sprintf($sTypeVal, $ClassName);
$sTestFile= strtolower($sTestFile);
$sTestFile= $sDirVal. strtolower(sprintf($sTypeVal, $ClassName));
//echo $sTestFile."</br>";
if (is_file($sTestFile)) {
include_once($sTestFile);
include($sTestFile);
return FALSE;
}
}
Expand All @@ -57,7 +56,7 @@ static function AddFile ($ClassName="", $ClassFile="", $overwrite= false){

// More Checks
$LoadFile = WB_PATH.$ClassFile;
if (!is_file($LoadFile)) return ("Not a file: $LoadFile");
if (!is_file($LoadFile)) return ("File does not exist or not a file: $LoadFile");
if (!is_readable($LoadFile)) return ("File not readable: $LoadFile");

// if all is ok set new Classfile
Expand Down

0 comments on commit ca2f33a

Please sign in to comment.