Declaration Issue for Get Cache Items

robdog

Well-known member
Here is the error that I am running into:
PHP Fatal error: Declaration of Symfony\Component\Cache\CacheItem::get() must be compatible with Psr\Cache\CacheItemInterface::get(): mixed

The vendor file doesn't seem to have the response value for "mixed". I am using PHP 8.3 and on the latest version of XenForo.

Let me know if you need any other details.
 
The PSR interface we ship (src/vendor/psr/cache/src/CacheItemInterface.php) does not have the return type either, as it is not compatible with PHP 7.2. Do you have an add-on that has a dependency (or transitive dependency) on psr/cache? If so, you'll need to pin it to ^1.0|^2.0.
 
I was able to get this fixed. Here are all the items I had to pin:

"guzzlehttp/guzzle": "7.8.1",
"guzzlehttp/promises": "2.0.2",
"guzzlehttp/psr7": "2.6.2",
"psr/cache": "^1.0|^2.0",
"psr/log": "^1.1|^2",

Thanks @Jeremy P for pointing me in the right direction.
 
The PSR interface we ship (src/vendor/psr/cache/src/CacheItemInterface.php) does not have the return type either, as it is not compatible with PHP 7.2. Do you have an add-on that has a dependency (or transitive dependency) on psr/cache? If so, you'll need to pin it to ^1.0|^2.0.

Hey @Jeremy P & @robdog ,

I get following error, when I try to open: https://www.mydomain.com/help/bb-codes/

1747817094173.webp


1747817582297.webp

I am using XF v2.3.6 and [MMO] Hide Bb-Code Content System 2.3.4.
I am hosting the Website wih Plesk and the Website is behind Cloudflare.


I try already PHP 8.1.x - 8.4.x but allways the same issue. The addon developer says it's not releated to the addon.

I have also tried with adding
1747819147691.webp

under:
/var/www/vhosts/worldofiptv.com/httpdocs/src/addons/MMO/CoreLib/composer.json

and run:
Bash:
root@srv:/var/www/vhosts/mydomain.com/httpdocs/src/addons/MMO/CoreLib# composer update
Loading composer repositories with package information
Updating dependencies
Lock file operations: 2 installs, 14 updates, 1 removal
  - Removing symfony/polyfill-php73 (v1.27.0)
  - Locking carbonphp/carbon-doctrine-types (3.2.0)
  - Upgrading nesbot/carbon (2.66.0 => 2.73.0)
  - Upgrading psr/cache (1.0.1 => 2.0.0)
  - Locking psr/clock (1.0.0)
  - Upgrading psr/container (1.1.2 => 2.0.2)
  - Upgrading psr/log (1.1.4 => 3.0.2)
  - Upgrading symfony/cache (v5.4.22 => v6.4.21)
  - Upgrading symfony/cache-contracts (v2.5.2 => v2.5.4)
  - Upgrading symfony/deprecation-contracts (v2.5.2 => v3.5.1)
  - Upgrading symfony/expression-language (v5.4.21 => v5.4.45)
  - Upgrading symfony/polyfill-mbstring (v1.27.0 => v1.32.0)
  - Upgrading symfony/polyfill-php80 (v1.27.0 => v1.32.0)
  - Upgrading symfony/service-contracts (v2.5.2 => v3.5.1)
  - Upgrading symfony/translation (v5.4.22 => v6.4.21)
  - Upgrading symfony/translation-contracts (v2.5.2 => v3.5.1)
  - Upgrading symfony/var-exporter (v5.4.21 => v6.4.21)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 2 installs, 14 updates, 1 removal
  - Downloading symfony/translation-contracts (v3.5.1)
  - Downloading symfony/polyfill-mbstring (v1.32.0)
  - Downloading symfony/deprecation-contracts (v3.5.1)
  - Downloading symfony/translation (v6.4.21)
  - Downloading symfony/polyfill-php80 (v1.32.0)
  - Downloading psr/clock (1.0.0)
  - Downloading carbonphp/carbon-doctrine-types (3.2.0)
  - Downloading nesbot/carbon (2.73.0)
  - Downloading psr/cache (2.0.0)
  - Downloading symfony/cache-contracts (v2.5.4)
  - Downloading symfony/var-exporter (v6.4.21)
  - Downloading symfony/cache (v6.4.21)
  - Downloading symfony/expression-language (v5.4.45)
  - Removing symfony/polyfill-php73 (v1.27.0)
  - Upgrading symfony/translation-contracts (v2.5.2 => v3.5.1): Extracting archive
  - Upgrading symfony/polyfill-mbstring (v1.27.0 => v1.32.0): Extracting archive
  - Upgrading symfony/deprecation-contracts (v2.5.2 => v3.5.1): Extracting archive
  - Upgrading symfony/translation (v5.4.22 => v6.4.21): Extracting archive
  - Upgrading symfony/polyfill-php80 (v1.27.0 => v1.32.0): Extracting archive
  - Installing psr/clock (1.0.0): Extracting archive
  - Installing carbonphp/carbon-doctrine-types (3.2.0): Extracting archive
  - Upgrading nesbot/carbon (2.66.0 => 2.73.0): Extracting archive
  - Upgrading psr/log (1.1.4 => 3.0.2): Extracting archive
  - Upgrading psr/cache (1.0.1 => 2.0.0): Extracting archive
  - Upgrading symfony/cache-contracts (v2.5.2 => v2.5.4): Extracting archive
  - Upgrading psr/container (1.1.2 => 2.0.2): Extracting archive
  - Upgrading symfony/service-contracts (v2.5.2 => v3.5.1): Extracting archive
  - Upgrading symfony/var-exporter (v5.4.21 => v6.4.21): Extracting archive
  - Upgrading symfony/cache (v5.4.22 => v6.4.21): Extracting archive
  - Upgrading symfony/expression-language (v5.4.21 => v5.4.45): Extracting archive
Generating autoload files
12 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found.

but I still get the issue. I don't know what I did wrong and how to fix it.
I'm really desperate, so I would be very grateful for some help.
 
Last edited:
You're depending (transitively) on symfony/cache 6.4 but we ship and expect 5.4. You can run composer depends --tree symfony/cache to see why.
 
What Jeremy said... is there a specific reason you need to include the updated version of symfony?
 
I receive this error when rebuilding master data:
Code:
Fatal error: Declaration of Symfony\Component\Cache\CacheItem::get() must be compatible with Psr\Cache\CacheItemInterface::get(): mixed in /home/nginx/domains/domain.com/public/src/vendor/symfony/cache/CacheItem.php on line 49

Code:
Stack trace
#0 [internal function]: XF::handleFatalError()
#1 {main}

Request state
array(4) {
  ["url"] => string(34) "/install/index.php?upgrade/run-job"
  ["referrer"] => string(64) "https://domain.com/install/index.php?upgrade/run-job"
  ["_GET"] => array(1) {
    ["upgrade/run-job"] => string(0) ""
  }
  ["_POST"] => array(3) {
    ["_xfRedirect"] => string(65) "https://domain.com/install/index.php?upgrade/complete"
    ["_xfToken"] => string(8) "********"
    ["execute"] => string(1) "1"
  }
}

Any idea how I can debug this?
 
Back
Top Bottom