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

Restore auth when calling API only if needed #7804

Merged
merged 2 commits into from May 10, 2015
Merged

Restore auth when calling API only if needed #7804

merged 2 commits into from May 10, 2015

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented May 1, 2015

Also added tests, there were none before...

@tsteur tsteur added c: Performance For when we could improve the performance / speed of Matomo. Needs Review PRs that need a code review labels May 1, 2015
@tsteur tsteur added this to the Piwik 2.14.0 milestone May 6, 2015
Piwik::postEvent('API.Request.authenticate', array($tokenAuth));
Access::getInstance()->reloadAccess();
SettingsServer::raiseMemoryLimitIfNecessary();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's maybe a matter of taste but I'm not a huge fan of reloadAuthUsingTokenAuth() actually calling doReloadAuthUsingTokenAuth(), it's a bit redundant and makes the code harder to navigate (eg. to illustrate what prevents from having another doReallyReloadAuthUsingTokenAuth()).

Maybe something like that?

public static function reloadAuthUsingTokenAuth()
{
    if (! self::shouldReloadAuthUsingTokenAuth($request)) {
        return;
    }
    // do the thing
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can rename it to doReallyReloadAuthUsingTokenAuth. That method is called by reloadAuthUsingTokenAuth but also when restoring the token. Here we definitely want to reload auth even shouldReloadAuthUsingTokenAuth would return false. That's why I added that method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed it to forceReloadAuthUsingTokenAuth

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 better choice

@mnapoli
Copy link
Contributor

mnapoli commented May 7, 2015

Except the minor comment 👍 Did you see a significant performance difference?

mnapoli added a commit that referenced this pull request May 10, 2015
Restore auth when calling API only if needed
@mnapoli mnapoli merged commit 2db472c into master May 10, 2015
@mnapoli mnapoli deleted the restore_access branch May 10, 2015 02:42
@mattab mattab removed the c: Performance For when we could improve the performance / speed of Matomo. label Jun 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants