Repository navigation
Nextcloud 21 beta 1 Error: Call to a member function getContainer() on null #24711
Description
Activity
- added0. Needs triagePending check for reproducibility or if it fits our roadmapPending check for reproducibility or if it fits our roadmap
on Dec 15, 2020 Still present with NC21 beta-3.
Error occurs when enabling any app. In polls it seems, that the migration doesn't run properly then (preSchemaChange seems not to be executed). I can't confirm if this relates to this issue, but with NC20 migrations run as expected.Still present with NC21 beta-6.
Also seeing this issue on 21.0.0 final
Reacted by Stavros Kois and ggeorggIs there a known fix?
is there any other error logged before the one about the undefined index or the getContainer? I don't see how the code can take that path without any preceding error
I get this one for every app before the getContainer error:
{ "reqId": "QGjRhKM7q7d7EfmjYfQE", "level": 3, "time": "2021-02-20T23:44:17+01:00", "remoteAddr": "", "user": "--", "app": "PHP", "method": "", "url": "--", "message": { "Exception": "Error", "Message": "Undefined index: news at /var/www/nextcloud/lib/private/AppFramework/Bootstrap/RegistrationContext.php#421", "Code": 0, "Trace": [ { "file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/RegistrationContext.php", "line": 421, "function": "onError", "class": "OC\\Log\\ErrorHandler", "type": "::" }, { "file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php", "line": 143, "function": "delegateContainerRegistrations", "class": "OC\\AppFramework\\Bootstrap\\RegistrationContext", "type": "->" }, { "file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php", "line": 86, "function": "registerApps", "class": "OC\\AppFramework\\Bootstrap\\Coordinator", "type": "->" }, { "file": "/var/www/nextcloud/lib/private/Installer.php", "line": 146, "function": "runLazyRegistration", "class": "OC\\AppFramework\\Bootstrap\\Coordinator", "type": "->" }, { "file": "/var/www/nextcloud/lib/private/legacy/OC_App.php", "line": 431, "function": "installApp", "class": "OC\\Installer", "type": "->" }, { "file": "/var/www/nextcloud/core/Command/App/Install.php", "line": 84, "function": "enable", "class": "OC_App", "type": "->" }, { "file": "/var/www/nextcloud/3rdparty/symfony/console/Command/Command.php", "line": 255, "function": "execute", "class": "OC\\Core\\Command\\App\\Install", "type": "->" }, { "file": "/var/www/nextcloud/3rdparty/symfony/console/Application.php", "line": 1009, "function": "run", "class": "Symfony\\Component\\Console\\Command\\Command", "type": "->" }, { "file": "/var/www/nextcloud/3rdparty/symfony/console/Application.php", "line": 273, "function": "doRunCommand", "class": "Symfony\\Component\\Console\\Application", "type": "->" }, { "file": "/var/www/nextcloud/3rdparty/symfony/console/Application.php", "line": 149, "function": "doRun", "class": "Symfony\\Component\\Console\\Application", "type": "->" }, { "file": "/var/www/nextcloud/lib/private/Console/Application.php", "line": 215, "function": "run", "class": "Symfony\\Component\\Console\\Application", "type": "->" }, { "file": "/var/www/nextcloud/console.php", "line": 100, "function": "run", "class": "OC\\Console\\Application", "type": "->" }, { "file": "/var/www/nextcloud/occ", "line": 11, "args": [ "/var/www/nextcloud/console.php" ], "function": "require_once" } ], "File": "/var/www/nextcloud/lib/private/Log/ErrorHandler.php", "Line": 92, "CustomMessage": "--" }, "userAgent": "--", "version": "21.0.0.18", "id": "603394c4e7be7" }Reacted by klouI also have the same 2 (sets of) errors, except
...RegistrationContext.php#404on NC21 final I see it, have you found any fix ?
Thanks a lot for the log @szaimen. I think I understand it now. There is only one occurrence in the code where we create and write the application instance to the
$appsvariable. And if there's an error there we silently continue.Could someone apply this patch and try again?
diff --git a/lib/private/AppFramework/Bootstrap/Coordinator.php b/lib/private/AppFramework/Bootstrap/Coordinator.php index 06a17e5242b..d82424f542b 100644 --- a/lib/private/AppFramework/Bootstrap/Coordinator.php +++ b/lib/private/AppFramework/Bootstrap/Coordinator.php @@ -118,7 +118,10 @@ class Coordinator { /** @var IBootstrap|App $application */ $apps[$appId] = $application = $this->serverContainer->query($applicationClassName); } catch (QueryException $e) { - // Weird, but ok + $this->logger->logException($e, [ + 'message' => "Application class $applicationClassName can't be loaded: " . $e->getMessage(), + 'level' => ILogger::FATAL, + ]); continue; } try {
I've applied the fix, disabled the news app, enabled it again but the same error messages appear again.
Also unfortunately no new error message was logged, so I'm not sure if the patch works.
BTW: when I enable the news app, all those messages get logged: (which seem to be related to the enable command)

Hmm did you flush your opcache? Try restarting the web server.
Yes, I've cleared the cache (redis and apcu) and restarted the whole server. Still the same.
So it's always erroring at the exact same line. Try this
diff --git a/lib/private/AppFramework/Bootstrap/RegistrationContext.php b/lib/private/AppFramework/Bootstrap/RegistrationContext.php index d2dc365d835..988313f20e8 100644 --- a/lib/private/AppFramework/Bootstrap/RegistrationContext.php +++ b/lib/private/AppFramework/Bootstrap/RegistrationContext.php @@ -38,6 +38,7 @@ use OCP\Dashboard\IManager; use OCP\EventDispatcher\IEventDispatcher; use OCP\ILogger; use Throwable; +use function array_shift; class RegistrationContext { @@ -399,7 +400,7 @@ class RegistrationContext { } } - foreach ($this->aliases as $registration) { + while (($registration = array_shift($this->aliases)) !== null) { try { $apps[$registration['appId']] ->getContainer() @@ -416,7 +417,7 @@ class RegistrationContext { } } - foreach ($this->parameters as $registration) { + while (($registration = array_shift($this->parameters)) !== null) { try { $apps[$registration['appId']] ->getContainer()
Now that I think about it I'm very confident that this is actually the problem. Let me also open a PR …
- added3. to reviewWaiting for reviewsWaiting for reviewsand removed0. Needs triagePending check for reproducibility or if it fits our roadmapPending check for reproducibility or if it fits our roadmap
on Feb 24, 2021 See #25786
I've applied the patch and can confirm that it works. Thank you!
finally 🎊
Reacted by hobbseckyReacted by Simon L.Reacted by Simon L.For some reason it works when I put offending apps into the non-writable directory, but not it's in wapps
(and yes the wapps dir has properly set up permissions)
Sorry, but I’m new on github. I have the same problem. I’m trying to execute the patch but I can’t. Access denied. For sure I’m making something wrong. Must I specify any thing for git to recognize the patch? Thanks in advance
I've applied the patch and can confirm that it works. Thank you!
Same here. Thanks!
finally 🎊
Thanks! Worked for me too.
Error: Call to a member function getContainer() on null
Error: Undefined index: workflowengine at /var/www/nextcloud/lib/private/AppFramework/Bootstrap/RegistrationContext.php#368