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

IsEmpty check in storage should not trigger reading from the mapper #585

Merged
merged 1 commit into from
Dec 12, 2015
Merged

Conversation

kachar
Copy link
Contributor

@kachar kachar commented Apr 29, 2015

$auth = $sm->get('zfcuser_auth_service');

if ($auth->hasIdentity()) {       // Mapper is called here
    $user = $auth->getIdentity(); // instead of here
    // ...
}
// Zend\Authentication\AuthenticationService

public function hasIdentity()
{
    return !$this->getStorage()->isEmpty();  // Mapper reads the data inside the isEmpty check
}

public function getIdentity()
{
    $storage = $this->getStorage();

    if ($storage->isEmpty()) {
        return null;
    }

    return $storage->read(); // Here we are using already cached data
}

What do you think about this proposal?

@kachar kachar changed the title IsEmpty check in storage should not trigger additional read from the mapper IsEmpty check in storage should not trigger reading from the mapper Apr 29, 2015
@Danielss89 Danielss89 added this to the 1.4.0 milestone Dec 12, 2015
Danielss89 added a commit that referenced this pull request Dec 12, 2015
IsEmpty check in storage should not trigger reading from the mapper
@Danielss89 Danielss89 merged commit 6e286ef into ZF-Commons:1.x Dec 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants