Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to undefined method OC\\Server::getEventDispatcher() #1864

Open
ChristophWurst opened this issue Nov 6, 2023 · 9 comments
Open

Call to undefined method OC\\Server::getEventDispatcher() #1864

ChristophWurst opened this issue Nov 6, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@ChristophWurst
Copy link
Member

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:

  1. ???

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) ...
@ChristophWurst ChristophWurst added the bug Something isn't working label Nov 6, 2023
@blindzero
Copy link

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.

@Thatoo
Copy link

Thatoo commented Jan 17, 2024

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"
}

@Thatoo
Copy link

Thatoo commented Jan 17, 2024

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.

@rikmeijer
Copy link
Contributor

rikmeijer commented Feb 1, 2024

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)

@Thatoo
Copy link

Thatoo commented Feb 8, 2024

@rikmeijer did you make a PR for that?

@Thatoo
Copy link

Thatoo commented Feb 8, 2024

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();

@rikmeijer
Copy link
Contributor

I put my altered Application.php in a gist

@paulcalabro
Copy link

paulcalabro commented Feb 22, 2024

Thanks for sharing that @rikmeijer ! That appears to have resolved the issue for me.

@paulcalabro
Copy link

Is anyone working on this? If not, I can make a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants