Skip to content

Commit f68ab00

Browse files
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 <christoph@winzerhof-wurst.at>
1 parent 6d357d0 commit f68ab00

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/private/Repair.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
use Psr\Log\LoggerInterface;
8181
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
8282
use Symfony\Component\EventDispatcher\GenericEvent;
83+
use Throwable;
8384

8485
class Repair implements IOutput {
8586

@@ -140,7 +141,13 @@ public function addStep($repairStep) {
140141
$s = \OC::$server->query($repairStep);
141142
} catch (QueryException $e) {
142143
if (class_exists($repairStep)) {
143-
$s = new $repairStep();
144+
try {
145+
// Last resort: hope there are no constructor arguments
146+
$s = new $repairStep();
147+
} catch (Throwable $inner) {
148+
// Well, it was worth a try
149+
throw new \Exception("Repair step '$repairStep' can't be instantiated: " . $e->getMessage(), 0, $e);
150+
}
144151
} else {
145152
throw new \Exception("Repair step '$repairStep' is unknown");
146153
}

0 commit comments

Comments
 (0)