Server: [SOLVED] Undefined variable: server at Application.php

Created on 21 Jan 2020  路  10Comments  路  Source: nextcloud/server

Steps to reproduce

  1. Install Maps Metadata app via Application Store
  2. Reconnect to admin account

Actual behaviour

"Internal Server Error"
With a request ID
Can't connect to Admin account from Web

    Request ID : XiY4YDa3z@JG6VmVc6ED2QAAAEM
    Type : Exception
    Code : 0
    Message : Call to a member function getContentSecurityPolicyManager() on null
    File : /var/www/nextcloud.com/lib/private/AppFramework/Http/Dispatcher.php
    Line : 109


Trace

#0 /var/www/nextcloud.com/lib/private/AppFramework/App.php(125): OC\AppFramework\Http\Dispatcher->dispatch()
#1 /var/www/nextcloud.com/lib/private/AppFramework/Routing/RouteActionHandler.php(47): OC\AppFramework\App::main()
#2 [internal function]: OC\AppFramework\Routing\RouteActionHandler->__invoke()
#3 /var/www/nextcloud.com/lib/private/Route/Router.php(299): call_user_func()
#4 /var/www/nextcloud.com/lib/base.php(1008): OC\Route\Router->match()
#5 /var/www/nextcloud.com/index.php(38): OC::handleRequest()
#6 {main}

Keep redirecting me to httpx://domain.ltd/index.php/apps/files/
So can't connect.

Temp Fix :
Comment the line 31 from "faulty" Application.php file :
$server->getContentSecurityPolicyManager()->addDefaultPolicy($policy);
And keep Metadata App.
Or remove Metadata App.

Server configuration

Operating system: CentOS 8

Web server: Apache 2.4

Database: MariaDB

PHP version: php -v
PHP 7.4.1 (cli) (built: Dec 17 2019 16:35:58) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.1, Copyright (c), by Zend Technologies

Nextcloud version: NC18

fresh install:

Nextcloud from: Nextcloud.com

List of activated apps:


App list

Enabled:
  - accessibility: 1.4.0
  - activity: 2.11.0
  - cloud_federation_api: 1.1.0
  - comments: 1.8.0
  - dav: 1.14.0
  - federatedfilesharing: 1.8.0
  - federation: 1.8.0
  - files: 1.13.1
  - files_pdfviewer: 1.7.0
  - files_rightclick: 0.15.2
  - files_sharing: 1.10.1
  - files_trashbin: 1.8.0
  - files_versions: 1.11.0
  - files_videoplayer: 1.7.0
  - firstrunwizard: 2.7.0
  - groupfolders: 6.0.0
  - logreader: 2.3.0
  - lookup_server_connector: 1.6.0
  - metadata: 0.11.0
  - nextcloud_announcements: 1.7.0
  - notifications: 2.6.0
  - oauth2: 1.6.0
  - password_policy: 1.8.0
  - photos: 1.0.0
  - privacy: 1.2.0
  - provisioning_api: 1.8.0
  - recommendations: 0.6.0
  - serverinfo: 1.8.0
  - settings: 1.0.0
  - sharebymail: 1.8.0
  - support: 1.1.0
  - survey_client: 1.6.0
  - systemtags: 1.8.0
  - text: 2.0.0
  - theming: 1.9.0
  - twofactor_backupcodes: 1.7.0
  - updatenotification: 1.8.0
  - viewer: 1.2.0
  - workflowengine: 2.0.0
Disabled:
  - admin_audit
  - bruteforcesettings
  - encryption
  - files_external
  - user_ldap

Nextcloud configuration:


Config report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "domain.com"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "18.0.0.10",
        "overwrite.cli.url": "https:\/\/domain.com",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "maintenance": false,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_smtpsecure": "tls",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "logtimezone": "Europe\/Paris",
        "date.timezone": "Europe\/Paris"
    }
}

Are you using external storage, if yes which one: No

Are you using encryption: no

Client configuration

Browser: Firefox/68.0

Operating system: W10

Logs

Nextcloud log (data/nextcloud.log)


Nextcloud log

{
    "reqId": "XiYxytR-FMFQQa1sF0oW3AAAAIk",
    "level": 3,
    "time": "2020-01-21T00:03:38+01:00",
    "remoteAddr": "1.1.1.1",
    "user": "skip",
    "app": "PHP",
    "method": "GET",
    "url": "/index.php/apps/files/",
    "message": "Undefined variable: server at /var/www/nextcloud.com/apps/metadata/lib/AppInfo/Application.php#31",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0",
    "version": "18.0.0.10"
}


{
    "reqId": "XiYxytR-FMFQQa1sF0oW3AAAAIk",
    "level": 3,
    "time": "2020-01-21T00:03:38+01:00",
    "remoteAddr": "1.1.1.1",
    "user": "skip",
    "app": "index",
    "method": "GET",
    "url": "/index.php/apps/files/",
    "message": {
        "Exception": "Exception",
        "Message": "Call to a member function getContentSecurityPolicyManager() on null",
        "Code": 0,
        "Trace": [
            {
                "file": "/var/www/nextcloud.com/lib/private/AppFramework/App.php",
                "line": 125,
                "function": "dispatch",
                "class": "OC\\AppFramework\\Http\\Dispatcher",
                "type": "->"
            },
            {
                "file": "/var/www/nextcloud.com/lib/private/AppFramework/Routing/RouteActionHandler.php",
                "line": 47,
                "function": "main",
                "class": "OC\\AppFramework\\App",
                "type": "::"
            },
            {
                "function": "__invoke",
                "class": "OC\\AppFramework\\Routing\\RouteActionHandler",
                "type": "->"
            },
            {
                "file": "/var/www/nextcloud.com/lib/private/Route/Router.php",
                "line": 299,
                "function": "call_user_func"
            },
            {
                "file": "/var/www/nextcloud.com/lib/base.php",
                "line": 1008,
                "function": "match",
                "class": "OC\\Route\\Router",
                "type": "->"
            },
            {
                "file": "/var/www/nextcloud.com/index.php",
                "line": 38,
                "function": "handleRequest",
                "class": "OC",
                "type": "::"
            }
        ],
        "File": "/var/www/nextcloud.com/lib/private/AppFramework/Http/Dispatcher.php",
        "Line": 109,
        "Previous": {
            "Exception": "Error",
            "Message": "Call to a member function getContentSecurityPolicyManager() on null",
            "Code": 0,
            "Trace": [
                {
                    "file": "/var/www/nextcloud.com/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
                    "line": 247,
                    "function": "OCA\\Metadata\\AppInfo\\{closure}",
                    "class": "OCA\\Metadata\\AppInfo\\Application",
                    "type": "->",
                    "args": [
                        "*** sensitive parameters replaced ***"
                    ]
                },
                {
                    "file": "/var/www/nextcloud.com/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
                    "line": 73,
                    "function": "callListeners",
                    "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/lib/private/EventDispatcher/EventDispatcher.php",
                    "line": 80,
                    "function": "dispatch",
                    "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/lib/private/EventDispatcher/SymfonyAdapter.php",
                    "line": 63,
                    "function": "dispatch",
                    "class": "OC\\EventDispatcher\\EventDispatcher",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/apps/files/lib/Listener/LegacyLoadAdditionalScriptsAdapter.php",
                    "line": 51,
                    "function": "dispatch",
                    "class": "OC\\EventDispatcher\\SymfonyAdapter",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/lib/private/EventDispatcher/ServiceEventListener.php",
                    "line": 76,
                    "function": "handle",
                    "class": "OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
                    "line": 247,
                    "function": "__invoke",
                    "class": "OC\\EventDispatcher\\ServiceEventListener",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
                    "line": 73,
                    "function": "callListeners",
                    "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/lib/private/EventDispatcher/EventDispatcher.php",
                    "line": 80,
                    "function": "dispatch",
                    "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/lib/private/EventDispatcher/SymfonyAdapter.php",
                    "line": 63,
                    "function": "dispatch",
                    "class": "OC\\EventDispatcher\\EventDispatcher",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/apps/files_sharing/list.php",
                    "line": 44,
                    "function": "dispatch",
                    "class": "OC\\EventDispatcher\\SymfonyAdapter",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/apps/files/lib/Controller/ViewController.php",
                    "line": 121,
                    "args": [
                        "/var/www/nextcloud.com/apps/files_sharing/list.php"
                    ],
                    "function": "include"
                },
                {
                    "file": "/var/www/nextcloud.com/apps/files/lib/Controller/ViewController.php",
                    "line": 259,
                    "function": "renderScript",
                    "class": "OCA\\Files\\Controller\\ViewController",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/lib/private/AppFramework/Http/Dispatcher.php",
                    "line": 170,
                    "function": "index",
                    "class": "OCA\\Files\\Controller\\ViewController",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/lib/private/AppFramework/Http/Dispatcher.php",
                    "line": 99,
                    "function": "executeController",
                    "class": "OC\\AppFramework\\Http\\Dispatcher",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/lib/private/AppFramework/App.php",
                    "line": 125,
                    "function": "dispatch",
                    "class": "OC\\AppFramework\\Http\\Dispatcher",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/lib/private/AppFramework/Routing/RouteActionHandler.php",
                    "line": 47,
                    "function": "main",
                    "class": "OC\\AppFramework\\App",
                    "type": "::"
                },
                {
                    "function": "__invoke",
                    "class": "OC\\AppFramework\\Routing\\RouteActionHandler",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/lib/private/Route/Router.php",
                    "line": 299,
                    "function": "call_user_func"
                },
                {
                    "file": "/var/www/nextcloud.com/lib/base.php",
                    "line": 1008,
                    "function": "match",
                    "class": "OC\\Route\\Router",
                    "type": "->"
                },
                {
                    "file": "/var/www/nextcloud.com/index.php",
                    "line": 38,
                    "function": "handleRequest",
                    "class": "OC",
                    "type": "::"
                }
            ],
            "File": "/var/www/nextcloud.com/apps/metadata/lib/AppInfo/Application.php",
            "Line": 31
        },
        "CustomMessage": "--"
    },
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0",
    "version": "18.0.0.10"
}

