File tree 3 files changed +13
-20
lines changed
3 files changed +13
-20
lines changed Original file line number Diff line number Diff line change 10
10
require_once $ wpcli_snapshot_autoloader ;
11
11
}
12
12
13
- $ wpcli_snapshot_verify_required_packages = function () {
14
- $ utils = new \WP_CLI \Snapshot \Utils ();
15
- $ utils ->available_wp_packages ();
16
- };
17
-
18
- WP_CLI ::add_command (
19
- 'snapshot ' ,
20
- '\WP_CLI\Snapshot\SnapshotCommand ' ,
21
- [
22
- 'before_invoke ' => $ wpcli_snapshot_verify_required_packages ,
23
- ]
24
- );
13
+ WP_CLI ::add_command ( 'snapshot ' , '\WP_CLI\Snapshot\SnapshotCommand ' );
Original file line number Diff line number Diff line change @@ -98,9 +98,10 @@ public function __construct() {
98
98
throw new \Exception ( 'Snapshot command requires ZipArchive. ' );
99
99
}
100
100
101
- $ this ->db = new SnapshotDB ();
102
- $ this ->storage = new SnapshotStorage ();
103
- $ this ->progress = Utils \make_progress_bar ( 'Creating Backup ' , 5 );
101
+ $ this ->db = new SnapshotDB ();
102
+ $ this ->storage = new SnapshotStorage ();
103
+ $ this ->snapshot_utils = new WP_CLI \Snapshot \Utils ();
104
+ $ this ->progress = Utils \make_progress_bar ( 'Creating Backup ' , 5 );
104
105
105
106
}
106
107
@@ -252,6 +253,7 @@ public function _list( $args, $assoc_args ) {
252
253
* @throws WP_CLI\ExitException
253
254
*/
254
255
public function restore ( $ args , $ assoc_args ) {
256
+ $ this ->snapshot_utils ->available_wp_packages (); // Check required packages available or not.
255
257
$ backup_info = $ this ->get_backup_info ( $ args [0 ] );
256
258
$ snapshot_files = [];
257
259
$ extra_snapshot_info = $ this ->db ->get_extra_snapshot_info ( $ backup_info ['id ' ] );
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ private function get_packages_list() {
61
61
}
62
62
63
63
foreach ( $ packages_raw_list as $ package ) {
64
- $ this ->installed_packages [ $ package [ ' name ' ] ] = $ package ['name ' ];
64
+ $ this ->installed_packages [] = $ package ['name ' ];
65
65
}
66
66
}
67
67
@@ -72,9 +72,11 @@ private function get_packages_list() {
72
72
*/
73
73
private function check_missing_packages () {
74
74
foreach ( $ this ->required_packages as $ package_name => $ installation_command ) {
75
- if ( empty ( $ this ->installed_packages [ $ package_name ] ) ) {
76
- $ this -> missing_packages [ $ package_name ] = $ installation_command ;
75
+ if ( in_array ( $ package_name , $ this ->installed_packages , true ) ) {
76
+ continue ;
77
77
}
78
+
79
+ $ this ->missing_packages [ $ package_name ] = $ installation_command ;
78
80
}
79
81
80
82
if ( empty ( $ this ->missing_packages ) ) {
@@ -91,10 +93,10 @@ private function check_missing_packages() {
91
93
*/
92
94
private function show_missing_packages_info () {
93
95
foreach ( $ this ->missing_packages as $ package_name => $ installation_command ) {
94
- WP_CLI ::warning ( "Missing ' $ package_name' package. Try ' $ installation_command'. " );
96
+ WP_CLI ::warning ( "Missing ' { $ package_name} ' package. Try ' { $ installation_command} '. " );
95
97
}
96
98
97
- WP_CLI ::error ( 'Snapshot command needs to be installed above packages . ' );
99
+ WP_CLI ::error ( 'Snapshot command requires above packages to be installed. ' );
98
100
}
99
101
100
102
}
You can’t perform that action at this time.
0 commit comments