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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

valderama’s picture

Status: Active » Needs review
FileSize
583 bytes

Here is the patch. Please review.

Thanks,
walter

helmo’s picture

I saw the same notices while updating a memcache installation...
Your patch seems sound, although I haven't been able to reproduce the problem.

mgifford’s picture

FileSize
981 bytes

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

nerdcore’s picture

Proper 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?

mgifford’s picture

markpavlitski’s picture

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

sd46’s picture

Status: Needs review » Reviewed & tested by the community

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

Jeremy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, 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.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

clarification