Aleksander Machniak
2015-05-13 244a46fdea371cead1dec4bcdaf0da72de960941
Fix missing index update after write() call
2 files modified
50 ■■■■ changed files
program/lib/Roundcube/rcube_cache.php 25 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_cache_shared.php 25 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_cache.php
@@ -164,7 +164,7 @@
        // Remove all keys
        if ($key === null) {
            $this->cache         = array();
            $this->cache_changed = false;
            $this->cache_changed = true;
            $this->cache_changes = array();
            $this->cache_sums    = array();
        }
@@ -344,7 +344,15 @@
        }
        if ($this->type == 'memcache' || $this->type == 'apc') {
            return $this->add_record($this->ckey($key), $data);
            $result = $this->add_record($this->ckey($key), $data);
            // make sure index will be updated
            if ($result && !array_key_exists($key, $this->cache_sums)) {
                $this->cache_changed    = true;
                $this->cache_sums[$key] = true;
            }
            return $result;
        }
        $key_exists = array_key_exists($key, $this->cache_sums);
@@ -507,10 +515,15 @@
        // Make sure index contains new keys
        foreach ($this->cache as $key => $value) {
            if ($value !== null) {
                if (array_search($key, $this->index) === false) {
                    $this->index[] = $key;
                }
            if ($value !== null && !in_array($key, $this->index)) {
                $this->index[] = $key;
            }
        }
        // new keys added using self::write()
        foreach ($this->cache_sums as $key => $value) {
            if ($value === true && !in_array($key, $this->index)) {
                $this->index[] = $key;
            }
        }
program/lib/Roundcube/rcube_cache_shared.php
@@ -161,7 +161,7 @@
        // Remove all keys
        if ($key === null) {
            $this->cache         = array();
            $this->cache_changed = false;
            $this->cache_changed = true;
            $this->cache_changes = array();
            $this->cache_sums    = array();
        }
@@ -338,7 +338,15 @@
        }
        if ($this->type == 'memcache' || $this->type == 'apc') {
            return $this->add_record($this->ckey($key), $data);
            $result = $this->add_record($this->ckey($key), $data);
            // make sure index will be updated
            if ($result && !array_key_exists($key, $this->cache_sums)) {
                $this->cache_changed    = true;
                $this->cache_sums[$key] = true;
            }
            return $result;
        }
        $key_exists = array_key_exists($key, $this->cache_sums);
@@ -496,10 +504,15 @@
        // Make sure index contains new keys
        foreach ($this->cache as $key => $value) {
            if ($value !== null) {
                if (array_search($key, $this->index) === false) {
                    $this->index[] = $key;
                }
            if ($value !== null && !in_array($key, $this->index)) {
                $this->index[] = $key;
            }
        }
        // new keys added using self::write()
        foreach ($this->cache_sums as $key => $value) {
            if ($value === true && !in_array($key, $this->index)) {
                $this->index[] = $key;
            }
        }