|
9 | 9 | use App\RemoteSite\Responses\PrepareUpdate; |
10 | 10 | use Illuminate\Contracts\Queue\ShouldQueue; |
11 | 11 | use Illuminate\Foundation\Queue\Queueable; |
| 12 | +use Illuminate\Support\Facades\App; |
12 | 13 | use Illuminate\Support\Facades\Log; |
13 | 14 |
|
14 | 15 | class UpdateSite implements ShouldQueue |
@@ -74,6 +75,45 @@ public function handle(): void |
74 | 75 |
|
75 | 76 | protected function performExtraction(PrepareUpdate $prepareResult): void |
76 | 77 | { |
| 78 | + $connection = App::make(Connection::class, [ |
| 79 | + $this->site->url, |
| 80 | + $prepareResult->password |
| 81 | + ]); |
| 82 | + |
| 83 | + // Ping server |
| 84 | + $pingResult = $connection->performExtractionRequest(["task" => "ping"]); |
| 85 | + |
| 86 | + if (empty($pingResult["message"]) || $pingResult["message"] === 'Invalid login') { |
| 87 | + throw new \Exception( |
| 88 | + "Invalid ping response for site: " . $this->site->id |
| 89 | + ); |
| 90 | + } |
| 91 | + |
| 92 | + // Start extraction |
| 93 | + $stepResult = $connection->performExtractionRequest(["task" => "startExtract"]); |
| 94 | + |
| 95 | + // Run actual core update |
| 96 | + while (array_key_exists("done", $stepResult) && $stepResult["done"] !== true) { |
| 97 | + if ($stepResult["status"] !== true) { |
| 98 | + throw new \Exception( |
| 99 | + "Invalid extract response for site: " . $this->site->id |
| 100 | + ); |
| 101 | + } |
| 102 | + |
| 103 | + // Make next backup step |
| 104 | + $stepResult = $connection->performExtractionRequest( |
| 105 | + [ |
| 106 | + "task" => "stepExtract", |
| 107 | + "instance" => $stepResult["instance"] |
| 108 | + ] |
| 109 | + ); |
| 110 | + } |
77 | 111 |
|
| 112 | + // Clean up restore |
| 113 | + $connection->performExtractionRequest( |
| 114 | + [ |
| 115 | + "task" => "finalizeUpdate" |
| 116 | + ] |
| 117 | + ); |
78 | 118 | } |
79 | 119 | } |
0 commit comments