nextcloud / maps

🌍🌏🌎 The whole world fits inside your cloud!
https://apps.nextcloud.com/apps/maps
GNU Affero General Public License v3.0
504 stars 89 forks source link

[Bug]: Wrong variable type in ContactsController.php #1157

Closed EdRoxter closed 11 months ago

EdRoxter commented 1 year ago

⚠️ This issue respects the following points: ⚠️

Bug description

When I place a VCF file with a street address in a map's directory, I get the following error screen: Screenshot_20231104_141840

Long story short, I traced it down to lib/Controller/ContactsController.php:303. The fourth argument to vCardToArray() - i.e. $adrtype - is expected to be a string, but it's converted to an array in this call.

When I replace $result[] = $this->vCardToArray($file, $vcard, $geo, array($adrtype), $adr->getValue(), $file->getId()); with $result[] = $this->vCardToArray($file, $vcard, $geo, $adrtype, $adr->getValue(), $file->getId()); it works just fine.

Steps to reproduce

  1. Create a new map in the Maps app
  2. Open folder
  3. Drag'n'drop a vcf file with an "ADR" record into the folder
  4. Reload Maps app in browser

Expected behavior

Address from VCF contact should just show in the map

Installation method

Manual installation

Operating system

RHEL/CentOS

PHP engine version

Other

Web server

Apache (supported)

Database engine version

MariaDB

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

None

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

Fresh Nextcloud Maps install (never installed before)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

Configuration report

{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "27.1.3.2",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "loglevel": 2,
        "maintenance": false,
        "theme": "",
        "trusted_domains": [
            "***REDACTED***"
        ],
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "sendmail",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trashbin_retention_obligation": "auto",
        "singleuser": false,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "mail_sendmailmode": "smtp",
        "mysql.utf8mb4": true,
        "defaultapp": "snappymail",
        "updater.release.channel": "stable",
        "overwrite.cli.url": "https:\/\/***REDACTED***",
        "default_phone_region": "DE",
        "preview_max_x": 1000,
        "preview_max_y": 1000,
        "debug": false,
        "versions_retention_obligation": "auto, 60",
        "app_install_overwrite": [
            "ocsms"
        ]
    }
}

List of activated Apps

nabled:
  - activity: 2.19.0
  - bruteforcesettings: 2.7.0
  - calendar: 4.5.2
  - cloud_federation_api: 1.10.0
  - contacts: 5.4.2
  - cpanelmailsync: 0.1.7
  - dav: 1.27.0
  - federatedfilesharing: 1.17.0
  - federation: 1.17.0
  - files: 1.22.0
  - files_external: 1.19.0
  - files_pdfviewer: 2.8.0
  - files_reminders: 1.0.0
  - files_rightclick: 1.6.0
  - files_sharing: 1.19.0
  - files_texteditor: 2.15.1
  - files_trashbin: 1.17.0
  - files_versions: 1.20.0
  - logreader: 2.12.0
  - lookup_server_connector: 1.15.0
  - maps: 1.1.1
  - metadata: 0.19.0
  - notes: 4.8.1
  - notifications: 2.15.0
  - oauth2: 1.15.1
  - password_policy: 1.17.0
  - passwords: 2023.10.30
  - photos: 2.3.0
  - privacy: 1.11.0
  - provisioning_api: 1.17.0
  - serverinfo: 1.17.0
  - settings: 1.9.0
  - sharebymail: 1.17.0
  - side_menu: 3.10.3
  - snappymail: 2.29.1
  - tasks: 0.15.0
  - text: 3.8.0
  - theming: 2.2.0
  - twofactor_backupcodes: 1.16.0
  - twofactor_totp: 9.0.0
  - updatenotification: 1.17.0
  - viewer: 2.1.0
  - workflowengine: 2.9.0
Disabled:
  - admin_audit: 1.17.0
  - circles: 27.0.1 (installed 23.0.0)
  - comments: 1.17.0 (installed 1.5.0)
  - contactsinteraction: 1.8.0 (installed 1.6.0)
  - dashboard: 7.7.0 (installed 7.7.0)
  - encryption: 2.15.0 (installed 2.11.0)
  - firstrunwizard: 2.16.0 (installed 2.8.0)
  - nextcloud_announcements: 1.16.0 (installed 1.4.0)
  - recommendations: 1.6.0 (installed 0.4.0)
  - related_resources: 1.2.0 (installed 1.0.4)
  - support: 1.10.0 (installed 1.0.0)
  - survey_client: 1.15.0 (installed 1.3.0)
  - suspicious_login: 5.0.0
  - systemtags: 1.17.0 (installed 1.5.0)
  - user_ldap: 1.17.0
  - user_status: 1.7.0 (installed 1.0.1)
  - weather_status: 1.7.0 (installed 1.0.0)

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

