Skip to content

Commit 5c121e2

Browse files
andrewbessAndrii Beziazychnyi
authored andcommitted
#25669: health_check.php fails if any database cache engine configured
- 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"
1 parent 121fadd commit 5c121e2

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

lib/internal/Magento/Framework/Cache/Backend/Database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public function save($data, $id, $tags = [], $specificLifetime = false)
240240
* Remove a cache record
241241
*
242242
* @param string $id Cache id
243-
* @return boolean True if no problem
243+
* @return int|boolean Number of affected rows or false on failure
244244
*/
245245
public function remove($id)
246246
{

lib/internal/Magento/Framework/Lock/Backend/Cache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function lock(string $name, int $timeout = -1): bool
4545
*/
4646
public function unlock(string $name): bool
4747
{
48-
return $this->cache->remove($this->getIdentifier($name));
48+
return (bool)$this->cache->remove($this->getIdentifier($name));
4949
}
5050

5151
/**

pub/health_check.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@
6363
}
6464
$cacheBackendClass = $cacheConfig[ConfigOptionsListConstants::CONFIG_PATH_BACKEND];
6565
try {
66+
/** @var \Magento\Framework\App\Cache\Frontend\Factory $cacheFrontendFactory */
67+
$cacheFrontendFactory = $objectManager->get(Magento\Framework\App\Cache\Frontend\Factory::class);
6668
/** @var \Zend_Cache_Backend_Interface $backend */
67-
$backend = new $cacheBackendClass($cacheConfig[ConfigOptionsListConstants::CONFIG_PATH_BACKEND_OPTIONS]);
69+
$backend = $cacheFrontendFactory->create($cacheConfig);
6870
$backend->test('test_cache_id');
6971
} catch (\Exception $e) {
7072
http_response_code(500);

0 commit comments

Comments
 (0)