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
Comment #2
manuel.adanComment #3
ProFire commentedI'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.
Comment #4
martin107 commentedI WAS getting the error. -- the patch fixes that.
patch looks clean
+1 from me.
Comment #5
anavarreI cannot reproduce this issue either on PHP 7.2.5 (Debian) with 8.6.x. Could you please share steps to reliably reproduce?
Comment #6
it-cru@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 )
Comment #7
anavarre#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.
Comment #8
anavarreClarified steps to reproduce.
Comment #9
renrhafReviewed & tested on latest "php:7-fpm-alpine" Docker image.
Patch successfully fix the error message, thanks @manuel.adan.
Comment #10
abramm+1 RTBC for PHP 7.2.
Works just as it should.
Comment #11
webchickTagging as a D8 stable release blocker, per #2989594: [META] Create a stable release of Memcache module for Drupal 8
Comment #12
catchCommitted/pushed to 8.x-2.x, thanks!