nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
26.21k stars 3.95k forks source link

[Bug]: [PHP] Error: Array to string conversion at /usr/share/nginx/nextcloud/lib/private/App/DependencyAnalyzer.php#398 #45648

Open corsairius opened 1 month ago

corsairius commented 1 month ago

⚠️ This issue respects the following points: ⚠️

Bug description

Changing to the Apps section from the user icon (admin enabled) caused an error to be logged into the Nextcloud error log.

Steps to reproduce

  1. Select Apps from User icon.

Expected behavior

No error.

Installation method

None

Nextcloud Server version

29

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.2

Web server

Nginx

Database engine version

PostgreSQL

Is this bug present after an update or on a fresh install?

Upgraded to a MAJOR version (ex. 22 to 23)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "xxx",
            "xxx",
            "xxx",
            "xxx"
        ],
        "loglevel": 1,
        "session_lifetime": 86400,
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "29.0.1.1",
        "overwrite.cli.url": "xxx",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "5433",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "enable_previews": true,
        "enabledPreviewProviders": [
            "OC\\Preview\\PNG",
            "OC\\Preview\\JPEG",
            "OC\\Preview\\JPG",
            "OC\\Preview\\GIF",
            "OC\\Preview\\BMP",
            "OC\\Preview\\XBitmap",
            "OC\\Preview\\Movie",
            "OC\\Preview\\PDF",
            "OC\\Preview\\MP3",
            "OC\\Preview\\TXT",
            "OC\\Preview\\MarkDown",
            "OC\\Preview\\MP4",
            "OC\\Preview\\MOV",
            "OC\\Preview\\Image",
            "OC\\Preview\\Photoshop",
            "OC\\Preview\\TIFF",
            "OC\\Preview\\SVG",
            "OC\\Preview\\HEIC",
            "OC\\Preview\\TIFF",
            "OC\\Preview\\EMF",
            "OCA\\Richdocuments\\Preview\\EMF"
        ],
        "htaccess.RewriteBase": "\/",
        "installed": true,
        "mail_smtpmode": "smtp",
        "mail_smtpsecure": "tls",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "US",
        "maintenance": false,
        "preview_max_x": 512,
        "preview_max_y": 512,
        "jpeg_quality": 60,
        "theme": "",
        "updater.release.channel": "stable",
        "app_install_overwrite": [
            "facerecognition",
            "files_external_ipfs",
            "duplicatefinder",
            "caniupdate"
        ],
        "memories.exiftool": "\/usr\/share\/nginx\/nextcloud\/apps\/memories\/bin-ext\/exiftool-amd64-glibc",
        "memories.vod.path": "\/usr\/share\/nginx\/nextcloud\/apps\/memories\/bin-ext\/go-vod-amd64",
        "memories.index.path.blacklist": "\\\/(@(Recycle|eaDir|Notes( \\([0-9]+\\)*))|Notes( \\([0-9]+\\))*)\\\/",
        "memories.index.mode": "3",
        "memories.vod.ffmpeg": "\/usr\/bin\/ffmpeg",
        "memories.vod.ffprobe": "\/usr\/bin\/ffprobe",
        "memories.exiftool_no_local": true,
        "memories.db.triggers.fcu": true,
        "preview_max_memory": 4096,
        "preview_max_filesize_image": 256,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "filelocking.enabled": true,
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "timeout": 0
        },
        "maintenance_window_start": 100
    }
}

List of activated Apps

