summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-02-01 14:56:56 +0100
committerMorris Jobke <hey@morrisjobke.de>2021-03-18 08:45:17 +0100
commit9e3775618bde7c0bf57fa7248e9a7dc2dbb47f4d (patch)
tree4749233c246458fd57b0b33c2447265a11263a3f
parent9135a42781f52e9853cd5a8c831cb6cc2fcdd7f5 (diff)
downloadnextcloud-server-9e3775618bde7c0bf57fa7248e9a7dc2dbb47f4d.tar.gz
nextcloud-server-9e3775618bde7c0bf57fa7248e9a7dc2dbb47f4d.zip
log full expection during repair step
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--core/register_command.php4
-rw-r--r--lib/private/Migration/BackgroundRepair.php3
-rw-r--r--lib/private/Repair.php7
-rw-r--r--lib/private/Updater.php5
-rw-r--r--lib/private/legacy/OC_App.php3
-rw-r--r--tests/lib/RepairStepTest.php3
6 files changed, 18 insertions, 7 deletions
diff --git a/core/register_command.php b/core/register_command.php
index 3c8aa50e18c..a357c9b7470 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -46,6 +46,8 @@
/** @var Symfony\Component\Console\Application $application */
+use Psr\Log\LoggerInterface;
+
$application->add(new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand());
$application->add(new OC\Core\Command\Status);
$application->add(new OC\Core\Command\Check(\OC::$server->getSystemConfig()));
@@ -161,7 +163,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
$application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->query(\OC\Installer::class)));
$application->add(new OC\Core\Command\Maintenance\Repair(
- new \OC\Repair([], \OC::$server->getEventDispatcher()),
+ new \OC\Repair([], \OC::$server->getEventDispatcher(), \OC::$server->get(LoggerInterface::class)),
\OC::$server->getConfig(),
\OC::$server->getEventDispatcher(),
\OC::$server->getAppManager()
diff --git a/lib/private/Migration/BackgroundRepair.php b/lib/private/Migration/BackgroundRepair.php
index 5b8c7875ab7..749a1a1bc69 100644
--- a/lib/private/Migration/BackgroundRepair.php
+++ b/lib/private/Migration/BackgroundRepair.php
@@ -33,6 +33,7 @@ use OC\Repair;
use OC_App;
use OCP\BackgroundJob\IJobList;
use OCP\ILogger;
+use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
@@ -92,7 +93,7 @@ class BackgroundRepair extends TimedJob {
}
$step = $argument['step'];
- $repair = new Repair([], $this->dispatcher);
+ $repair = new Repair([], $this->dispatcher, \OC::$server->get(LoggerInterface::class));
try {
$repair->addStep($step);
} catch (\Exception $ex) {
diff --git a/lib/private/Repair.php b/lib/private/Repair.php
index 22a715caf1d..353f6c855bc 100644
--- a/lib/private/Repair.php
+++ b/lib/private/Repair.php
@@ -76,6 +76,7 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Collaboration\Resources\IManager;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
+use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
@@ -90,15 +91,18 @@ class Repair implements IOutput {
/** @var string */
private $currentStep;
+ private $logger;
+
/**
* Creates a new repair step runner
*
* @param IRepairStep[] $repairSteps array of RepairStep instances
* @param EventDispatcherInterface $dispatcher
*/
- public function __construct(array $repairSteps, EventDispatcherInterface $dispatcher) {
+ public function __construct(array $repairSteps, EventDispatcherInterface $dispatcher, LoggerInterface $logger) {
$this->repairSteps = $repairSteps;
$this->dispatcher = $dispatcher;
+ $this->logger = $logger;
}
/**
@@ -117,6 +121,7 @@ class Repair implements IOutput {
try {
$step->run($this);
} catch (\Exception $e) {
+ $this->logger->error("Exception while executing repair step " . $step->getName(), ['exception' => $e]);
$this->emit('\OC\Repair', 'error', [$e->getMessage()]);
}
}
diff --git a/lib/private/Updater.php b/lib/private/Updater.php
index 65e2c9bd57f..f6ba27991e7 100644
--- a/lib/private/Updater.php
+++ b/lib/private/Updater.php
@@ -45,6 +45,7 @@ use OC_App;
use OCP\IConfig;
use OCP\ILogger;
use OCP\Util;
+use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
/**
@@ -243,7 +244,7 @@ class Updater extends BasicEmitter {
file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
// pre-upgrade repairs
- $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher());
+ $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher(), \OC::$server->get(LoggerInterface::class));
$repair->run();
$this->doCoreUpgrade();
@@ -276,7 +277,7 @@ class Updater extends BasicEmitter {
}
// post-upgrade repairs
- $repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher());
+ $repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher(), \OC::$server->get(LoggerInterface::class));
$repair->run();
//Invalidate update feed
diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php
index d48d6c40810..aeaaf3bf1ea 100644
--- a/lib/private/legacy/OC_App.php
+++ b/lib/private/legacy/OC_App.php
@@ -61,6 +61,7 @@ use OCP\App\ManagerEvent;
use OCP\AppFramework\QueryException;
use OCP\Authentication\IAlternativeLogin;
use OCP\ILogger;
+use Psr\Log\LoggerInterface;
/**
* This class manages the apps. It allows them to register and integrate in the
@@ -1041,7 +1042,7 @@ class OC_App {
$dispatcher = OC::$server->getEventDispatcher();
// load the steps
- $r = new Repair([], $dispatcher);
+ $r = new Repair([], $dispatcher, \OC::$server->get(LoggerInterface::class));
foreach ($steps as $step) {
try {
$r->addStep($step);
diff --git a/tests/lib/RepairStepTest.php b/tests/lib/RepairStepTest.php
index 9a569f8af6d..b1d16fdd3fd 100644
--- a/tests/lib/RepairStepTest.php
+++ b/tests/lib/RepairStepTest.php
@@ -9,6 +9,7 @@
namespace Test;
use OCP\Migration\IRepairStep;
+use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
class RepairStepTest implements IRepairStep {
@@ -41,7 +42,7 @@ class RepairTest extends TestCase {
protected function setUp(): void {
parent::setUp();
$dispatcher = new EventDispatcher();
- $this->repair = new \OC\Repair([], $dispatcher);
+ $this->repair = new \OC\Repair([], $dispatcher, $this->createMock(LoggerInterface::class));
$dispatcher->addListener('\OC\Repair::warning', function ($event) {
/** @var \Symfony\Component\EventDispatcher\GenericEvent $event */