Fatal error : Class Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy contains 1 abstract method... (Symfony2.8/PHP7)

Fatal error : Class Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy contains 1 abstract method... (Symfony2.8/PHP7)

几个月前,我们将公司内网从 Symfony 2.3 升级到 Symfony 2.8,从 PHP 5.6 升级到 7.0.10。 然后,由于循环引用,我们遇到了很多"Fatal Errors",可以通过重新启动Wampserver "erased"。 我读到这可能是因为将一些参数传递给服务。我通过仅传递容器并将其设置为 属性 来纠正此问题,即使我不相信这是一个好习惯。 我还读到这可能是因为 opcache,所以我禁用了它。

之后,我们不再有这个问题。然而,自两周以来,一个新的 "Fatal error" 随机出现:

PHP Fatal error:  Class Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::open) in C:\wamp\www\symfony\app\cache\prod\classes.php on line 393

PHP Fatal error:  Class Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::read) in C:\wamp\www\symfony\app\cache\prod\classes.php on line 393

我们只需重新启动服务器即可。我看到很多人有类似的错误,但我找不到任何真正的解决方案。我不知道这是 PHP 错误还是由于 Symfony 2.8 - PHP7 不兼容,尽管 Symfony achieves 100% PHP7 compatibility 还是我们代码中的错误。

在内网上进行特定操作后,我会尝试了解是否会出现此错误。

我希望我的问题有所不同并且有人会找到解决方案。如果我忘记了什么,或者如果您想查看代码的另一部分,请告诉我!

我的配置:

composer.json :

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-4": { "": "src/" },
        "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
    },
    "require": {
        "php": ">=5.3.9",
        "symfony/symfony": "2.8.*",
        "doctrine/orm": "^2.4.8",
        "doctrine/doctrine-bundle": "~1.4",
        "symfony/swiftmailer-bundle": "~2.3,>=2.3.10",
        "symfony/monolog-bundle": "^3.0.2",
        "sensio/distribution-bundle": "~5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "~2.0",
        "friendsofsymfony/user-bundle": "v2.0.0-beta2",
        "friendsofsymfony/jsrouting-bundle": "dev-master",
        "liuggio/ExcelBundle": "2.0.*@dev",
        "knplabs/knp-snappy-bundle": "dev-master",
        "h4cc/wkhtmltopdf-amd64": "0.11.0-RC1",
        "symfony/intl": "^2.8",
        "symfony/property-access": "^3.2",
        "symfony/assetic-bundle": "^2.8"
    },
    "require-dev": {
        "sensio/generator-bundle": "~3.0",
        "escapestudios/symfony2-coding-standard": "~2.0"
    },
    "scripts": {
        "symfony-scripts": [
            "Incenteev\ParameterHandler\ScriptHandler::buildParameters",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-install-cmd": [
            "@symfony-scripts"
        ],
        "post-update-cmd": [
            "@symfony-scripts"
        ],
        "build-params": [
            "Incenteev\ParameterHandler\ScriptHandler::buildParameters"
          ]
    },
    "config": {
        "bin-dir": "bin",
        "platform": {
            "php": "7.0.10"
        }
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "2.8-dev"
        }
    }
}

作曲家表演 :