root:/usr/share/nginx/nextcloud# sudo -u www-data php occ app:list
Enabled:
  - activity: 2.21.1
  - app_api: 2.6.0
  - assistant: 1.0.9
  - bruteforcesettings: 2.9.0
  - calendar: 4.7.4
  - cloud_federation_api: 1.12.0
  - comments: 1.19.0
  - contacts: 6.0.0
  - contactsinteraction: 1.10.0
  - dashboard: 7.9.0
  - dav: 1.30.1
  - deck: 1.13.0
  - external: 5.4.0
  - externalportal: 1.3.0
  - facerecognition: 0.9.50
  - federatedfilesharing: 1.19.0
  - federation: 1.19.0
  - files: 2.1.0
  - files_downloadlimit: 2.0.0
  - files_external: 1.21.0
  - files_pdfviewer: 2.10.0
  - files_reminders: 1.2.0
  - files_sharing: 1.21.0
  - files_trashbin: 1.19.0
  - files_versions: 1.22.0
  - firstrunwizard: 2.18.0
  - groupfolders: 17.0.0
  - logreader: 2.14.0
  - lookup_server_connector: 1.17.0
  - mail: 3.6.1
  - memories: 7.3.1
  - nextcloud_announcements: 1.18.0
  - notes: 4.10.0
  - notifications: 2.17.0
  - oauth2: 1.17.0
  - password_policy: 1.19.0
  - photos: 2.5.0
  - previewgenerator: 5.5.0
  - privacy: 1.13.0
  - provisioning_api: 1.19.0
  - recognize: 7.0.0
  - recommendations: 2.1.0
  - related_resources: 1.4.0
  - richdocuments: 8.4.2
  - richdocumentscode: 24.4.201
  - serverinfo: 1.19.0
  - settings: 1.12.0
  - sharebymail: 1.19.0
  - spreed: 19.0.1
  - support: 1.12.0
  - survey_client: 1.17.0
  - systemtags: 1.19.0
  - tasks: 0.16.0
  - text: 3.10.0
  - theming: 2.4.0
  - twofactor_backupcodes: 1.18.0
  - updatenotification: 1.19.1
  - user_status: 1.9.0
  - user_usage_report: 1.13.0
  - viewer: 2.3.0
  - weather_status: 1.9.0
  - workflow_media_converter: 1.11.7
  - workflowengine: 2.11.0
Disabled:
  - admin_audit: 1.19.0
  - circles: 29.0.0-dev (installed 27.0.1)
  - cms_pico: 1.0.21 (installed 1.0.21)
  - context_chat: 2.1.2 (installed 2.1.2)
  - documentserver_community: 0.1.17 (installed 0.1.17)
  - duplicatefinder: 1.1.10 (installed 1.1.10)
  - encryption: 2.17.0
  - files_mindmap: 0.0.30 (installed 0.0.30)
  - maps: 1.4.0 (installed 1.4.0)
  - onlyoffice: 9.2.2 (installed 9.2.2)
  - sensorlogger: 0.1.4
  - stt_helper: 1.1.1 (installed 1.1.1)
  - stt_whisper: 1.0.8 (installed 1.0.8)
  - suspicious_login: 7.0.0 (installed 4.2.1)
  - twofactor_totp: 11.0.0-dev
  - user_ldap: 1.20.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

{"reqId":"7LmMYlh8GAVU6dUUp7j5","level":3,"time":"2024-06-03T19:09:19+00:00","remoteAddr":"xxx","user":"xxx","app":"PHP","method":"GET","url":"/settings/apps/list","message":"Array to string conversion at /usr/share/nginx/nextcloud/lib/private/App/DependencyAnalyzer.php#398","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36","version":"29.0.1.1","data":{"app":"PHP"},"id":"xxx"}

Additional info

No response

joshtrichards commented 1 month ago

Not able to reproduce so far, but I'll leave open while we await other reports.

Any particular section or app profile trigger this for you?

corsairius commented 1 month ago

Just entering the Apps section throws this error.

kesselb commented 1 month ago

Hi,

please apply the following patch to your installation. Then try opening the apps section again and then check your logfile for "array given to DependencyAnalyzer.getValue" and share the complete logline with us.

