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

PSR CacheItemItemface is incompatible with WpObjectCacheItem Error #880

Closed
4 tasks done
u382514 opened this issue Oct 18, 2023 · 3 comments
Closed
4 tasks done

PSR CacheItemItemface is incompatible with WpObjectCacheItem Error #880

u382514 opened this issue Oct 18, 2023 · 3 comments
Labels
Scope: Bug Addressing unexpected problems or unintended behavior.

Comments

@u382514
Copy link

u382514 commented Oct 18, 2023

Checklist

  • I have looked into the Readme and the documentation, and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

Receiving the following error when trying to login and redirecting back:

Fatal error: Declaration of Auth0\WordPress\Cache\WpObjectCacheItem::expiresAt(?DateTimeInterface $expiration) must be compatible with Psr\Cache\CacheItemInterface::expiresAt(?DateTimeInterface $expiration): static in /var/www/html/web/app/plugins/wordpress/vendor/auth0/wordpress/src/Cache/WpObjectCacheItem.php on line 45

The function in the PSR CacheItemInterface.php file is showing static like this:

public function expiresAt(?\DateTimeInterface $expiration): static;

while the function in the WpObjectCacheItem.php file under Auth0 does not:

public function expiresAt(?\DateTimeInterface $expiration)
    {
        if ($expiration instanceof DateTimeInterface) {
            $this->expires = $expiration->getTimestamp();
            return $this;
        }

        $this->expires = $expiration;
        return $this;
    }

If I add the ':static' to the Auth0 function, it works.

Reproduction

  1. Install fresh Bedrock
  2. Run composer require symfony/http-client nyholm/psr7 auth0/wordpress:^5.0 on the root
  3. Go into Auth0's wpAuth0.php and change the '// load dependencies' line to the correct vendor/autoload.php. This is because it is weirdly hardcoded instead of discovering the location. Will bring up in separate issue.
  4. Do all the Auth0 configs necessary.
  5. Try signing in.

Additional context

The composer require after running the composer command:

{
    "require": {
        "symfony/http-client": "^6.0",
        "nyholm/psr7": "^1.8",
        "auth0/wordpress": "^5.0"
    }
}

wp-auth0 version

5.1

WordPress version

Latest Bedrock

PHP version

8.2.8

@evansims
Copy link
Member

evansims commented Nov 6, 2023

Hi @u382514 👋 Thanks for raising this, I'll check into it and get back to you

@evansims evansims added the Scope: Bug Addressing unexpected problems or unintended behavior. label Nov 6, 2023
@evansims
Copy link
Member

Hi @u382514, as you noticed, v3 of the PSR-6 interface implemented a breaking change requiring return value types, but the plugin was designed to target v1 || v2. I'll look into updating this soon if it can be done in a way that doesn't break v1 and v2 compatibility. Otherwise, we will need to restrict version support to those previous versions.

@evansims
Copy link
Member

Hey @u382514 👋 Thanks for your patience while we investigated this. I can confirm a fix has been committed and will ship as part of our next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Bug Addressing unexpected problems or unintended behavior.
Projects
None yet
Development

No branches or pull requests

2 participants