Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Using dev version I received tons of PHP notices like this:
Notice: Trying to get property of non-object in MemCacheDrupal->getMultiple() (line 30 of /sites/all/modules/memcache/memcache.inc).
Notice: Trying to get property of non-object in MemCacheDrupal->valid() (line 65 of /sites/all/modules/memcache/memcache.inc).
Sometimes there is no $result object, so I added a check before the result object is used.
Patch follows.
Comment | File | Size | Author |
---|---|---|---|
#6 | memcache-notices-1750476-6.patch | 952 bytes | markpavlitski |
#3 | notices-1750476-3.patch | 981 bytes | mgifford |
#1 | notices-1750476-2.patch | 583 bytes | valderama |
Comments
Comment #1
valderama CreditAttribution: valderama commentedHere is the patch. Please review.
Thanks,
walter
Comment #2
helmo CreditAttribution: helmo commentedI saw the same notices while updating a memcache installation...
Your patch seems sound, although I haven't been able to reproduce the problem.
Comment #3
mgiffordWe got these with 7.x-1.0. I don't think it would have been fixed in dev, as I found that the checks weren't being done in git.
We got these errors (when clearing cache). Could be that it should be set up with something else. However, just having a check for null values is a good practice.
The patch above only addressed the issue at line 30 not at line 65, so I updated this patch to take them both out.
Comment #4
nerdcore CreditAttribution: nerdcore commentedProper variable checking is always good practice, although I am concerned about why these notices cropped up after running memcache for a week (or more) without any notices. A major change I made to the site where I started getting these was enabling APC as an additional cache mechanism.
Should I be concerned about this, or were there always just some bad variable tests in place and this patch fixes the problem once and for all?
Comment #5
mgiffordRelated meta issue - #1830496: Better logging and handling of connect errors
Comment #6
markpavlitski CreditAttribution: markpavlitski commentedThe patch in #3 does not account for when $cache is a valid object but $cache->created does not exist.
The attached patch takes a slightly different approach.
Comment #7
sd46 CreditAttribution: sd46 commentedTested patch in comment #6, the patch prevents both notices from being generated.
I don't know how the notices were originally caused, but for testing purposes an easy way to recreate them is to change between
$conf['memcache_extension'] = 'Memcached';
and
$conf['memcache_extension'] = 'Memcache';
in the settings.php file, which will cause both notices to be generated on the next page load.
Comment #8
Jeremy CreditAttribution: Jeremy commentedThanks, committed #6 (the first notice was a typo which this fixes):
http://drupalcode.org/project/memcache.git/commit/812d5dc
Bug doesn't appear to affect 6.x-1.x; closing.
Comment #9.0
(not verified) CreditAttribution: commentedclarification