aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Support
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2021-06-24 15:31:49 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-06-24 15:31:49 +0200
commit35a9ad0d787c4db0e22098025a410912bcb45854 (patch)
treee18d4c5757cd65f655e96c8a08475571a26cc79c /lib/private/Support
parentbdfd2d92090f5b80254232aecab523f0aaf5e0fc (diff)
downloadnextcloud-server-35a9ad0d787c4db0e22098025a410912bcb45854.tar.gz
nextcloud-server-35a9ad0d787c4db0e22098025a410912bcb45854.zip
Unshift crash reports when they are loaded, to break the recusion
If, for whatever reason, during the loading of a crash reporter a new log entry is generated, then the lazy loading mechanism will be invoked *again* while it's already executed. This doesn't result in an endless recursion, but means that the crash reporters will be built and registered many times. This then means any further log entry will be logged x times instead of once. Unshift makes sure to take the class off the registration list right away, so another invokation of the same method won't try to do the same job. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/Support')
-rw-r--r--lib/private/Support/CrashReport/Registry.php5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/private/Support/CrashReport/Registry.php b/lib/private/Support/CrashReport/Registry.php
index a5c39de98f0..96796d6370f 100644
--- a/lib/private/Support/CrashReport/Registry.php
+++ b/lib/private/Support/CrashReport/Registry.php
@@ -35,6 +35,7 @@ use OCP\Support\CrashReport\IMessageReporter;
use OCP\Support\CrashReport\IRegistry;
use OCP\Support\CrashReport\IReporter;
use Throwable;
+use function array_shift;
class Registry implements IRegistry {
@@ -119,8 +120,7 @@ class Registry implements IRegistry {
}
private function loadLazyProviders(): void {
- $classes = $this->lazyReporters;
- foreach ($classes as $class) {
+ while (($class = array_shift($this->lazyReporters)) !== null) {
try {
/** @var IReporter $reporter */
$reporter = $this->serverContainer->query($class);
@@ -151,6 +151,5 @@ class Registry implements IRegistry {
]);
}
}
- $this->lazyReporters = [];
}
}