From 6af9b8e85aaf155f9e5b87744823ac7555aa7309 Mon Sep 17 00:00:00 2001 From: Mark Hamstra Date: Mon, 10 Feb 2025 21:59:26 +0100 Subject: [PATCH] Make sure to check for proc_close as well before running a backup [S47321] --- .../sitedashclient/docs/changelog.txt | 2 ++ .../sitedashclient/src/Upgrade/Backup.php | 31 ++++++++----------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/core/components/sitedashclient/docs/changelog.txt b/core/components/sitedashclient/docs/changelog.txt index 103e598..4d0d561 100644 --- a/core/components/sitedashclient/docs/changelog.txt +++ b/core/components/sitedashclient/docs/changelog.txt @@ -1,3 +1,5 @@ +- Make sure to check for proc_close as well before running a backup [S47321] + SiteDash Client 1.7.1-pl ------------------------ Released on 2024-12-03 diff --git a/core/components/sitedashclient/src/Upgrade/Backup.php b/core/components/sitedashclient/src/Upgrade/Backup.php index d1f5208..1917118 100644 --- a/core/components/sitedashclient/src/Upgrade/Backup.php +++ b/core/components/sitedashclient/src/Upgrade/Backup.php @@ -37,23 +37,18 @@ public function __construct(\modX $modx) public function run() { - if (!function_exists('proc_open')) { - http_response_code(503); - echo json_encode([ - 'success' => false, - 'message' => 'The proc_open() function is disabled on your server. This is required for the backup to run.', - 'directory' => str_replace(MODX_CORE_PATH, '{core_path}', $this->targetDirectory) - ], JSON_PRETTY_PRINT); - return; - } - if (!function_exists('proc_get_status')) { - http_response_code(503); - echo json_encode([ - 'success' => false, - 'message' => 'The proc_get_status() function is disabled on your server. This is required to allow the status of the backup to be checked.', - 'directory' => str_replace(MODX_CORE_PATH, '{core_path}', $this->targetDirectory) - ], JSON_PRETTY_PRINT); - return; + $functions = ['proc_open', 'proc_get_status', 'proc_close']; + foreach ($functions as $function) { + if (!function_exists($function)) { + http_response_code(503); + echo json_encode([ + 'success' => false, + 'message' => "The {$function}() function is disabled on your server. This is required for the backup to run.", + 'directory' => str_replace(MODX_CORE_PATH, '{core_path}', $this->targetDirectory) + ], JSON_PRETTY_PRINT); + + return; + } } if (!$this->createDirectory($this->targetDirectory)) { @@ -196,4 +191,4 @@ private function createDirectory($target) } return true; } -} \ No newline at end of file +}