How to resolve Method '...\EntityManager_9a5be93::refresh()' is not compatible

In a previous post I commented that I was trying to add guzzlehttp to a suitecrm-8 instance. In the above there has been no success so far. But then I noticed that when trying to access the instance’s website I was getting a 500 error. In logs/prod/prod.log I get the following messages

[2023-02-23 21:31:14] php.CRITICAL: Uncaught Error: Class 'ApiPlatform\Core\Metadata\Resource\Factory\CachedResourceNameCollectionFactory' not found {"exception":"[object] (Error(code: 0): Class 'ApiPlatform\\Core\\Metadata\\Resource\\Factory\\CachedResourceNameCollectionFactory' not found at /var/www/crm.local/cache/prod/ContainerW6S4Mxo/App_KernelProdContainer.php:1562)"} []
[2023-02-23 21:31:15] php.CRITICAL: Fatal Compile Error: Declaration of ContainerW6S4Mxo\EntityManager_9a5be93::refresh($entity) must be compatible with Doctrine\ORM\EntityManager::refresh($entity, ?int $lockMode = NULL) {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Compile Error: Declaration of ContainerW6S4Mxo\\EntityManager_9a5be93::refresh($entity) must be compatible with Doctrine\\ORM\\EntityManager::refresh($entity, ?int $lockMode = NULL) at /var/www/crm.local/cache/prod/ContainerW6S4Mxo/EntityManager_9a5be93.php:130)"} []

How can I resolve this Method 'ContainerW6S4Mxo\EntityManager_9a5be93::refresh()' is not compatible with method 'Doctrine\ORM\EntityManager::refresh()'

Update 1

In case it is relevant. I have noticed that when comparing the composer.json and composer.lock file with those of another instance of suitecrm-8 there are changes

when comparing composer.json

--- /var/www/crm.local/composer.json
+++ /var/www/another-crm.local/composer.json
@@ -43,11 +43,9 @@
     "gymadarasz/ace": "^1.2",
     "gymadarasz/imagesloaded": "^4.1",
     "hslavich/oneloginsaml-bundle": "^2.2",
-    "javanile/php-imap2": "^0.1.10",
     "jeroendesloovere/vcard": "^1.7",
     "justinrainbow/json-schema": "^5.2",
     "lcobucci/jwt": "3.3.3",
-    "league/oauth2-client": "^2.6",
     "league/oauth2-server": "^5.1",
     "league/uri": "^4.2.3",
     "monolog/monolog": "^1.23",
@@ -90,7 +88,7 @@
     "voku/anti-xss": "^4.1",
     "webonyx/graphql-php": "^0.13.8",
     "wikimedia/composer-merge-plugin": "^2.0",
-    "zbateson/mail-mime-parser": "^2.2",
+    "zbateson/mail-mime-parser": "^1.1",
     "zf1/zend-gdata": "^1.12",
     "zf1/zend-loader": "^1.12",
     "zf1/zend-oauth": "^1.12",

when comparing composer.lock

