From bb91d5bd69bcce0c099d59cfef655ea9e7cccad7 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 30 Nov 2021 08:56:41 +0100 Subject: [PATCH 1/2] Let repair step query exceptions bubble up And hide the type error caused by a constructor call with missing arguments. `new $repairStep();` only works for the rare case that no arguments are required. Anything else will throw. Then we previously hid the trace of the more important query exception. Signed-off-by: Christoph Wurst --- lib/private/Repair.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/private/Repair.php b/lib/private/Repair.php index 1fe332cf1e2e2..50c12232f0518 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -79,6 +79,7 @@ use OCP\Migration\IRepairStep; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; +use Throwable; class Repair implements IOutput { @@ -131,7 +132,13 @@ public function addStep($repairStep) { $s = \OC::$server->query($repairStep); } catch (QueryException $e) { if (class_exists($repairStep)) { - $s = new $repairStep(); + try { + // Last resort: hope there are no constructor arguments + $s = new $repairStep(); + } catch (Throwable $inner) { + // Well, it was worth a try + throw new \Exception("Repair step '$repairStep' can't be instantiated: " . $e->getMessage(), 0, $e); + } } else { throw new \Exception("Repair step '$repairStep' is unknown"); } From 56fb21769fb434dd4b0461081aab47dd2acc8004 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 30 Nov 2021 10:57:49 +0100 Subject: [PATCH 2/2] Include previous execption for repair steps that don't exist Signed-off-by: Christoph Wurst --- lib/private/Repair.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Repair.php b/lib/private/Repair.php index 50c12232f0518..406149ac3560e 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -140,7 +140,7 @@ public function addStep($repairStep) { throw new \Exception("Repair step '$repairStep' can't be instantiated: " . $e->getMessage(), 0, $e); } } else { - throw new \Exception("Repair step '$repairStep' is unknown"); + throw new \Exception("Repair step '$repairStep' is unknown", 0, $e); } }