Closed (fixed)
Project:
Custom Contextual Links
Version:
7.x-1.6
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
22 Aug 2019 at 12:25 UTC
Updated:
15 Oct 2019 at 19:35 UTC
Jump to comment: Most recent
Unchecked assumptions about cache/cache variables causes warning/notice mess.
Cache usage inside module's main code assumes in many points some variables as objects/array even though it happens frequently they're not.
Hence we have broken property access like in this code
$cache = cache_get($type);
// If nothing is set in the cache then recreate it.
if (!isset($cache->cid)) {
_ccl_update_cache();
$cache = cache_get($type);
}
return $cache->data; // often here $cache is just "false"
or incorrect use of array functions (foreach, array_keys) on non-array or straight-up non-set variables, like here:
if (in_array($node->type, array_keys($node_cache['ct']))) { // $node_cache['ct'] is often not set/not an array
foreach ($node_cache['ct'][$node->type] as $id => $link) {
if ($processed_link = _ccl_prepare_link($link, $dest, $node)) {
$element['#links']['ccl-ct-' . $id] = $processed_link;
}
}
}
Simple `isset` or `is_array` checks will remove the problem.
(small patch attached, but the fix is trivial).
| Comment | File | Size | Author |
|---|---|---|---|
| module.contrib.ccl_.remove.notices.warnings.patch | 1.85 KB | giuspe |
Comments
Comment #3
bkoether commentedThanks @giuspe,
I applied your patch and pushed it into the next release.
Ben
Comment #4
bkoether commented