Index: lib/private/App/DependencyAnalyzer.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/lib/private/App/DependencyAnalyzer.php b/lib/private/App/DependencyAnalyzer.php
--- a/lib/private/App/DependencyAnalyzer.php    (revision 806e390d14123f0bdf9e805bd55553339a0b5d3b)
+++ b/lib/private/App/DependencyAnalyzer.php    (date 1717527159746)
@@ -31,6 +31,7 @@
 namespace OC\App;

 use OCP\IL10N;
+use function OCP\Log\logger;

 class DependencyAnalyzer {
    /** @var array */
@@ -395,6 +396,12 @@
        if (isset($element['@value'])) {
            return $element['@value'];
        }
+       if (is_array($element)) {
+           logger('core')->error('array given to DependencyAnalyzer.getValue', [
+               'element' => $element,
+               'trace' => new \Exception('array given to DependencyAnalyzer.getValue')
+           ]);
+       }
        return (string)$element;
    }
 }
corsairius commented 1 month ago
{"reqId":"WWII5J4EAuEPo2n7Oyod","level":3,"time":"2024-06-05T00:07:34+00:00","remoteAddr":"192.168.64.1","user":"xxx","app":"core","method":"GET","url":"/settings/apps/list","message":"array given to DependencyAnalyzer.getValue","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36","version":"29.0.1.1","data":{"app":"core","element":"{\"min-version\":\"5.7\"}","trace":"{\"class\":\"Exception\",\"message\":\"array given to DependencyAnalyzer.getValue\",\"code\":0,\"file\":\"/usr/share/nginx/nextcloud/lib/private/App/DependencyAnalyzer.php:402\",\"trace\":\"#0 /usr/share/nginx/nextcloud/lib/private/App/DependencyAnalyzer.php(215): OC\\App\\DependencyAnalyzer->getValue()\\n#1 [internal function]: OC\\App\\DependencyAnalyzer->OC\\App\\{closure}()\\n#2 /usr/share/nginx/nextcloud/lib/private/App/DependencyAnalyzer.php(214): array_map()\\n#3 /usr/share/nginx/nextcloud/lib/private/App/DependencyAnalyzer.php(65): OC\\App\\DependencyAnalyzer->analyzeDatabases()\\n#4 /usr/share/nginx/nextcloud/apps/settings/lib/Controller/AppSettingsController.php(348): OC\\App\\DependencyAnalyzer->analyze()\\n#5 [internal function]: OCA\\Settings\\Controller\\AppSettingsController->OCA\\Settings\\Controller\\{closure}()\\n#6 /usr/share/nginx/nextcloud/apps/settings/lib/Controller/AppSettingsController.php(319): array_map()\\n#7 /usr/share/nginx/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(232): OCA\\Settings\\Controller\\AppSettingsController->listApps()\\n#8 /usr/share/nginx/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(138): OC\\AppFramework\\Http\\Dispatcher->executeController()\\n#9 /usr/share/nginx/nextcloud/lib/private/AppFramework/App.php(184): OC\\AppFramework\\Http\\Dispatcher->dispatch()\\n#10 /usr/share/nginx/nextcloud/lib/private/Route/Router.php(338): OC\\AppFramework\\App::main()\\n#11 /usr/share/nginx/nextcloud/lib/base.php(1050): OC\\Route\\Router->match()\\n#12 /usr/share/nginx/nextcloud/index.php(49): OC::handleRequest()\\n#13 {main}\"}"},"id":"665fac57c61b0"}
kesselb commented 1 month ago

Thanks :+1:

Somehow, the min-version definition for a database in info.xml seems to trigger that error.

To loop over all files and find the min-version definitions: grep -i -r "<database min-version=" .

I think it could be the sensorloggers app: https://github.com/search?q=%3Cdatabase+min-version%3D%225.7&type=code

The definition itself looks correct. I'm unsure why it fails here. Maybe because it's only one database definition.

Seems like this block is missing to make it work. However, comparing the min-version for database is not implemented anyway :see_no_evil:

