Skip to content

Commit

Permalink
Make sure to check for proc_close as well before running a backup [S4…
Browse files Browse the repository at this point in the history
…7321]
  • Loading branch information
Mark-H committed Feb 10, 2025
1 parent 4a5fe0d commit 6af9b8e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
2 changes: 2 additions & 0 deletions core/components/sitedashclient/docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
31 changes: 13 additions & 18 deletions core/components/sitedashclient/src/Upgrade/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -196,4 +191,4 @@ private function createDirectory($target)
}
return true;
}
}
}

0 comments on commit 6af9b8e

Please sign in to comment.