Skip to content

Commit 48f413a

Browse files
committed
fix: log and write the output of the 'occ maintenance:mode --off' command if it fails
Signed-off-by: Julien Veyssier <[email protected]>
1 parent 55d647a commit 48f413a

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

lib/UpdateCommand.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,25 @@ protected function execute(InputInterface $input, OutputInterface $output) {
354354
}
355355

356356
$this->updater->log('[info] Disabling maintenance mode');
357-
system($occRunCommand . ' maintenance:mode --off', $returnValueMaintenanceMode);
357+
$descriptorSpec = [
358+
0 => ['pipe', 'r'], // stdin
359+
1 => ['pipe', 'w'], // stdout
360+
2 => ['pipe', 'w'], // stderr
361+
];
362+
$process = proc_open($occRunCommand . ' maintenance:mode --off', $descriptorSpec, $pipes);
363+
if (!is_resource($process)) {
364+
$this->updater->log('[info] Could not run the command to disable maintenance mode');
365+
$output->writeln('');
366+
$output->writeln('Could not run the command to disable maintenance mode');
367+
return 1;
368+
}
369+
fclose($pipes[0]);
370+
$stdoutContent = stream_get_contents($pipes[1]);
371+
fclose($pipes[1]);
372+
$stderrContent = stream_get_contents($pipes[2]);
373+
fclose($pipes[2]);
374+
$returnValueMaintenanceMode = proc_close($process);
375+
358376
if ($returnValueMaintenanceMode === 0) {
359377
$this->updater->log('[info] maintenance mode disabled');
360378
$output->writeln('');
@@ -364,6 +382,14 @@ protected function execute(InputInterface $input, OutputInterface $output) {
364382
$this->updater->log('[info] Disabling maintenance mode failed - return code: ' . $returnValueMaintenanceMode);
365383
$output->writeln('');
366384
$output->writeln('Disabling Maintenance mode failed - return code:' . $returnValueMaintenanceMode);
385+
if ($stdoutContent) {
386+
$this->updater->log('[info] occ stdout: ' . $stdoutContent);
387+
$output->writeln('occ stdout: ' . $stdoutContent);
388+
}
389+
if ($stderrContent) {
390+
$this->updater->log('[info] occ stderr: ' . $stderrContent);
391+
$output->writeln('occ stderr: ' . $stderrContent);
392+
}
367393
$this->updater->log('[info] updater finished - with errors');
368394
return $returnValueMaintenanceMode;
369395
}

0 commit comments

Comments
 (0)