@@ -302,12 +302,20 @@ public function registerTemplateProvider(string $appId, string $class): void {
302302 */
303303 public function delegateCapabilityRegistrations (array $ apps ): void {
304304 while (($ registration = array_shift ($ this ->capabilities )) !== null ) {
305+ $ appId = $ registration ['appId ' ];
306+ if (!isset ($ apps [$ appId ])) {
307+ // If we land here something really isn't right. But at least we caught the
308+ // notice that is otherwise emitted for the undefined index
309+ $ this ->logger ->error ("App $ appId not loaded for the capability registration " );
310+
311+ continue ;
312+ }
313+
305314 try {
306- $ apps [$ registration [ ' appId ' ] ]
315+ $ apps [$ appId ]
307316 ->getContainer ()
308317 ->registerCapability ($ registration ['capability ' ]);
309318 } catch (Throwable $ e ) {
310- $ appId = $ registration ['appId ' ];
311319 $ this ->logger ->logException ($ e , [
312320 'message ' => "Error during capability registration of $ appId: " . $ e ->getMessage (),
313321 'level ' => ILogger::ERROR ,
@@ -380,19 +388,27 @@ public function delegateEventListenerRegistrations(IEventDispatcher $eventDispat
380388 */
381389 public function delegateContainerRegistrations (array $ apps ): void {
382390 while (($ registration = array_shift ($ this ->services )) !== null ) {
391+ $ appId = $ registration ['appId ' ];
392+ if (!isset ($ apps [$ appId ])) {
393+ // If we land here something really isn't right. But at least we caught the
394+ // notice that is otherwise emitted for the undefined index
395+ $ this ->logger ->error ("App $ appId not loaded for the container service registration " );
396+
397+ continue ;
398+ }
399+
383400 try {
384401 /**
385402 * Register the service and convert the callable into a \Closure if necessary
386403 */
387- $ apps [$ registration [ ' appId ' ] ]
404+ $ apps [$ appId ]
388405 ->getContainer ()
389406 ->registerService (
390407 $ registration ['name ' ],
391408 Closure::fromCallable ($ registration ['factory ' ]),
392409 $ registration ['shared ' ] ?? true
393410 );
394411 } catch (Throwable $ e ) {
395- $ appId = $ registration ['appId ' ];
396412 $ this ->logger ->logException ($ e , [
397413 'message ' => "Error during service registration of $ appId: " . $ e ->getMessage (),
398414 'level ' => ILogger::ERROR ,
@@ -401,32 +417,48 @@ public function delegateContainerRegistrations(array $apps): void {
401417 }
402418
403419 while (($ registration = array_shift ($ this ->aliases )) !== null ) {
420+ $ appId = $ registration ['appId ' ];
421+ if (!isset ($ apps [$ appId ])) {
422+ // If we land here something really isn't right. But at least we caught the
423+ // notice that is otherwise emitted for the undefined index
424+ $ this ->logger ->error ("App $ appId not loaded for the container alias registration " );
425+
426+ continue ;
427+ }
428+
404429 try {
405- $ apps [$ registration [ ' appId ' ] ]
430+ $ apps [$ appId ]
406431 ->getContainer ()
407432 ->registerAlias (
408433 $ registration ['alias ' ],
409434 $ registration ['target ' ]
410435 );
411436 } catch (Throwable $ e ) {
412- $ appId = $ registration ['appId ' ];
413437 $ this ->logger ->logException ($ e , [
414- 'message ' => "Error during service alias registration of $ appId: " . $ e ->getMessage (),
438+ 'message ' => "Error during service parameter registration of $ appId: " . $ e ->getMessage (),
415439 'level ' => ILogger::ERROR ,
416440 ]);
417441 }
418442 }
419443
420444 while (($ registration = array_shift ($ this ->parameters )) !== null ) {
445+ $ appId = $ registration ['appId ' ];
446+ if (!isset ($ apps [$ appId ])) {
447+ // If we land here something really isn't right. But at least we caught the
448+ // notice that is otherwise emitted for the undefined index
449+ $ this ->logger ->error ("App $ appId not loaded for the container parameter registration " );
450+
451+ continue ;
452+ }
453+
421454 try {
422- $ apps [$ registration [ ' appId ' ] ]
455+ $ apps [$ appId ]
423456 ->getContainer ()
424457 ->registerParameter (
425458 $ registration ['name ' ],
426459 $ registration ['value ' ]
427460 );
428461 } catch (Throwable $ e ) {
429- $ appId = $ registration ['appId ' ];
430462 $ this ->logger ->logException ($ e , [
431463 'message ' => "Error during service alias registration of $ appId: " . $ e ->getMessage (),
432464 'level ' => ILogger::ERROR ,
@@ -440,12 +472,20 @@ public function delegateContainerRegistrations(array $apps): void {
440472 */
441473 public function delegateMiddlewareRegistrations (array $ apps ): void {
442474 while (($ middleware = array_shift ($ this ->middlewares )) !== null ) {
475+ $ appId = $ middleware ['appId ' ];
476+ if (!isset ($ apps [$ appId ])) {
477+ // If we land here something really isn't right. But at least we caught the
478+ // notice that is otherwise emitted for the undefined index
479+ $ this ->logger ->error ("App $ appId not loaded for the container middleware registration " );
480+
481+ continue ;
482+ }
483+
443484 try {
444- $ apps [$ middleware [ ' appId ' ] ]
485+ $ apps [$ appId ]
445486 ->getContainer ()
446487 ->registerMiddleWare ($ middleware ['class ' ]);
447488 } catch (Throwable $ e ) {
448- $ appId = $ middleware ['appId ' ];
449489 $ this ->logger ->logException ($ e , [
450490 'message ' => "Error during capability registration of $ appId: " . $ e ->getMessage (),
451491 'level ' => ILogger::ERROR ,
0 commit comments