0. Needs triage bug

Most helpful comment

I get the error:

  Error    index              Exception: Call to a member function getContentSecurityPolicyManager() on null at lib/private/AppFramework/Http/Dispatcher.php line 109                                                            2020-01-21T00:22:59-05:00

                              0. lib/private/AppFramework/App.php line 126
                                 OC\AppFramework\Http\Dispatcher->dispatch(OCA\Files\Controller\ViewController {}, "index")
                              1. lib/private/AppFramework/Routing/RouteActionHandler.php line 47
                                 OC\AppFramework\App::main("OCA\\Files\\Controller\\ViewController", "index", OC\AppFramework\DependencyInjection\DIContainer {}, {_route:"files.view.index"})
                              2. <<closure>>
                                 OC\AppFramework\Routing\RouteActionHandler->__invoke({_route:"files.view.index"})
                              3. lib/private/Route/Router.php line 297
                                 call_user_func(OC\AppFramework\Routing\RouteActionHandler {}, {_route:"files.view.index"})
                              4. lib/base.php line 997
                                 OC\Route\Router->match("\/apps\/files\/")
                              5. index.php line 42
                                 OC::handleRequest(

                                 )

  Error    PHP                Undefined variable: server at /apps2/metadata/lib/AppInfo/Application.php#31 

when the plugin Metadata is enabled, on NC17. Disabling it makes it work again. The error only shows up on the "Files" view. I don't have the Maps plugin installed, never had it installed.
Maybe that helps.

All 10 comments

yes, same here. Only difference, I manually installed the Maps release file, first disabling then enabling the app. Problem persists with maps removed.

NC: 17

Server configuration
Operating system: Debian Testing

Web server: nginx/1.16.1

Database: MariaDB

PHP version: php -v
PHP 7.3.13-1+0~20191218.50+debian10~1.gbp23c2da (cli) (built: Dec 18 2019 15:00:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.13, Copyright (c) 1998-2018 Zend Technologies

Hmm, could it be that it is correlation rather than cause? I upgraded to NC18 final and also tried to upgrade maps (which failed) around the same time, since both had upgrades. But now I have completely removed maps and the problem persists. Couldn't find anything in the logfiles that helped.

Ubuntu LTS (bionic beaver) with PHP 7.2.4 and apache/php-fpm combo.

I'm experiencing the same error, accept mine occurred simply after logging out. All of a sudden I was not able to log back in.

CentOS 7
PHP 7.3.13
Apache (httpd) 2.4.6

I get the error:

  Error    index              Exception: Call to a member function getContentSecurityPolicyManager() on null at lib/private/AppFramework/Http/Dispatcher.php line 109                                                            2020-01-21T00:22:59-05:00

                              0. lib/private/AppFramework/App.php line 126
                                 OC\AppFramework\Http\Dispatcher->dispatch(OCA\Files\Controller\ViewController {}, "index")
                              1. lib/private/AppFramework/Routing/RouteActionHandler.php line 47
                                 OC\AppFramework\App::main("OCA\\Files\\Controller\\ViewController", "index", OC\AppFramework\DependencyInjection\DIContainer {}, {_route:"files.view.index"})
                              2. <<closure>>
                                 OC\AppFramework\Routing\RouteActionHandler->__invoke({_route:"files.view.index"})
                              3. lib/private/Route/Router.php line 297
                                 call_user_func(OC\AppFramework\Routing\RouteActionHandler {}, {_route:"files.view.index"})
                              4. lib/base.php line 997
                                 OC\Route\Router->match("\/apps\/files\/")
                              5. index.php line 42
                                 OC::handleRequest(

                                 )

  Error    PHP                Undefined variable: server at /apps2/metadata/lib/AppInfo/Application.php#31 

when the plugin Metadata is enabled, on NC17. Disabling it makes it work again. The error only shows up on the "Files" view. I don't have the Maps plugin installed, never had it installed.
Maybe that helps.

@kammerjaeger The Metadata app was also the cause for me. After disabling everything is back to normal. Nice find :)

Thanks, @kammerjaeger that was it. Metadata breaks the Filemanager.`
https://github.com/gino0631/nextcloud-metadata/issues/49

[index] Error: Exception: Call to a member function getContentSecurityPolicyManager() on null at <<closure>>

0. /var/www/nextcloud/lib/private/AppFramework/App.php line 125
   OC\AppFramework\Http\Dispatcher->dispatch(OCA\Files\Controller\ViewController {}, "index")
1. /var/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php line 47
   OC\AppFramework\App::main("OCA\\Files\\Controller\\ViewController", "index", OC\AppFramework\ ... {}, {_route: "files.view.index"})
2. <<closure>>
   OC\AppFramework\Routing\RouteActionHandler->__invoke({_route: "files.view.index"})
3. /var/www/nextcloud/lib/private/Route/Router.php line 299
   call_user_func(OC\AppFramework\ ... {}, {_route: "files.view.index"})
4. /var/www/nextcloud/lib/base.php line 1008
   OC\Route\Router->match("/apps/files/")
5. /var/www/nextcloud/index.php line 38
   OC::handleRequest()

GET /apps/files/
from 2003:f9:5706:f900:28d3:f94:16f9:5707 by larsNC at 2020-01-21T06:55:49+00:00

You are right guys, I've installed Metadata, then installed Maps. Issue occurred only after the last one, so I though it was the issue.
After removing that app, I can safely restore application.php line 31.

Updating Metadata to 0.11.1 (available since 2h: https://github.com/gino0631/nextcloud-metadata/issues/49#issuecomment-576649977) fixed this for me.
Thank you <3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mama21mama picture mama21mama  路  3Comments

dl5rcw picture dl5rcw  路  3Comments

williambargent picture williambargent  路  3Comments

ThomasLeister picture ThomasLeister  路  3Comments

ghost picture ghost  路  3Comments