Skip to content
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

Autoloader performance issue #461

Closed
nmoinvaz opened this issue May 10, 2018 · 5 comments
Closed

Autoloader performance issue #461

nmoinvaz opened this issue May 10, 2018 · 5 comments
Milestone

Comments

@nmoinvaz
Copy link

It appears that the autoloader slows down the wordpress site significantly.

Running performance monitor I was able to see that for every class that was being searched for, it would search in a bunch of different directories - even for files that were not part of the auth0 plugin. The more plugins I had installed, the worse the problem would get.

image

I believe the issue exists here:

https://github.com/auth0/wp-auth0/blob/9713e6a7cdf4c3446632be5338426dfba102bf3a/WP_Auth0.php#L412

And this is the fix that I did that seems to help things although I don't know if it is a permanent solution:

foreach ( $paths as $p ) {
    foreach ( $exts as $ext ) {
        if (strpos($p.$class.$ext, "WP_Auth0") !== FALSE && file_exists( $p.$class.$ext ) ) {
            require_once $p.$class.$ext;
            return true;
        }
    }
}

Thanks.

@joshcanhelp
Copy link
Contributor

@nmoinvaz - Thank you very much for the thorough report here. I'm going to take a look today and should be able to get this into the next release, coming in the next couple of weeks.

@joshcanhelp
Copy link
Contributor

👆 twitched on the close issue button

Alright, I can confirm that this is trying to autoload all classes that are called in plugins. Moving this to high priority to fix and should have a PR ready next week at some point.

@nmoinvaz thanks again for the heads-up here. Your solution is close but:

  • You should check for the name at the very top of that method, exit early.
  • There are a few classes that do not start with WP_Auth0 ... the JWT verifier library for one (used during login) called JWT and the Twitter API library (only used with social sharing, IIRC) called TwitterAPIExchange)

@joshcanhelp
Copy link
Contributor

@nmoinvaz - FYI, I just submitted a PR to correct this issue, linked above. This will be included in the next release being tested right now. It still needs a review on our end but if you want to patch that method (changed lines) on a test site and make sure it works for you, go ahead. Once that PR is merged, you're safe to make that change in production and when the plugin updates, those changes will be retained.

Thanks again for the report!

@joshcanhelp joshcanhelp added this to the 3.6.0 milestone May 22, 2018
@nmoinvaz
Copy link
Author

I have tested it and it works well so far.

@joshcanhelp
Copy link
Contributor

Fixed in #465, merged into dev and ready for release 👍

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants