My app doesn't work with PHP7.3

Hello everyone :slight_smile:

I coded an app for nextcloud and it depends on the Groupfolders app.

I coded with Nextcloud 21 with PHP 7.4 and it worked.

When I install with PHP7.3 and Nextcloud 20 or 21. I get this error message from nextcloud.log :eyes: :

{
  "reqId":"uFaMt4OIsZlcpqsJXOSL",
  "level":3,
  "time":"2021-11-17T14:14:12+00:00",
  "remoteAddr":"172.19.0.1",
  "user":"admin",
  "app":"index",
  "method":"GET",
  "url":"/apps/workspace/spaces",
  "message":{
    "Exception":"TypeError",
    "Message":"Return value of OC\\AppFramework\\Middleware\\MiddlewareDispatcher::afterException() must be an instance of OCP\\AppFramework\\Http\\Response, null returned",
    "Code":0,
    "Trace":[
      {
        "file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line":108,
        "function":"afterException",
        "class":"OC\\AppFramework\\Middleware\\MiddlewareDispatcher",
        "type":"->",
        "args":[
          {
            "__class__":"OCA\\Workspace\\Controller\\WorkspaceController"
          },
          "findAll",
          {
            "__class__":"OCP\\Http\\Client\\LocalServerException"
          }
        ]
      },
      {
        "file":"/var/www/html/lib/private/AppFramework/App.php",
        "line":152,
        "function":"dispatch",
        "class":"OC\\AppFramework\\Http\\Dispatcher",
        "type":"->",
        "args":[
          {
            "__class__":"OCA\\Workspace\\Controller\\WorkspaceController"
          },
          "findAll"
        ]
      },
      {
        "file":"/var/www/html/lib/private/Route/Router.php",
        "line":309,
        "function":"main",
        "class":"OC\\AppFramework\\App",
        "type":"::",
        "args":[
          "OCA\\Workspace\\Controller\\WorkspaceController",
          "findAll",
          {
            "__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"
          },
          {
            "_route":"workspace.workspace.findAll"
          }
        ]
      },
      {
        "file":"/var/www/html/lib/base.php",
        "line":1008,
        "function":"match",
        "class":"OC\\Route\\Router",
        "type":"->",
        "args":[
          "/apps/workspace/spaces"
        ]
      },
      {
        "file":"/var/www/html/index.php",
        "line":37,
        "function":"handleRequest",
        "class":"OC",
        "type":"::",
        "args":[
          
        ]
      }
    ],
    "File":"/var/www/html/lib/private/AppFramework/Middleware/MiddlewareDispatcher.php",
    "Line":122,
    "CustomMessage":"--"
  },
  "userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0",
  "version":"20.0.14.2"
}

I think the problem is in this function :

<?php
// GroupfolderService.php
    public function getAll() {
            $response = $this->httpClient->get(
            $this->urlGenerator->getBaseUrl() . '/index.php/apps/groupfolders/folders',
            [
                'auth' => [
                    $this->login->getUID(),
                    $this->login->getPassword()
                ],
                'headers' => self::HEADERS
            ]
        );

        $response = json_decode($response->getBody(), true);

	return $response['ocs']['data'];

    }

The problem is in line with $response = $this->httpClient->get()$this->httpClient is the IClient Interface.

Do you have one idea of this problem ?

Thank you in advance :pray:

Sorry i do not have a solution.
But because of PHP 7.3 i think you use actually Debian Buster. Is this correct?
Perhaps you can dist-upgrate to Debian Bullseye with PHP 7.4 to solve your problem.

Thanks for your answer :slight_smile:

I don’t know if the server is a Debian Buster or a Ubuntu distro. The server belong to my customer and he cannot upgrade the PHP. Otherwise, he lost the support by service provider.

I think it is not an Ubuntu server because your provider gives you normally a LTS version.

Ubuntu 18.04 LTS PHP 7.2
Ubuntu 20.04 LTS PHP 7.4
Debian Buster PHP 7.3
Debian Bullseye PHP 7.4

Do you have a VPS or only a web space?
With VPS you can perhaps upägrade to a newer linux version.
On web space you can sometimes change the php version in the settings.

Your conroller method doesn’t return a response object but some raw array. Maybe wrap this in a JSONResponse?