Call to undefined method OC\\Server::getEventDispatcher()
Describe the bug
{
"reqId": "2PtOBQe5Y6B2la734eY8",
"level": 4,
"time": "2023-11-06T08:21:35+00:00",
"remoteAddr": "2001:9e8:367e:ac00:93ff:25b4:2b5:8bf1",
"user": "--",
"app": "social",
"method": "GET",
"url": "/ocs/v2.php/apps/dashboard/api/v2/widget-items?widgets%5B%5D=activity",
"message": "Error during app service registration: Call to undefined method OC\\Server::getEventDispatcher()",
"userAgent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0",
"version": "28.0.0.3",
"exception": {
"Exception": "Error",
"Message": "Call to undefined method OC\\Server::getEventDispatcher()",
"Code": 0,
"Trace": [
{
"file": "/var/www/nextcloud/apps/social/lib/AppInfo/Application.php",
"line": 71,
"function": "registerDeprecatedListener",
"class": "OCA\\Social\\AppInfo\\Application",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php",
"line": 142,
"function": "register",
"class": "OCA\\Social\\AppInfo\\Application",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php",
"line": 90,
"function": "registerApps",
"class": "OC\\AppFramework\\Bootstrap\\Coordinator",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/base.php",
"line": 700,
"function": "runInitialRegistration",
"class": "OC\\AppFramework\\Bootstrap\\Coordinator",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/base.php",
"line": 1200,
"function": "init",
"class": "OC",
"type": "::"
},
{
"file": "/var/www/nextcloud/ocs/v1.php",
"line": 31,
"args": [
"/var/www/nextcloud/lib/base.php"
],
"function": "require_once"
},
{
"file": "/var/www/nextcloud/ocs/v2.php",
"line": 23,
"args": [
"/var/www/nextcloud/ocs/v1.php"
],
"function": "require_once"
}
],
"File": "/var/www/nextcloud/apps/social/lib/AppInfo/Application.php",
"Line": 82,
"message": "Error during app service registration: Call to undefined method OC\\Server::getEventDispatcher()",
"exception": {},
"CustomMessage": "Error during app service registration: Call to undefined method OC\\Server::getEventDispatcher()"
}
}
To Reproduce Steps to reproduce the behavior:
- ???
Expected behavior
App does not use private APIs.
Screenshots If applicable, add screenshots to help explain your problem.
Client details:
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
- Device: [e.g. iPhone6, desktop]
Server details
**Social app version:**Operating system:
Web server:
Database:
PHP version:
Nextcloud version: 28
Logs
Nextcloud log (data/nextcloud.log)
Insert your Nextcloud log here
Browser log
Insert your browser log here, this could for example include:
a) The javascript console log
b) The network log
c) ...
same here... With OS: Debian 6.1.27-1 PHP: 8.2.14 Webserver: Apache/2.4.57 + nginx/1.24.0 in proxy-mode (standard Plesk setup)
all clients behave in the same way.
Same here with :
- OS: Debian 11.8
- PHP: 8.2.14
- Webserver: nginx
- Nextcloud 28.0.1
{
"reqId": "Z4aKkF6PliRh58VVYKSf",
"level": 4,
"time": "2024-01-17T09:37:51+00:00",
"remoteAddr": "XXX.XXX.XXX.XXX",
"user": "--",
"app": "social",
"method": "GET",
"url": "/nuage-nextcloud/apps/logreader/api/log?offset=0&query=",
"message": "Error during app service registration: Call to undefined method OC\\Server::getEventDispatcher()",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0",
"version": "28.0.1.1",
"exception": {
"Exception": "Error",
"Message": "Call to undefined method OC\\Server::getEventDispatcher()",
"Code": 0,
"Trace": [
{
"file": "/var/www/nextcloud/apps/social/lib/AppInfo/Application.php",
"line": 71,
"function": "registerDeprecatedListener",
"class": "OCA\\Social\\AppInfo\\Application",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php",
"line": 142,
"function": "register",
"class": "OCA\\Social\\AppInfo\\Application",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php",
"line": 90,
"function": "registerApps",
"class": "OC\\AppFramework\\Bootstrap\\Coordinator",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/base.php",
"line": 700,
"function": "runInitialRegistration",
"class": "OC\\AppFramework\\Bootstrap\\Coordinator",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/base.php",
"line": 1200,
"function": "init",
"class": "OC",
"type": "::"
},
{
"file": "/var/www/nextcloud/index.php",
"line": 37,
"args": [
"/var/www/nextcloud/lib/base.php"
],
"function": "require_once"
}
],
"File": "/var/www/nextcloud/apps/social/lib/AppInfo/Application.php",
"Line": 82,
"message": "Error during app service registration: Call to undefined method OC\\Server::getEventDispatcher()",
"exception": [],
"CustomMessage": "Error during app service registration: Call to undefined method OC\\Server::getEventDispatcher()"
},
"id": "65a79fef269ec"
}
Doesn't seem to make any trouble (didn't see any issue using the social app) but it makes the log very much full !
[edit] It was fulling the log too much, I had to disable the Social app. I'll wait for a fix before enable it back.
Fixed (well, it stopped generating errors) it by replacing line ./apps/social/lib/AppInfo/Application.php@71 with:
$dispatcher = $this->getContainer()->query(IEventDispatcher::class);
and adding (at the top of the file)
use OCP\EventDispatcher\IEventDispatcher;
(based on https://docs.nextcloud.com/server/19/developer_manual/app/events.html)
@rikmeijer did you make a PR for that?
Could you write which line you modify and replace by $dispatcher = $this->getContainer()->query(IEventDispatcher::class); ?
because line 71, I have
71 $this->registerDeprecatedListener();
and it doesn't feel right to make the modification there. If you had said to change line 82, I'd understand better :
82 $dispatcher = \OC::$server->getEventDispatcher();
I put my altered Application.php in a gist
Thanks for sharing that @rikmeijer ! That appears to have resolved the issue for me.
Is anyone working on this? If not, I can make a PR.
So far as I can tell, Social is abandoned, but you could fork it and merge back if the maintainer ever returns. Your Application.php solved the errors for me [1], and because it was a Vue Event thing I'd hoped it would also solve why I can't any open profiles, but that adventure continues. If you fork this repo, I'll subscribe!
(1) I had to make a small change, it wouldn't work for me without the namespace
$dispatcher = $this->getContainer()->query(\OCP\EventDispatcher\IEventDispatcher::class);