-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redundant check in Autoloader.php #467
Comments
No, it's not when |
@jens1o in this case the second condition is never reached. |
Yeah. The first condition is only there to avoid calling the rather expensive |
Depending on your use case several autoloader can be active and will be called until the handler which can handle the reqested class can be found. Any autoloader which can not handle a request should exit as fast as possible. The first condition is very quick and does sort out all requests not starting with 'S', the second is more time consuming and does sort out anything not starting with 'Smarty'. Note that strpos() is faster as any string compare functions. |
Believe me that I understand the concept of having the first condition resolve as fast as possible. But the logic of this statement is flawed. It should probably be changed to: if ($class[ 0 ] !== 'S' || strpos($class, 'Smarty') !== 0) { But at its current form (using If you can't understand basic boolean logic, then I give up. |
tsahi-gisha is correct of course. The |
This fix is now in the master branch |
Hi guys, Today at PrestaShop we found that the flawed In our case, since Smarty autoloader was called before the Composer autoload, every Symfony class (like So first of all thanks for fixing this 😉 We're going to fork Smarty and use our fork patched version until the next release. Do you have planned the next release ? If this has impacted us, there might more people impacted by this. |
The following code is taken from
Autoloader.php
:this line does a redundant check:
The second condition is always
true
.The text was updated successfully, but these errors were encountered: