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.

Comments

MPetrovic created an issue. See original summary.

bkosborne’s picture

From 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.

MPetrovic’s picture

The code path is traversed regardless of which extension is used.

bkosborne’s picture

You're right, I missed that area of the code. There's a separate area that's only run with Memcache extension.

hitchshock’s picture

Status: Active » Needs review
StatusFileSize
new2 KB

Variable $php_errormsg is deprecated in PHP 7.2, so I changed it to function error_get_last()

rbargerhuff’s picture

A little more information regarding the above comment which can be applied to the submitted patch:

When the track_errors ini setting is enabled, a $php_errormsg variable is created in the local scope when a non-fatal error occurs. Given that the preferred way of retrieving such error information is by using error_get_last(), this feature has been deprecated.

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.

darrell_ulm’s picture

For patch #5 output returned:

% patch -p1 < php_errormsg_deprecated-2981613-1.patch

patching file dmemcache.inc
Hunk #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.

darrell_ulm’s picture

StatusFileSize
new2.03 KB

In reference to #6.

Re rolled patch from #5 to include:
error_clear_last();
after line 285.

darrell_ulm’s picture

Patch from #8 re-diffed for Memcache-7.x-1.6,
As always, test before you deploy.

hitchshock’s picture

Heh, I need to look more often at the comments on my patches :)

darrell_ulm’s picture

For 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.

rajatc’s picture

Issue tags: +PHP
StatusFileSize
new64.22 KB

Patch #9 working for me.Please see the screenshot for the same.
https://www.drupal.org/files/issues/2020-05-14/memcache-PHPCompatibility...

rajatc’s picture

Status: Needs review » Reviewed & tested by the community
jeremy’s picture

The 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).

jeremy’s picture

StatusFileSize
new2.71 KB

Updated patch attached, with changes:

- make naming consistent
- expose additional debug info on errors
- update README to reflect increased minimum PHP requirement

  • Jeremy committed 0f5e34f on 7.x-1.x
    Issue #2981613 by darrellulm, HitchShock, Jeremy, Rajat Charde:...
jeremy’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

jeremy’s picture

Status: Closed (fixed) » Needs work

Patch 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

hitchshock’s picture

Status: Needs work » Needs review

Hey, 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

jeremy’s picture

Status: Needs review » Needs work

The 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.

bburg’s picture

Status: Needs work » Needs review
StatusFileSize
new3.78 KB

Reworked patch. Also added annotations to make phpcs not complain.

bzaher’s picture

Patch #22 looks good. Tested using PHP 7.4, memcache 7.x-1.8. The warnings are gone from the phpcs report.

hitchshock’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -

+1 RTBC - PHP7.4

japerry’s picture

Status: Reviewed & tested by the community » Closed (outdated)

Closing as Drupal 7 is no longer supported.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.