From f420587a13d5b72500a3df725036ea0570f53d81 Mon Sep 17 00:00:00 2001 From: Thorsten Reiter Date: Tue, 10 Dec 2024 17:24:13 +0100 Subject: [PATCH] fix-cs --- src/bundle/Core/Command/ReindexCommand.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bundle/Core/Command/ReindexCommand.php b/src/bundle/Core/Command/ReindexCommand.php index 57822a8924..971f319f29 100644 --- a/src/bundle/Core/Command/ReindexCommand.php +++ b/src/bundle/Core/Command/ReindexCommand.php @@ -450,12 +450,16 @@ private function getPhpPath() private function getNumberOfCPUCores() { $cores = 1; - if (isset($_SERVER['PLATFORM_BRANCH']) && is_file( '/run/config.json')) { + if (isset($_SERVER['PLATFORM_BRANCH']) && is_file('/run/config.json')) { // Ibexa Cloud: read #cpus from config $config_json_encoded = file_get_contents('/run/config.json'); + if ($config_json_encoded == false) { + return 1; + } $config_json = json_decode($config_json_encoded); $cores = isset($config_json->info->limits->cpu) ? max(1, floor($config_json->info->limits->cpu)) : 1; - return $cores; + + return (int)$cores; } elseif (is_file('/proc/cpuinfo')) { // Linux (and potentially Windows with linux sub systems) $cpuinfo = file_get_contents('/proc/cpuinfo');