Elxis CMS Forum
Support => Elxis 4.x/5.x DEV => Topic started by: GavinKou on August 03, 2013, 19:12:45
-
i wanna to integrate smarty with elxis.
but found some strange errors.
after disabled smarty mute model and register a shutdown function to debug.
i think got the root cause finally , so reported it here hope it can be fixed officially in someday
which is the trigger_error call of autoloader in loader.php will broke spl_autoloader loader chain.
function autoloader($class) {
if (strpos($class, 'Swift') === 0) { return false; }
if (elxisLoader::loadClass($class)) {
return true;
} else {
// trigger_error('Class "'.$class.'" could not be autoloaded by the Elxis loader', E_USER_ERROR);
return false;
}
}
here the trigger_error line will triger an error when fails to find a smarty class in elxis style,
then it will stop spl to run the rest functions in queue of autoload functions, which means will skip the rest autoload funcionts.
even smartyAutoload function exist in the queue.
after comment that line out. everything came back.
-
If you comment that line Elxis will not generate a fatal error page when a class does not exist, neither it will write this in logs or inform you. The issue will be escalated to the next autoloader, this from smarty that will finally generate the error but in the meanwhile Elxis will generate fatal errors due to the miss of the class. I think that you should change the Elxis autoloader in order to detect classes from smarty like we have done for the Swift mailer. Smarty does use the word "Smarty" as a prefix for its classes so the problem can be easily solved:
function autoloader($class) {
if (strpos($class, 'Swift') === 0) { return false; }
if (strpos($class, 'Smarty') === 0) { return false; }
if (elxisLoader::loadClass($class)) {
return true;
} else {
trigger_error('Class "'.$class.'" could not be autoloaded by the Elxis loader', E_USER_ERROR);
return false;
}
}
Irrelevant note
I just noticed something interesting: I have written 7777 posts in this forum which started in summer 2006 (7 years old). So I have 7777 articles in 7 years!
Too many seven's, it is weird!
-
Congrats from ***** ! (on irrelevant note)
-
hum that make sense
thanks Mr 7777 ;D
If you comment that line Elxis will not generate a fatal error page when a class does not exist, neither it will write this in logs or inform you. The issue will be escalated to the next autoloader, this from smarty that will finally generate the error but in the meanwhile Elxis will generate fatal errors due to the miss of the class. I think that you should change the Elxis autoloader in order to detect classes from smarty like we have done for the Swift mailer. Smarty does use the word "Smarty" as a prefix for its classes so the problem can be easily solved:
function autoloader($class) {
if (strpos($class, 'Swift') === 0) { return false; }
if (strpos($class, 'Smarty') === 0) { return false; }
if (elxisLoader::loadClass($class)) {
return true;
} else {
trigger_error('Class "'.$class.'" could not be autoloaded by the Elxis loader', E_USER_ERROR);
return false;
}
}
Irrelevant note
I just noticed something interesting: I have written 7777 posts in this forum which started in summer 2006 (7 years old). So I have 7777 articles in 7 years!
Too many seven's, it is weird!