-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fixed auto-loader to skip non-WP-Auth0 classes #465
Conversation
|
||
// Anything that's not part of the above and not name-spaced can be skipped. | ||
if ( 0 !== strpos( $class, 'WP_Auth0' ) ) { | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should you log something on this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely not. This is called for all class instantiations. It's not an error if an non-WP-Auth0 class is being called. We want to escape quickly.
$source_dir . 'admin/', | ||
$source_dir . 'exceptions/', | ||
$source_dir . 'wizard/', | ||
$source_dir . 'initial-setup/', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this last comma will be ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It's a PHP standard/style to add a comma on the last line of an array
$source_dir . 'initial-setup/', | ||
); | ||
|
||
foreach ( $paths as $path ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how often this method would be called, but I suppose several times per execution. Is there any way of iterating through all the files in a more efficient way? Maybe accepting an array of "classes to require" so you can iterate once and require them all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
several times per execution
Correct
Maybe accepting an array of "classes to require"
That would defeat the purpose of the autoloader. This is here to "magically" include the necessary files for whatever class you might call. There is a more efficient way to do this using Namespaces but that would require a lot more work (I have it on my list)
foreach ( $paths as $path ) { | ||
if ( file_exists( $path . $class . '.php' ) ) { | ||
require_once $path . $class . '.php'; | ||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to return false
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope!
Fixes #461