Skip to content

Commit 4197ff8

Browse files
committed
feat(backup): handle site disabled state in backup process
1 parent 877a78c commit 4197ff8

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

src/helper/Site_Backup_Restore.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,17 @@ public function __construct() {
5050

5151
public function backup( $args, $assoc_args = [] ) {
5252
delem_log( 'site backup start' );
53-
$args = auto_site_name( $args, 'site', __FUNCTION__ );
54-
$this->site_data = get_site_info( $args, true, true, true );
55-
$list_backups = \EE\Utils\get_flag_value( $assoc_args, 'list' );
53+
$args = auto_site_name( $args, 'site', __FUNCTION__ );
54+
$list_backups = \EE\Utils\get_flag_value( $assoc_args, 'list' );
55+
$dash_auth = \EE\Utils\get_flag_value( $assoc_args, 'dash-auth' );
56+
57+
// For dash-auth commands, we need to handle site disabled state specially
58+
// to send API callback instead of just exiting with error
59+
if ( $dash_auth ) {
60+
$this->site_data = get_site_info( $args, false, true, true );
61+
} else {
62+
$this->site_data = get_site_info( $args, true, true, true );
63+
}
5664

5765
// Handle --list flag to display available backups
5866
if ( $list_backups ) {
@@ -62,8 +70,6 @@ public function backup( $args, $assoc_args = [] ) {
6270
}
6371

6472
// Handle --dash-auth flag for EasyDash integration
65-
$dash_auth = \EE\Utils\get_flag_value( $assoc_args, 'dash-auth' );
66-
6773
if ( $dash_auth ) {
6874
// Debug: Log the raw dash_auth value received
6975
EE::debug( 'Received --dash-auth value: ' . $dash_auth );
@@ -98,6 +104,16 @@ public function backup( $args, $assoc_args = [] ) {
98104

99105
// Register shutdown handler to send failure callback if backup doesn't complete
100106
register_shutdown_function( [ $this, 'dash_shutdown_handler' ] );
107+
108+
// Check if site is disabled - send API callback with error
109+
if ( empty( $this->site_data['site_enabled'] ) ) {
110+
$this->capture_error(
111+
sprintf( 'Site %s is disabled. Enable it with `ee site enable %s` to create backup.', $this->site_data['site_url'], $this->site_data['site_url'] ),
112+
self::ERROR_TYPE_VALIDATION,
113+
1003
114+
);
115+
EE::error( sprintf( 'Site %s is disabled. Enable it with `ee site enable %s` to create backup.', $this->site_data['site_url'], $this->site_data['site_url'] ) );
116+
}
101117
}
102118

103119
// Acquire global lock to serialize backups (prevents OOM from concurrent backups)

0 commit comments

Comments
 (0)