composer/ca-bundle                     1.0.7
doctrine/annotations                   v1.4.0
doctrine/cache                         v1.6.1
doctrine/collections                   v1.4.0
doctrine/common                        v2.7.2
doctrine/dbal                          v2.5.12
doctrine/doctrine-bundle               1.6.8
doctrine/doctrine-cache-bundle         1.3.0
doctrine/inflector                     v1.1.0
doctrine/instantiator                  1.0.5
doctrine/lexer                         v1.0.1
doctrine/orm                           v2.5.6
escapestudios/symfony2-coding-standard 2.11.0
friendsofsymfony/jsrouting-bundle      dev-master 31462ad
friendsofsymfony/user-bundle           2.0.0-beta2
h4cc/wkhtmltopdf-amd64                 0.11.0-RC1
incenteev/composer-parameter-handler   v2.1.2
ircmaxell/password-compat              v1.0.4
jdorn/sql-formatter                    v1.2.17
knplabs/knp-snappy                     v0.5.0
knplabs/knp-snappy-bundle              dev-master 40b780f
kriswallsmith/assetic                  v1.4.0
liuggio/ExcelBundle                    dev-master a028c00
monolog/monolog                        1.23.0
paragonie/random_compat                v2.0.10
phpoffice/phpexcel                     1.8.1
psr/log                                1.0.2
sensio/distribution-bundle             v5.0.20
sensio/framework-extra-bundle          v3.0.26
sensio/generator-bundle                v3.1.6
sensiolabs/security-checker            v4.0.4
squizlabs/php_codesniffer              2.9.1
swiftmailer/swiftmailer                v5.4.8
symfony/assetic-bundle                 v2.8.2
symfony/inflector                      v3.3.5
symfony/monolog-bundle                 v3.1.0
symfony/polyfill-apcu                  v1.4.0
symfony/polyfill-intl-icu              v1.4.0
symfony/polyfill-mbstring              v1.4.0
symfony/polyfill-php54                 v1.4.0
symfony/polyfill-php55                 v1.4.0
symfony/polyfill-php56                 v1.4.0
symfony/polyfill-php70                 v1.4.0
symfony/polyfill-util                  v1.4.0
symfony/property-access                v3.3.5
symfony/security-acl                   v3.0.0
symfony/swiftmailer-bundle             v2.6.2
symfony/symfony                        v2.8.25
twig/twig                              v2.4.3
willdurand/jsonp-callback-validator    v1.1.0

编辑 :

刚刚重现了这个问题,打开内网的时候看到的,不知道是打开之前崩溃了还是打开的时候崩溃了。在 Symfony 的 prod.log 中没有日志,但是在 wamp 的 php_error.log 中,有两个错误:

[31-Jul-2017 15:22:30 Europe/Paris] PHP Warning: session_regenerate_id(): Session object destruction failed. ID: user (path: C:\wamp\www\symfony\app/sessions) in C:\wamp\www\symfony\app\cache\prod\classes.php on line 156

[31-Jul-2017 15:22:30 Europe/Paris] PHP Stack trace:

[31-Jul-2017 15:22:30 Europe/Paris] PHP 1. {main}() C:\wamp\www\symfony\web\app.php:0

[31-Jul-2017 15:22:30 Europe/Paris] PHP 2. Symfony\Component\HttpKernel\Kernel->handle() C:\wamp\www\symfony\web\app.php:16

[31-Jul-2017 15:22:30 Europe/Paris] PHP 3. Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle() C:\wamp\www\symfony\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php:185

[31-Jul-2017 15:22:30 Europe/Paris] PHP 4. Symfony\Component\HttpKernel\HttpKernel->handle() C:\wamp\www\symfony\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel.php:69

[31-Jul-2017 15:22:30 Europe/Paris] PHP 5. Symfony\Component\HttpKernel\HttpKernel->handleRaw() C:\wamp\www\symfony\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php:64

[31-Jul-2017 15:22:30 Europe/Paris] PHP 6. Symfony\Component\EventDispatcher\EventDispatcher->dispatch() C:\wamp\www\symfony\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php:125

[31-Jul-2017 15:22:30 Europe/Paris] PHP 7. Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() C:\wamp\www\symfony\app\cache\prod\classes.php:1779

[31-Jul-2017 15:22:30 Europe/Paris] PHP 8. call_user_func:{C:\wamp\www\symfony\app\cache\prod\classes.php:1864}() C:\wamp\www\symfony\app\cache\prod\classes.php:1864

[31-Jul-2017 15:22:30 Europe/Paris] PHP 9. Symfony\Component\Security\Http\Firewall->onKernelRequest() C:\wamp\www\symfony\app\cache\prod\classes.php:1864

[31-Jul-2017 15:22:30 Europe/Paris] PHP 10. Symfony\Component\Security\Http\Firewall\LogoutListener->handle() C:\wamp\www\symfony\app\cache\prod\classes.php:2635

[31-Jul-2017 15:22:30 Europe/Paris] PHP 11. Symfony\Component\Security\Http\Logout\SessionLogoutHandler->logout() C:\wamp\www\symfony\vendor\symfony\symfony\src\Symfony\Component\Security\Http\Firewall\LogoutListener.php:127

[31-Jul-2017 15:22:30 Europe/Paris] PHP 12. Symfony\Component\HttpFoundation\Session\Session->invalidate() C:\wamp\www\symfony\vendor\symfony\symfony\src\Symfony\Component\Security\Http\Logout\SessionLogoutHandler.php:34

[31-Jul-2017 15:22:30 Europe/Paris] PHP 13. Symfony\Component\HttpFoundation\Session\Session->migrate() C:\wamp\www\symfony\app\cache\prod\classes.php:529

[31-Jul-2017 15:22:30 Europe/Paris] PHP 14. Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->regenerate() C:\wamp\www\symfony\app\cache\prod\classes.php:533

[31-Jul-2017 15:22:30 Europe/Paris] PHP 15. session_regenerate_id() C:\wamp\www\symfony\app\cache\prod\classes.php:156

[31-Jul-2017 15:30:50 Europe/Paris] PHP Fatal error: Class Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy contains 3 abstract methods and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::open, SessionHandlerInterface::close, SessionHandlerInterface::write) in C:\wamp\www\symfony\app\cache\prod\classes.php on line 393

[31-Jul-2017 15:30:50 Europe/Paris] PHP Stack trace:

[31-Jul-2017 15:30:50 Europe/Paris] PHP 1. {main}() C:\wamp\www\symfony\web\app.php:0

[31-Jul-2017 15:30:50 Europe/Paris] PHP 2. Symfony\Component\HttpKernel\Kernel->handle() C:\wamp\www\symfony\web\app.php:16

[31-Jul-2017 15:30:50 Europe/Paris] PHP 3. Symfony\Component\HttpKernel\Kernel->boot() C:\wamp\www\symfony\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php:182

[31-Jul-2017 15:30:50 Europe/Paris] PHP 4. Symfony\Component\HttpKernel\Kernel->doLoadClassCache() C:\wamp\www\symfony\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php:126

[31-Jul-2017 15:30:50 Europe/Paris] PHP 5. Symfony\Component\ClassLoader\ClassCollectionLoader::load() C:\wamp\www\symfony\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php:411

[31-Jul-2017 15:30:50 Europe/Paris] PHP 6. require_once() C:\wamp\www\symfony\vendor\symfony\symfony\src\Symfony\Component\ClassLoader\ClassCollectionLoader.php:96

编辑 2 :

Arf,再次出现 2 个循环引用:

[2017-08-01 15:41:00] request.CRITICAL: Exception thrown when handling an exception (Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "session", path: "session -> session.storage.native -> twig.controller.exception -> twig -> security.csrf.token_manager". at C:\wamp\www\symfony\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Container.php line 281) {"exception":"[object] (Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException(code: 0): Circular reference detected for service \"session\", path: \"session -> session.storage.native -> twig.controller.exception -> twig -> security.csrf.token_manager\". at C:\wamp\www\symfony\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Container.php:281)"} []

[2017-08-01 15:43:04] request.CRITICAL: Exception thrown when handling an exception (Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "fos_user.user_provider.username", path: "security.firewall.map.context.main -> security.authentication.rememberme.services.simplehash.main -> fos_user.user_provider.username -> fos_user.user_manager -> twig.controller.exception -> twig -> security.authorization_checker -> security.authentication.manager". at C:\wamp\www\symfony\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Container.php line 281) {"exception":"[object] (Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException(code: 0): Circular reference detected for service \"fos_user.user_provider.username\", path: \"security.firewall.map.context.main -> security.authentication.rememberme.services.simplehash.main -> fos_user.user_provider.username -> fos_user.user_manager -> twig.controller.exception -> twig -> security.authorization_checker -> security.authentication.manager\". at C:\wamp\www\symfony\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Container.php:281)"} []

我们在使用 codeignaiter 时遇到了同样的问题,PHP 7.1.X 我认为该错误与 opcache (here!) 扩展错误有关。

重启apache后错误没有出现。

我升级到php7.2,问题没有再出现了。

注:抱歉我的英语水平,希望对你有所帮助