Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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 <[email protected]>
  • Loading branch information
ChristophWurst authored and backportbot[bot] committed Nov 30, 2021
commit 1933b3d8cb556a562ee2dd9f763c45f71d1a8295
9 changes: 8 additions & 1 deletion lib/private/Repair.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use Throwable;

class Repair implements IOutput {

Expand Down Expand Up @@ -140,7 +141,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");
}
Expand Down