Problem/Motivation

I got this PHP warning running the latest memcache-dev on Drupal 8.5.0-beta1, PHP 7.2:

Deprecated: assert(): Calling assert() with a string argument is deprecated in /var/www/html/modules/memcache/src/MemcacheBackend.php on line 188
...

Which causes the fatal error:

The website encountered an unexpected error. Please try again later.
RuntimeException: Failed to start the session because headers have already been sent by "/var/www/html/modules/memcache/src/MemcacheBackend.php" at line 188. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (line 141 of vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php). 
...

Steps to reproduce

Make sure Zend assertions are turned on (should only happen in non-prod environments). E.g. below with PHP 7.2-FPM zend.assertions turned on.

$ php -i /etc/php/7.2/fpm/php.ini | grep zend.assertions
zend.assertions => 1 => 1

To enable zend.assertions, make sure to have the value set to 1 in php.ini as below:

$ grep "^zend.assertions" /etc/php/7.2/fpm/php.ini
zend.assertions = 1

Proposed resolution

Update the assert function call in MemcacheBackend.php (line 188) to the PHP 7.2 standards with backward support down to PHP 5.6

Remaining tasks

Patch & review

Comments

manuel.adan created an issue. See original summary.

manuel.adan’s picture

Assigned: manuel.adan » Unassigned
Status: Active » Needs review
StatusFileSize
new642 bytes
ProFire’s picture

Priority: Critical » Normal
Status: Needs review » Reviewed & tested by the community

I've reviewed on Windows 7, PHP 7.2.5.
The deprecated warning no longer appears for me. I'm downgrading the priority to Normal as per guideline. This issue doesn't render the site unusable or pose any security issue. The assert function with string arguments will still remain usable until the next major PHP version.

martin107’s picture

I WAS getting the error. -- the patch fixes that.

patch looks clean

+1 from me.

anavarre’s picture

I cannot reproduce this issue either on PHP 7.2.5 (Debian) with 8.6.x. Could you please share steps to reliably reproduce?

it-cru’s picture

@anavarre : Please check you assertion settings in PHP status report on your environment. Perhaps it is set to 'production mode' and throws no warning/error messages? (see also docs for 'PHP 7 configuration directives for assert()' on http://php.net/manual/en/function.assert.php )

anavarre’s picture

#6 - Ah right of course, I thought I had it enabled in dev. Thanks, I could immediately reproduce and the patch does fix the issue.

anavarre’s picture

Issue summary: View changes

Clarified steps to reproduce.

renrhaf’s picture

Reviewed & tested on latest "php:7-fpm-alpine" Docker image.
Patch successfully fix the error message, thanks @manuel.adan.

abramm’s picture

+1 RTBC for PHP 7.2.
Works just as it should.

webchick’s picture

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x-2.x, thanks!

  • catch committed 9fdec32 on 8.x-2.x authored by manuel.adan
    Issue #2944396 by manuel.adan, anavarre, ProFire: [PHP 7.2] Deprecated...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.