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

Errors with deserialization for the profiling of blocks in debug mode with PHP 7.3 #556

Closed
jerome-fix opened this issue Feb 16, 2019 · 9 comments

Comments

@jerome-fix
Copy link

Environment

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.45.2 3.45.2 The missing Symfony Admin Generator
sonata-project/block-bundle              3.14.0 3.14.0 Symfony SonataBlockBundle
sonata-project/cache                     2.0.1  2.0.1  Cache library
sonata-project/classification-bundle     3.8.0  3.8.0  Symfony SonataClassificationBundle
sonata-project/core-bundle               3.16.0 3.16.0 Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.4.0  2.4.0  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.1.5  1.1.5  Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.8.2  3.8.2  Symfony Sonata / Integrate Doctrine ORM into the Sona...
sonata-project/easy-extends-bundle       2.5.0  2.5.0  Symfony SonataEasyExtendsBundle
sonata-project/exporter                  2.0.1  2.0.1  Lightweight Exporter library
sonata-project/media-bundle              3.18.1 3.18.1 Symfony SonataMediaBundle
sonata-project/notification-bundle       3.5.1  3.5.1  Symfony SonataNotificationBundle

Symfony packages

$ composer show --latest 'symfony/*'
symfony/monolog-bundle     v3.3.1             v3.3.1             Symfony MonologBundle
symfony/phpunit-bridge     v3.4.22            v4.2.3             Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.10.0            v1.10.0            Symfony polyfill backporting apcu_* functio...
symfony/polyfill-ctype     v1.10.0            v1.10.0            Symfony polyfill for ctype functions
symfony/polyfill-intl-icu  v1.10.0            v1.10.0            Symfony polyfill for intl's ICU-related dat...
symfony/polyfill-mbstring  v1.10.0            v1.10.0            Symfony polyfill for the Mbstring extension
symfony/polyfill-php56     v1.10.0            v1.10.0            Symfony polyfill backporting some PHP 5.6+ ...
symfony/polyfill-php70     v1.10.0            v1.10.0            Symfony polyfill backporting some PHP 7.0+ ...
symfony/polyfill-util      v1.10.0            v1.10.0            Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.1             v3.0.1             Symfony Security Component - ACL (Access Co...
symfony/symfony            v3.4.22            v4.2.3             The Symfony PHP framework

PHP version

$ php -v
PHP 7.3.2-3+0~20190208150759.31+jessie~1.gbp0912bd (cli) (built: Feb  8 2019 23:17:46) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.2, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.2-3+0~20190208150759.31+jessie~1.gbp0912bd, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.7.0rc1, Copyright (c) 2002-2019, by Derick Rethans

Subject

An error occured when the profiler is retrieving data from blocks.

Steps to reproduce

Execute any page with a SonataBlock on development environment.

Expected results

Get information about Sonata blocks from the page in the profiler.

Actual results

[2019-02-16 17:08:17] [82414226] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Notice: unserialize(): Error at offset 7078 of 12086 bytes" at /var/www/cms/vendor/sonata-project/block-bundle/src/Profiler/DataCollector/BlockDataCollector.php line 167 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\ContextErrorException(code: 0): Notice: unserialize(): Error at offset 7078 of 12086 bytes at /var/www/cms/vendor/sonata-project/block-bundle/src/Profiler/DataCollector/BlockDataCollector.php:167)"}\

There is a bug in serialization with PHP 7.3 :
https://bugs.php.net/bug.php?id=77302

There are some workarounds and discussion about it :

For now I had to disable the profiler for the blocks.
https://sonata-project.org/bundles/block/master/doc/reference/profiler.html

Thanks,
Jérôme.

@jerome-fix jerome-fix changed the title rrors with deserialization for the profiling of blocks in debug mode with PHP 7.3 Errors with deserialization for the profiling of blocks in debug mode with PHP 7.3 Feb 16, 2019
@OskarStark
Copy link
Member

Shouldnt this be fixed by php?

@jerome-fix
Copy link
Author

Hi,

Not before 7.4 apparently. The bug already existed before, but without any message.

[2019-01-22 20:23 UTC] nikic@php.net

I plan to propose and implement a new custom object serialization mechanism for PHP 7.4, to replace the Serializable interface and all the problems that come with it.

For now, all I can suggest is to rewrite your code in a way that does not use parent::serialize(). I don't think there is anything we can do to fix Serializable itself, unfortunately.

[https://bugs.php.net/bug.php?id=77302]

@greg0ire
Copy link
Contributor

Would that kind of magical incantation fix it: symfony/symfony@3cfb558 ?

@muffe
Copy link

muffe commented Feb 20, 2019

Nope, error stays the same for me.

@toooni
Copy link
Contributor

toooni commented Mar 19, 2019

Just FYI. The bug will not be resolved by PHP. There will be a different approach on serialization https://wiki.php.net/rfc/custom_object_serialization.

@cbastienbaron
Copy link
Contributor

? maybe this issue need to stay open (for others users searching unserialize issues with blocks), this bug still exist see #652 and like said nikic ...

For now, all I can suggest is to rewrite your code in a way that does not use parent::serialize(). I don't think there is anything we can do to fix Serializable itself, unfortunately.

@greg0ire
Copy link
Contributor

I'm a bit confused… #562 was supposed to fix it, can you help @toooni ?

@toooni
Copy link
Contributor

toooni commented Dec 12, 2019

@cbastienbaron Which symfony version do you have?

@cbastienbaron
Copy link
Contributor

@toooni v3.4.35

composer info | grep symfony

friendsofsymfony/elastica-bundle     v5.1.1             Elasticsearch PHP integration for your Symfony project using Elastica
friendsofsymfony/http-cache          1.4.5              Tools to manage cache invalidation
friendsofsymfony/http-cache-bundle   1.3.16             Set path based HTTP cache headers and send invalidation requests to your HTTP cache
friendsofsymfony/jsrouting-bundle    1.6.3              A pretty nice way to expose your Symfony2 routing to client applications.
friendsofsymfony/user-bundle         v2.0.1             Symfony FOSUserBundle
symfony-cmf/routing                  2.1.0              Extends the Symfony routing component for dynamic routes and chaining several routers
symfony-cmf/routing-bundle           2.1.1              Symfony RoutingBundle
symfony/assetic-bundle               v2.8.2             Integrates Assetic into Symfony2
symfony/http-client                  v4.3.8             Symfony HttpClient component
symfony/http-client-contracts        v1.1.8             Generic abstractions related to HTTP clients
symfony/mime                         v4.3.8             A library to manipulate MIME messages
symfony/monolog-bundle               v3.4.0             Symfony MonologBundle
symfony/phpunit-bridge               v2.8.52            Symfony PHPUnit Bridge
symfony/polyfill-apcu                v1.12.0            Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-ctype               v1.12.0            Symfony polyfill for ctype functions
symfony/polyfill-intl-icu            v1.12.0            Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn            v1.12.0            Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-mbstring            v1.12.0            Symfony polyfill for the Mbstring extension
symfony/polyfill-php56               v1.12.0            Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70               v1.12.0            Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-php72               v1.12.0            Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73               v1.12.0            Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-util                v1.12.0            Symfony utilities for portability of PHP codes
symfony/swiftmailer-bundle           v2.6.7             Symfony SwiftmailerBundle
symfony/symfony                      v3.4.35            The Symfony PHP framework

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants