Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed return value in MemCache::setValues() #13362

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions framework/caching/MemCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ protected function setValue($key, $value, $duration)
* Stores multiple key-value pairs in cache.
* @param array $data array where key corresponds to cache key while value is the value stored
* @param int $duration the number of seconds in which the cached values will expire. 0 means never expire.
* @return array array of failed keys. Always empty in case of using memcached.
* @return array array of failed keys.
*/
protected function setValues($data, $duration)
{
Expand All @@ -313,9 +313,10 @@ protected function setValues($data, $duration)
// @see http://php.net/manual/en/memcache.set.php
// @see http://php.net/manual/en/memcached.expiration.php
$expire = $duration > 0 ? $duration + time() : 0;
$this->_cache->setMulti($data, $expire);

return [];
// Memcached::setMulti() returns boolean
// @see http://php.net/manual/ru/memcached.setmulti.php
return $this->_cache->setMulti($data, $expire) ? [] : array_keys($data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be explicitly checked with === true

Copy link
Contributor Author

@masterklavi masterklavi Jan 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't necessarily because of Memcached::setMulti() always returns boolean or null (when arguments are missed). See https://github.com/php-memcached-dev/php-memcached/blob/master/php_memcached.c#L1840 .

} else {
return parent::setValues($data, $duration);
}
Expand Down