mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 08:16:43 -04:00
Merge pull request #27681 from nextcloud/backport/27668/stable21
[stable21] Harden bootstrap context registrations when apps are missing
This commit is contained in:
commit
2ce22c75cb
1 changed files with 51 additions and 11 deletions
|
|
@ -302,12 +302,20 @@ class RegistrationContext {
|
|||
*/
|
||||
public function delegateCapabilityRegistrations(array $apps): void {
|
||||
while (($registration = array_shift($this->capabilities)) !== null) {
|
||||
$appId = $registration['appId'];
|
||||
if (!isset($apps[$appId])) {
|
||||
// If we land here something really isn't right. But at least we caught the
|
||||
// notice that is otherwise emitted for the undefined index
|
||||
$this->logger->error("App $appId not loaded for the capability registration");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$apps[$registration['appId']]
|
||||
$apps[$appId]
|
||||
->getContainer()
|
||||
->registerCapability($registration['capability']);
|
||||
} catch (Throwable $e) {
|
||||
$appId = $registration['appId'];
|
||||
$this->logger->logException($e, [
|
||||
'message' => "Error during capability registration of $appId: " . $e->getMessage(),
|
||||
'level' => ILogger::ERROR,
|
||||
|
|
@ -380,11 +388,20 @@ class RegistrationContext {
|
|||
*/
|
||||
public function delegateContainerRegistrations(array $apps): void {
|
||||
while (($registration = array_shift($this->services)) !== null) {
|
||||
$appId = $registration['appId'];
|
||||
if (!isset($apps[$appId])) {
|
||||
// If we land here something really isn't right. But at least we caught the
|
||||
// notice that is otherwise emitted for the undefined index
|
||||
$this->logger->error("App $appId not loaded for the container service registration");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
/**
|
||||
* Register the service and convert the callable into a \Closure if necessary
|
||||
*/
|
||||
$apps[$registration['appId']]
|
||||
$apps[$appId]
|
||||
->getContainer()
|
||||
->registerService(
|
||||
$registration['name'],
|
||||
|
|
@ -392,7 +409,6 @@ class RegistrationContext {
|
|||
$registration['shared'] ?? true
|
||||
);
|
||||
} catch (Throwable $e) {
|
||||
$appId = $registration['appId'];
|
||||
$this->logger->logException($e, [
|
||||
'message' => "Error during service registration of $appId: " . $e->getMessage(),
|
||||
'level' => ILogger::ERROR,
|
||||
|
|
@ -401,15 +417,23 @@ class RegistrationContext {
|
|||
}
|
||||
|
||||
while (($registration = array_shift($this->aliases)) !== null) {
|
||||
$appId = $registration['appId'];
|
||||
if (!isset($apps[$appId])) {
|
||||
// If we land here something really isn't right. But at least we caught the
|
||||
// notice that is otherwise emitted for the undefined index
|
||||
$this->logger->error("App $appId not loaded for the container alias registration");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$apps[$registration['appId']]
|
||||
$apps[$appId]
|
||||
->getContainer()
|
||||
->registerAlias(
|
||||
$registration['alias'],
|
||||
$registration['target']
|
||||
);
|
||||
} catch (Throwable $e) {
|
||||
$appId = $registration['appId'];
|
||||
$this->logger->logException($e, [
|
||||
'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
|
||||
'level' => ILogger::ERROR,
|
||||
|
|
@ -418,17 +442,25 @@ class RegistrationContext {
|
|||
}
|
||||
|
||||
while (($registration = array_shift($this->parameters)) !== null) {
|
||||
$appId = $registration['appId'];
|
||||
if (!isset($apps[$appId])) {
|
||||
// If we land here something really isn't right. But at least we caught the
|
||||
// notice that is otherwise emitted for the undefined index
|
||||
$this->logger->error("App $appId not loaded for the container parameter registration");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$apps[$registration['appId']]
|
||||
$apps[$appId]
|
||||
->getContainer()
|
||||
->registerParameter(
|
||||
$registration['name'],
|
||||
$registration['value']
|
||||
);
|
||||
} catch (Throwable $e) {
|
||||
$appId = $registration['appId'];
|
||||
$this->logger->logException($e, [
|
||||
'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
|
||||
'message' => "Error during service parameter registration of $appId: " . $e->getMessage(),
|
||||
'level' => ILogger::ERROR,
|
||||
]);
|
||||
}
|
||||
|
|
@ -440,12 +472,20 @@ class RegistrationContext {
|
|||
*/
|
||||
public function delegateMiddlewareRegistrations(array $apps): void {
|
||||
while (($middleware = array_shift($this->middlewares)) !== null) {
|
||||
$appId = $middleware['appId'];
|
||||
if (!isset($apps[$appId])) {
|
||||
// If we land here something really isn't right. But at least we caught the
|
||||
// notice that is otherwise emitted for the undefined index
|
||||
$this->logger->error("App $appId not loaded for the container middleware registration");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$apps[$middleware['appId']]
|
||||
$apps[$appId]
|
||||
->getContainer()
|
||||
->registerMiddleWare($middleware['class']);
|
||||
} catch (Throwable $e) {
|
||||
$appId = $middleware['appId'];
|
||||
$this->logger->logException($e, [
|
||||
'message' => "Error during capability registration of $appId: " . $e->getMessage(),
|
||||
'level' => ILogger::ERROR,
|
||||
|
|
|
|||
Loading…
Reference in a new issue