We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Autoloader can load a class file more than once

Developer Preview

Greg Ferrell's avatar
Greg Ferrell
102 posts
10 years ago
Greg Ferrell's avatar Greg Ferrell

I found this error because i named a model’s class differently than its filename on accident.

If you have a model named Test.php and inside there is no class Test {} and you call class_exists('\Namespace\Model\Test') more than one time, the autoloader will attempt to load the file a second time, throwing a duplicate class error.

To fix the issue i changed:

/EllisLab/ExpressionEngine/Core/Autoloader.php:100

from:

if (file_exists($class_path))
    {
     require $class_path;
     return;
    }

to:

if (file_exists($class_path))
    {
     require_once $class_path;
     return;
    }
       
Pascal Kriete's avatar
Pascal Kriete
2,589 posts
10 years ago
Pascal Kriete's avatar Pascal Kriete

Nice catch! Will be fixed.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.