{"reqId":"wgYgGexEuyLJLe3nc8IK","level":3,"time":"2023-11-04T13:18:37+00:00","remoteAddr":"***REDACTED***","user":"***REDACTED***","app":"index","method":"GET","url":"/index.php/apps/maps/contacts?myMapId=361339","message":"OCA\\Maps\\Controller\\ContactsController::vCardToArray(): Argument #4 ($adrtype) must be of type ?string, array given, called in /home/www/nextcloud/apps/maps/lib/Controller/ContactsController.php on line 303 in file '/home/www/nextcloud/apps/maps/lib/Controller/ContactsController.php' line 344","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36","version":"27.1.3.2","exception":{"Exception":"Exception","Message":"OCA\\Maps\\Controller\\ContactsController::vCardToArray(): Argument #4 ($adrtype) must be of type ?string, array given, called in /home/www/nextcloud/apps/maps/lib/Controller/ContactsController.php on line 303 in file '/home/www/nextcloud/apps/maps/lib/Controller/ContactsController.php' line 344","Code":0,"Trace":[{"file":"/home/www/nextcloud/lib/private/AppFramework/App.php","line":183,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/home/www/nextcloud/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/home/www/nextcloud/lib/base.php","line":1068,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/home/www/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/home/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","Line":169,"Previous":{"Exception":"TypeError","Message":"OCA\\Maps\\Controller\\ContactsController::vCardToArray(): Argument #4 ($adrtype) must be of type ?string, array given, called in /home/www/nextcloud/apps/maps/lib/Controller/ContactsController.php on line 303","Code":0,"Trace":[{"file":"/home/www/nextcloud/apps/maps/lib/Controller/ContactsController.php","line":303,"function":"vCardToArray","class":"OCA\\Maps\\Controller\\ContactsController","type":"->"},{"file":"/home/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":230,"function":"getContacts","class":"OCA\\Maps\\Controller\\ContactsController","type":"->"},{"file":"/home/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":137,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/home/www/nextcloud/lib/private/AppFramework/App.php","line":183,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/home/www/nextcloud/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/home/www/nextcloud/lib/base.php","line":1068,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/home/www/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/home/www/nextcloud/apps/maps/lib/Controller/ContactsController.php","Line":344},"CustomMessage":"--"}}

Browser Console

xhr.js:251 
 GET https://***REDACTED***/index.php/apps/maps/contacts?myMapId=361339 500 (Internal Server Error)
(anonymous) @   xhr.js:251
xhr @   xhr.js:49
vt  @   dispatchRequest.js:51
request @   Axios.js:148
De.forEach.kt.<computed>    @   Axios.js:174
(anonymous) @   bind.js:5
(anonymous) @   network.js:52
getContacts @   App.vue:1368
created @   App.vue:622
Fn  @   vue.runtime.esm.js:3017
Aa  @   vue.runtime.esm.js:4031
e._init @   vue.runtime.esm.js:5693
o   @   vue.runtime.esm.js:5826
(anonymous) @   vue.runtime.esm.js:4544
init    @   vue.runtime.esm.js:4406
(anonymous) @   vue.runtime.esm.js:6567
h   @   vue.runtime.esm.js:6521
eo.nodeOps  @   vue.runtime.esm.js:7109
e._update   @   vue.runtime.esm.js:3765
a   @   vue.runtime.esm.js:3875
e.get   @   vue.runtime.esm.js:3446
e   @   vue.runtime.esm.js:3436
e   @   vue.runtime.esm.js:3892
ui.$mount   @   vue.runtime.esm.js:8772
e._init @   vue.runtime.esm.js:5701
ui  @   vue.runtime.esm.js:5762
ec  @   main.js:104
(anonymous) @   optionsController.js:45
Promise.then (async)        
restoreOptions  @   optionsController.js:42
(anonymous) @   main.js:99

Additional info

PHP Version: 8.2.11