The track_error INI directive is deprecated and slated to be removed. It's used in 4 places in dmemcache.inc and seems to be a core part of how the Memcache module handles errors from memcache itself.
Memcached has proper error handling, but Memcache does not. This module is going need a new way to handle errors from the daemon.
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | memcache-2981613.patch | 3.78 KB | bburg |
| #15 | 2981613.patch | 2.71 KB | jeremy |
| #12 | memcache-PHPCompatibility-2981613_fixed.png | 64.22 KB | rajatc |
| #9 | memcache_php_errormsg_deprecated_for_version_6.patch | 2.03 KB | darrell_ulm |
| #8 | php_errormsg_deprecated-2981613-8.patch | 2.03 KB | darrell_ulm |
Comments
Comment #2
bkosborneFrom what I can tell, the PECL "memcache" extension does not work with PHP 7 anyway. It's last release was 2013. The PECL "memcached" extension DOES work with PHP 7.
So, I'm not sure this is a big problem, because I think it's safe to assume if someone is on PHP 7, they are using memcached extension, and that code path that uses "track_errors" won't run.
Comment #3
MPetrovic commentedThe code path is traversed regardless of which extension is used.
Comment #4
bkosborneYou're right, I missed that area of the code. There's a separate area that's only run with Memcache extension.
Comment #5
hitchshockVariable $php_errormsg is deprecated in PHP 7.2, so I changed it to function error_get_last()
Comment #6
rbargerhuff commentedA little more information regarding the above comment which can be applied to the submitted patch:
HitchShock, wouldn't you want to add after line 285, the following to keep the code consistent with the original:
error_clear_last();Thank you HitchShock for your contribution.
Comment #7
darrell_ulm commentedFor patch #5 output returned:
% patch -p1 < php_errormsg_deprecated-2981613-1.patchpatching file dmemcache.incHunk #2 succeeded at 394 (offset -1 lines).
Memcache seems to still be functional. I was not using dev, just a recent version of the module as a quick test.The patch applies to the current dev version, I was testing against the current release.
Comment #8
darrell_ulm commentedIn reference to #6.
Re rolled patch from #5 to include:
error_clear_last();
after line 285.
Comment #9
darrell_ulm commentedPatch from #8 re-diffed for Memcache-7.x-1.6,
As always, test before you deploy.
Comment #10
hitchshockHeh, I need to look more often at the comments on my patches :)
Comment #11
darrell_ulm commentedFor me the error_clear_last() function does not seem to be backward compatible for a PHP 5.3 test machine I've been testing. Wonder if that is just a php.ini directive needed to make that work for the patch.
We may want to hold off on this patch more for users running PHP 5 since it could cause issues until we track it down. Seemed to work for me for PHP 7.1 and PHP 7.2 however.
Comment #12
rajatc commentedPatch #9 working for me.Please see the screenshot for the same.
https://www.drupal.org/files/issues/2020-05-14/memcache-PHPCompatibility...
Comment #13
rajatc commentedComment #14
jeremy commentedThe README also needs to be updated, as this change would require the minimum PHP version to be 5.2 (currently we suggest 5.1 is supported).
This is of course fine, as Drupal 7 core already requires a newer version of PHP (https://www.drupal.org/docs/7/system-requirements/php-requirements).
Comment #15
jeremy commentedUpdated patch attached, with changes:
- make naming consistent
- expose additional debug info on errors
- update README to reflect increased minimum PHP requirement
Comment #17
jeremy commentedComment #19
jeremy commentedPatch reverted, it caused an unintentional regression for anyone running pre-PHP7 https://git.drupalcode.org/project/memcache/-/commit/3b22772d4c3d8702c18...
See https://www.drupal.org/project/memcache/issues/3159775
Comment #20
hitchshockHey, Jeremy. I see no point in abandoning the patch in favor of an old unsupported version of PHP, at the expense of a new one. This discourages customers who have a PHP 7+ version. And customers with PHP < v7 should still think about upgrading, it would be an additional incentive for them.
See https://www.php.net/supported-versions.php
https://www.php.net/manual/en/function.error-clear-last.php
Comment #21
jeremy commentedThe patch needs to be reworked so it doesn't break older versions of PHP. As we already do in other areas of the code, we'll need to run different code depending on which version of PHP is installed.
The intent is not to make this either-or, but instead to support both.
Comment #22
bburgReworked patch. Also added annotations to make phpcs not complain.
Comment #23
bzaher commentedPatch #22 looks good. Tested using PHP 7.4, memcache 7.x-1.8. The warnings are gone from the phpcs report.
Comment #24
hitchshock+1 RTBC - PHP7.4
Comment #25
japerryClosing as Drupal 7 is no longer supported.