nextcloud / circles

👪 Create groups with other users on a Nextcloud instance and share with them
GNU Affero General Public License v3.0
144 stars 47 forks source link

Removing a circle breaks the Activity app #1543

Closed paulvt closed 4 days ago

paulvt commented 6 months ago

Once you created and deleted a circle (via the Contacts) app, the Activity app cannot be used any more.

Steps to reproduce:

  1. Go to the Contacts app
  2. Add a circle "Test"
  3. Delete this circle
  4. Switch to the Activity app

The overview now spams "Could not load activities" messages (very quickly).

This is Circles app version 28.0.0 on Nextcloud 28.0.4.1. Installed via Docker (community) on PHP 8.2/Apache with PostgreSQL as database.

Exception in the logs:

{  "reqId": "SM1NThrV4KlxaekTbvfN",
  "level": 3,
  [...]
  "app": "no app in context",
  "method": "GET",
  "url": "/ocs/v2.php/apps/activity/api/v2/activity/all?format=json&previews=true&since=0",
  "message": "Exception thrown: RuntimeException",
  "userAgent": "[...]",
  "version": "28.0.4.1",
  "exception": {
    "Exception": "RuntimeException",
    "Message": "image not found: image:png webroot: serverroot:/var/www/html",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/html/apps/circles/lib/Activity/Provider.php",
        "line": 96,
        "function": "imagePath",
        "class": "OC\\URLGenerator",
        "type": "->",
        "args": [
          "circles",
          "png"
        ]
      },
      {
        "file": "/var/www/html/apps/circles/lib/Activity/Provider.php",
        "line": 67,
        "function": "setIcon",
        "class": "OCA\\Circles\\Activity\\Provider",
        "type": "->",
        "args": [
          [
            "OC\\Activity\\Event"
          ]
        ]
      },
      {
        "file": "/var/www/html/apps/activity/lib/GroupHelper.php",
        "line": 72,
        "function": "parse",
        "class": "OCA\\Circles\\Activity\\Provider",
        "type": "->",
        "args": [
          "en_GB",
          [
            "OC\\Activity\\Event"
          ]
        ]
      },
      {
        "file": "/var/www/html/apps/activity/lib/Data.php",
        "line": 248,
        "function": "addActivity",
        "class": "OCA\\Activity\\GroupHelper",
        "type": "->",
        "args": [
          [
            845,
            1712666130,
            30,
            "circles_as_member",
            "",
            "And 10 more entries, set log level to debug to see all entries"
          ]
        ]
      },
      {
        "file": "/var/www/html/apps/activity/lib/Controller/APIv2Controller.php",
        "line": 205,
        "function": "get",
        "class": "OCA\\Activity\\Data",
        "type": "->",
        "args": [
          [
            "OCA\\Activity\\GroupHelper"
          ],
          [
            "OCA\\Activity\\UserSettings"
          ],
          "paul",
          0,
          50,
          "desc",
          "all",
          "",
          0
        ]
      },
      {
        "file": "/var/www/html/apps/activity/lib/Controller/APIv2Controller.php",
        "line": 152,
        "function": "get",
        "class": "OCA\\Activity\\Controller\\APIv2Controller",
        "type": "->",
        "args": [
          "all",
          0,
          50,
          true,
          "",
          0,
          "desc"
        ]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 230,
        "function": "getFilter",
        "class": "OCA\\Activity\\Controller\\APIv2Controller",
        "type": "->",
        "args": [
          "all",
          0,
          50,
          true,
          "",
          0,
          "desc"
        ]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 137,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          [
            "OCA\\Activity\\Controller\\APIv2Controller"
          ],
          "getFilter"
        ]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/App.php",
        "line": 184,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          [
            "OCA\\Activity\\Controller\\APIv2Controller"
          ],
          "getFilter"
        ]
      },
      {
        "file": "/var/www/html/lib/private/Route/Router.php",
        "line": 315,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::",
        "args": [
          "OCA\\Activity\\Controller\\APIv2Controller",
          "getFilter",
          [
            "OC\\AppFramework\\DependencyInjection\\DIContainer"
          ],
          [
            "all",
            "ocs.activity.APIv2.getFilter"
          ]
        ]
      },
      {
        "file": "/var/www/html/ocs/v1.php",
        "line": 65,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->",
        "args": [
          "/ocsapp/apps/activity/api/v2/activity/all"
        ]
      },
      {
        "file": "/var/www/html/ocs/v2.php",
        "line": 23,
        "args": [
          "/var/www/html/ocs/v1.php"
        ],
        "function": "require_once"
      }
    ],
    "File": "/var/www/html/lib/private/URLGenerator.php",
    "Line": 274,
    "CustomMessage": "Exception thrown: RuntimeException"
  }
}
paulvt commented 6 months ago

Also reported on the forum: https://help.nextcloud.com/t/error-log-image-not-found-image-png-webroot/187094/3

excho0 commented 5 months ago

The code that causes the error:

/var/www/nextcloud/apps/circles/lib/Activity/Provider.php

private function setIcon(IEvent $event): void {
    $path = $this->urlGenerator->imagePath(
        Application::APP_ID,
        'circles.' . $this->activityManager->getRequirePNG() ? 'png' : 'svg'
    );
    $event->setIcon($this->urlGenerator->getAbsoluteURL($path));
}

and here is the fix:

private function setIcon(IEvent $event): void {
    $extension = $this->activityManager->getRequirePNG() ? 'png' : 'svg';
    $path = $this->urlGenerator->imagePath(
        Application::APP_ID,
        'circles.' . $extension
    );
    $event->setIcon($this->urlGenerator->getAbsoluteURL($path));
}

UPDATE:

I was looking in to the source code and It appears that they have already fixed the bug using a different version from the provided fix above. You can either use my version or simply wait for an update. I believe both versions should work. 🤗

joshtrichards commented 4 days ago

Fixed in #1544 / #1620