summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbkosborne2018-08-27 13:22:47 (GMT)
committerJeremy Andrews2018-08-27 13:22:47 (GMT)
commitfbdbd705093d5257233203a18dc4ebdbd8771e65 (patch)
tree053eb00f34326c35810c3190120bb63edb80b668
parentd613243480b7a44fb8a1e90fad7fe285e9e7f303 (diff)
Issue #2864659 by bkosborne, Jeremy, Fabianx: Notice: Trying to get property of non-object in _dmemcache_get_pieces()7.x-1.7-beta1
-rw-r--r--dmemcache.inc19
1 files changed, 11 insertions, 8 deletions
diff --git a/dmemcache.inc b/dmemcache.inc
index cb587f3..8dc10cb 100644
--- a/dmemcache.inc
+++ b/dmemcache.inc
@@ -317,16 +317,16 @@ function _dmemcache_get_pieces($item, $key, $bin = 'cache', $mc = NULL) {
$keys[] = _dmemcache_key_piece($key, $id);
}
- // Retrieve all the pieces of data.
+ // Retrieve all the pieces of data and append them together.
$pieces = dmemcache_get_multi($keys, $bin, $mc);
- if (count($pieces) != $item->piece_count) {
- // Some of the pieces don't exist, so our data cannot be reconstructed.
- return FALSE;
- }
-
- // Append all of the pieces together.
$data = '';
foreach ($pieces as $piece) {
+ // The piece may be NULL if it didn't exist in memcache. If so,
+ // we have to just return false for the entire set because we won't
+ // be able to reconstruct the original data without all the pieces.
+ if (!$piece) {
+ return FALSE;
+ }
$data .= $piece->data;
}
unset($pieces);
@@ -364,7 +364,8 @@ function _dmemcache_key_piece($key, $id) {
* The bin in which the item was stored.
*
* @return mixed
- * The item which was originally saved or FALSE
+ * An array keyed by $keys with the items requested or
+ * NULL values if the data was not present.
*/
function dmemcache_get_multi($keys, $bin = 'cache', $mc = NULL) {
$collect_stats = dmemcache_stats_init();
@@ -416,6 +417,8 @@ function dmemcache_get_multi($keys, $bin = 'cache', $mc = NULL) {
// If $results is FALSE, convert it to an empty array.
if (!$results) {
$results = array();
+ $keys = array_fill_keys($full_keys, NULL);
+ $results = array_merge($keys, $results);
_dmemcache_write_debug('getMulti', $bin, implode(',', $full_keys), FALSE);
}