Index: lib/private/App/DependencyAnalyzer.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/lib/private/App/DependencyAnalyzer.php b/lib/private/App/DependencyAnalyzer.php
--- a/lib/private/App/DependencyAnalyzer.php    (revision cac6443cbbc1aadb56e0499b19588386fd0c3cce)
+++ b/lib/private/App/DependencyAnalyzer.php    (date 1717578526379)
@@ -186,6 +186,9 @@
        if (!is_array($supportedDatabases)) {
            $supportedDatabases = [$supportedDatabases];
        }
+       if (isset($supportedDatabases['@value'])) {
+           $supportedDatabases = [$supportedDatabases];
+       }
        $supportedDatabases = array_map(function ($db) {
            return $this->getValue($db);
        }, $supportedDatabases);
corsairius commented 1 month ago
{"reqId":"jd5vyyp43IHt21mElXF9","level":3,"time":"2024-06-05T13:12:46+00:00","remoteAddr":"192.168.64.1","user":"xxx","app":"core","method":"GET","url":"/settings/apps/list","message":"array given to DependencyAnalyzer.getValue","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36","version":"29.0.1.1","data":{"app":"core","element":"{\"min-version\":\"5.7\"}","trace":"{\"class\":\"Exception\",\"message\":\"array given to DependencyAnalyzer.getValue\",\"code\":0,\"file\":\"/usr/share/nginx/nextcloud/lib/private/App/DependencyAnalyzer.php:402\",\"trace\":\"#0 /usr/share/nginx/nextcloud/lib/private/App/DependencyAnalyzer.php(215): OC\\App\\DependencyAnalyzer->getValue()\\n#1 [internal function]: OC\\App\\DependencyAnalyzer->OC\\App\\{closure}()\\n#2 /usr/share/nginx/nextcloud/lib/private/App/DependencyAnalyzer.php(214): array_map()\\n#3 /usr/share/nginx/nextcloud/lib/private/App/DependencyAnalyzer.php(65): OC\\App\\DependencyAnalyzer->analyzeDatabases()\\n#4 /usr/share/nginx/nextcloud/apps/settings/lib/Controller/AppSettingsController.php(348): OC\\App\\DependencyAnalyzer->analyze()\\n#5 [internal function]: OCA\\Settings\\Controller\\AppSettingsController->OCA\\Settings\\Controller\\{closure}()\\n#6 /usr/share/nginx/nextcloud/apps/settings/lib/Controller/AppSettingsController.php(319): array_map()\\n#7 /usr/share/nginx/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(232): OCA\\Settings\\Controller\\AppSettingsController->listApps()\\n#8 /usr/share/nginx/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(138): OC\\AppFramework\\Http\\Dispatcher->executeController()\\n#9 /usr/share/nginx/nextcloud/lib/private/AppFramework/App.php(184): OC\\AppFramework\\Http\\Dispatcher->dispatch()\\n#10 /usr/share/nginx/nextcloud/lib/private/Route/Router.php(338): OC\\AppFramework\\App::main()\\n#11 /usr/share/nginx/nextcloud/lib/base.php(1050): OC\\Route\\Router->match()\\n#12 /usr/share/nginx/nextcloud/index.php(49): OC::handleRequest()\\n#13 {main}\"}"},"id":"666064552b50f"}
{"reqId":"Uq6X5LgJWuQVJJ8mOkzX","level":3,"time":"2024-06-05T13:12:45+00:00","remoteAddr":"192.168.64.1","user":"xxx","app":"PHP","method":"GET","url":"/settings/apps/list","message":"Array to string conversion at /usr/share/nginx/nextcloud/lib/private/App/DependencyAnalyzer.php#405","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36","version":"29.0.1.1","data":{"app":"PHP"},"id":"666064552b522"}
kesselb commented 1 month ago

@corsairius It should work again if you remove the sensorloggers app (if possible with occ or by deleting the folder).

corsairius commented 1 month ago

Removed the sensorloggers from the disabled app list, as well as the others hanging around. Appears corrected. Thanks!