If memcached isn't running, the following message is generated:
Notice: Undefined variable: result in dmemcache_get() (line 114 of /var/www/sites/all/modules/contrib/memcache/dmemcache.inc).
This is because $result is defined within a test if ($mc || $mc = dmemcache_object($bin)) {, but returned outside the test without checking whether the test passed.
Moving $result to within the test suppresses the PHP notice, but doesn't alter the functionality (when the test condition fails, NULL will be returned in each case).
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | memcache-undefined-result-1307078-3.patch | 931 bytes | pillarsdotnet |
| #1 | memcache-remove_php_notice-1307078-1.patch | 496 bytes | manarth |
Comments
Comment #1
manarth commentedPatch attached.
Comment #2
manarth commentedComment #3
pillarsdotnet commentedThe function documentation says that it returns FALSE on error, which is different from NULL.
Attached patch solves the problem by initializing $result to FALSE.
Comment #4
das-peter commentedMay I ask you to give this patch a review: #1184678: Enhance failure tolerance
If you get this error notice, it's likely you're also happy about the changes this patch makes :)
@pillarsdotnet: Thanks for "connecting" the patches.
Comment #5
pillarsdotnet commentedPartial duplicate of #1184678: Enhance failure tolerance