--- /var/www/crm.local/composer.lock
+++ /var/www/another-crm.local/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "03e0fe46f891b8651d48081142b9f00f",
+    "content-hash": "fe47d13c51809917fd9675d20538ce5e",
     "packages": [
         {
             "name": "api-platform/core",
@@ -2731,70 +2731,6 @@
             "time": "2020-11-30T20:24:00+00:00"
         },
         {
-            "name": "javanile/php-imap2",
-            "version": "0.1.10",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/javanile/php-imap2.git",
-                "reference": "f96973ecf0d2d5005ee607faa13b0a5f61745ad9"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/javanile/php-imap2/zipball/f96973ecf0d2d5005ee607faa13b0a5f61745ad9",
-                "reference": "f96973ecf0d2d5005ee607faa13b0a5f61745ad9",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=7.0",
-                "zbateson/mail-mime-parser": "^2.2"
-            },
-            "require-dev": {
-                "phpunit/phpunit": "^6.5"
-            },
-            "suggest": {
-                "ext-iconv": "For best support/performance",
-                "ext-mbstring": "For best support/performance"
-            },
-            "type": "library",
-            "extra": {
-                "thanks": {
-                    "name": "Roundcube",
-                    "url": "https://github.com/roundcube"
-                }
-            },
-            "autoload": {
-                "files": [
-                    "bootstrap.php"
-                ],
-                "psr-4": {
-                    "Javanile\\Imap2\\": "src"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Francesco Bianco",
-                    "homepage": "https://github.com/francescobianco"
-                }
-            ],
-            "description": "PHP IMAP with OAUTH2",
-            "homepage": "https://github.com/javanile/php-imap2",
-            "keywords": [
-                "exchange",
-                "gmail",
-                "google",
-                "imap",
-                "microsoft",
-                "oauth",
-                "oauth2",
-                "outlook"
-            ],
-            "time": "2022-10-25T08:46:34+00:00"
-        },
-        {
             "name": "jeremykendall/php-domain-parser",
             "version": "4.0.3-alpha",
             "source": {
@@ -3270,72 +3206,6 @@
                 "listener"
             ],
             "time": "2018-11-26T11:52:41+00:00"
-        },
-        {
-            "name": "league/oauth2-client",
-            "version": "2.6.1",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/thephpleague/oauth2-client.git",
-                "reference": "2334c249907190c132364f5dae0287ab8666aa19"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/thephpleague/oauth2-client/zipball/2334c249907190c132364f5dae0287ab8666aa19",
-                "reference": "2334c249907190c132364f5dae0287ab8666aa19",
-                "shasum": ""
-            },
-            "require": {
-                "guzzlehttp/guzzle": "^6.0 || ^7.0",
-                "paragonie/random_compat": "^1 || ^2 || ^9.99",
-                "php": "^5.6 || ^7.0 || ^8.0"
-            },
-            "require-dev": {
-                "mockery/mockery": "^1.3.5",
-                "php-parallel-lint/php-parallel-lint": "^1.3.1",
-                "phpunit/phpunit": "^5.7 || ^6.0 || ^9.5",
-                "squizlabs/php_codesniffer": "^2.3 || ^3.0"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-2.x": "2.0.x-dev"
-                }
-            },
-            "autoload": {
-                "psr-4": {
-                    "League\\OAuth2\\Client\\": "src/"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Alex Bilbie",
-                    "email": "hello@alexbilbie.com",
-                    "homepage": "http://www.alexbilbie.com",
-                    "role": "Developer"
-                },
-                {
-                    "name": "Woody Gilk",
-                    "homepage": "https://github.com/shadowhand",
-                    "role": "Contributor"
-                }
-            ],
-            "description": "OAuth 2.0 Client Library",
-            "keywords": [
-                "Authentication",
-                "SSO",
-                "authorization",
-                "identity",
-                "idp",
-                "oauth",
-                "oauth2",
-                "single sign on"
-            ],
-            "time": "2021-12-22T16:42:49+00:00"
         },
         {
             "name": "league/oauth2-server",
@@ -10599,28 +10469,27 @@
         },
         {
             "name": "zbateson/mail-mime-parser",
-            "version": "2.2.3",
+            "version": "1.3.3",
             "source": {
                 "type": "git",
                 "url": "https://github.com/zbateson/mail-mime-parser.git",
-                "reference": "295c7f82a8c44af685680d9df6714beb812e90ff"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/zbateson/mail-mime-parser/zipball/295c7f82a8c44af685680d9df6714beb812e90ff",
-                "reference": "295c7f82a8c44af685680d9df6714beb812e90ff",
+                "reference": "244b70963945293b5225da2553239a06987d1a11"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/zbateson/mail-mime-parser/zipball/244b70963945293b5225da2553239a06987d1a11",
+                "reference": "244b70963945293b5225da2553239a06987d1a11",
                 "shasum": ""
             },
             "require": {
                 "guzzlehttp/psr7": "^1.7.0|^2.0",
                 "php": ">=5.4",
-                "pimple/pimple": "^3.0",
                 "zbateson/mb-wrapper": "^1.0.1",
                 "zbateson/stream-decorators": "^1.0.6"
             },
             "require-dev": {
                 "mikey179/vfsstream": "^1.6.0",
-                "sanmai/phpunit-legacy-adapter": "^6.3 || ^8.2"
+                "sanmai/phpunit-legacy-adapter": "^6.3 || ^8"
             },
             "suggest": {
                 "ext-iconv": "For best support/performance",
@@ -10663,7 +10532,7 @@
                     "type": "github"
                 }
             ],
-            "time": "2022-09-28T16:31:49+00:00"
+            "time": "2021-11-06T00:47:49+00:00"
         },
         {
             "name": "zbateson/mb-wrapper",
@@ -14227,7 +14096,6 @@
                 "issues": "https://github.com/PHP-CS-Fixer/diff/issues",
                 "source": "https://github.com/PHP-CS-Fixer/diff/tree/v1.3.1"
             },
-            "abandoned": true,
             "time": "2020-10-14T08:39:05+00:00"
         },
         {

That is weird. Try clearing the cache

On your SuiteCRM 8 instance root, please run:

./bin/console cache:clear

DO you have any idea what that ContainerW6S4Mxo is about? I never heard of that

hello. thanks for answering. ContainerW6S4Mxo is a directory that is created in cache/prod

I have managed to solve the problem by reversing the modification that was made in the composer.lock file after trying composer update What I have done is copy the content of composer.lock from another instance of suitecrm-8 to the one that had the problem and then do composer install

composer update is not advisable.

You should do just

composer install --no-dev

Thanks for the advice