Skip to content

Commit

Permalink
#25669: health_check.php fails if any database cache engine configured
Browse files Browse the repository at this point in the history
- fixed wrong "@return description" of the remove method in class
  Magento\Framework\Cache\Backend\Database
- fixed wrong returned type of the method "unlock" in class
  Magento\Framework\Lock\Backend\Cache
- fixed health_check to create instances into block "check cache storage
  availability"
  • Loading branch information
andrewbess authored and Andrii Beziazychnyi committed Nov 24, 2019
1 parent 121fadd commit 5c121e2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Cache/Backend/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function save($data, $id, $tags = [], $specificLifetime = false)
* Remove a cache record
*
* @param string $id Cache id
* @return boolean True if no problem
* @return int|boolean Number of affected rows or false on failure
*/
public function remove($id)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Lock/Backend/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function lock(string $name, int $timeout = -1): bool
*/
public function unlock(string $name): bool
{
return $this->cache->remove($this->getIdentifier($name));
return (bool)$this->cache->remove($this->getIdentifier($name));
}

/**
Expand Down
4 changes: 3 additions & 1 deletion pub/health_check.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@
}
$cacheBackendClass = $cacheConfig[ConfigOptionsListConstants::CONFIG_PATH_BACKEND];
try {
/** @var \Magento\Framework\App\Cache\Frontend\Factory $cacheFrontendFactory */
$cacheFrontendFactory = $objectManager->get(Magento\Framework\App\Cache\Frontend\Factory::class);
/** @var \Zend_Cache_Backend_Interface $backend */
$backend = new $cacheBackendClass($cacheConfig[ConfigOptionsListConstants::CONFIG_PATH_BACKEND_OPTIONS]);
$backend = $cacheFrontendFactory->create($cacheConfig);
$backend->test('test_cache_id');
} catch (\Exception $e) {
http_response_code(500);
Expand Down

0 comments on commit 5c121e2

Please sign in to comment.