nextcloud / nextcloud/server

[Bug]: using integer-values as key in TemplateResponse

Open
#59,457 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 33-feedback bug
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
Bug description

In old releases it was possible to using integer-values as key in TemplateResponse. Since some version it is impossible, but it is a very needed feature.

Steps to reproduce

1.create an multiple array and sort it with array_multisort
array_multisort($mysort, SORT_DESC, $myarray);

  1. use this array caling TemplateResponse
    return new TemplateResponse('myapp', 'mysite', $myarray );
Expected behavior

working without error

Nextcloud Server version

33

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.4

Web server

Apache (supported)

Database engine version

MariaDB

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

Upgraded to a MAJOR version (ex. 31 to 32)

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report
{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "aoo.arch.tu-dresden.de"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "overwrite.cli.url": "https:\/\/aoo.arch.tu-dresden.de\/nextcloud",
        "dbtype": "mysql",
        "version": "33.0.0.16",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "ldapIgnoreNamingRules": false,
        "ldapProviderFactory": "\\OCA\\User_LDAP\\LDAPProviderFactory",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "sendmail",
        "mail_smtpauthtype": "PLAIN",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "theme": "",
        "loglevel": 0,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "mail_smtpsecure": "ssl",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpauth": 1,
        "skeletondirectory": "\/var\/nextcloud_defaultfiles",
        "share_folder": "\/",
        "default_language": "de",
        "app_install_overwrite": [
            "calendar",
            "groupfolders",
            "spreed",
            "mindmaps",
            "dashboard",
            "ownpad",
            "admin_notifications",
            "personenbogen",
            "dienste",
            "apporder",
            "statistik"
        ],
        "encryption.key_storage_migrated": false,
        "mysql.utf8mb4": true,
        "default_phone_region": "DE",
        "maintenance": false,
        "lost_password_link": "disabled",
        "trashbin_retention_obligation": "14",
        "defaultapp": "dienste,calendar,personenbogen",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "maintenance_window_start": "1",
        "default_locale": "de_DE",
        "opcache.interned_strings_buffer": "16",
        "twofactor_enforced": "true",
        "twofactor_enforced_groups": [],
        "twofactor_enforced_excluded_groups": [],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***"
    }
}
List of activated Apps
Enabled:
  - activity: 6.0.0-dev.0
  - admin_audit: 1.23.0
  - app_api: 33.0.0
  - bruteforcesettings: 6.0.0-dev.0
  - calendar: 6.2.1
  - circles: 33.0.0
  - cloud_federation_api: 1.17.0
  - comments: 1.23.0
  - contacts: 8.4.2
  - contactsinteraction: 1.14.1
  - dav: 1.36.0
  - dienste: 0.0.3
  - event_update_notification: 2.8.0
  - federatedfilesharing: 1.23.0
  - files: 2.5.0
  - files_downloadlimit: 5.1.0-dev.0
  - files_pdfviewer: 6.0.0-dev.0
  - files_reminders: 1.6.0
  - files_sharing: 1.25.2
  - files_trashbin: 1.23.0
  - files_versions: 1.26.0
  - firstrunwizard: 6.0.0-dev.0
  - forms: 5.2.5
  - logreader: 6.0.0
  - lookup_server_connector: 1.21.0
  - mail: 5.7.5
  - nextcloud_announcements: 5.0.0
  - notes: 4.13.1
  - notifications: 6.0.0
  - notify_push: 1.3.1
  - oauth2: 1.21.0
  - password_policy: 5.0.0-dev.0
  - personenbogen: 0.0.8
  - photos: 6.0.0-dev.0
  - polls: 8.6.3
  - privacy: 5.0.0-dev.0
  - profile: 1.2.0
  - provisioning_api: 1.23.0
  - qownnotesapi: 26.2.2
  - recommendations: 6.0.0-dev.0
  - richdocuments: 10.1.2
  - richdocumentscode: 25.4.904
  - serverinfo: 5.0.0-dev.0
  - settings: 1.16.0
  - sharebymail: 1.23.0
  - spreed: 23.0.2
  - statistik: 0.0.1
  - support: 5.0.0
  - survey_client: 5.0.0-dev.0
  - systemtags: 1.23.0
  - tasks: 0.17.1
  - text: 7.0.0-dev.3
  - theming: 2.8.0
  - timemanager: 0.3.23
  - twofactor_backupcodes: 1.22.0
  - twofactor_totp: 15.0.0-dev.0
  - updatenotification: 1.23.0
  - user_ldap: 1.24.0
  - user_status: 1.13.0
  - viewer: 6.0.0-dev.0
  - weather_status: 1.13.0
  - webhook_listeners: 1.5.0
  - workflowengine: 2.15.0
Disabled:
  - appointments: 2.6.3 (installed 2.6.3)
  - apporder: 0.15.0 (installed 0.15.0)
  - camerarawpreviews: 0.8.8 (installed 0.8.8)
  - dashboard: 7.13.0 (installed 6.0.0)
  - deck: 1.16.3 (installed 1.16.3)
  - documentserver_community: 0.2.1 (installed 0.2.1)
  - drawio: 4.1.4 (installed 4.1.4)
  - encryption: 2.21.0 (installed 2.2.0)
  - end_to_end_encryption: 1.18.2 (installed 1.18.2)
  - federation: 1.23.0 (installed 1.6.0)
  - files_accesscontrol: 3.0.2 (installed 3.0.2)
  - files_external: 1.25.1
  - files_retention: 3.0.0 (installed 3.0.0)
  - files_rightclick: 0.15.1 (installed 1.6.0)
  - files_trackdownloads: 1.11.0 (installed 1.11.0)
  - groupfolders: 20.1.12 (installed 20.1.12)
  - mindmaps: 0.1.0 (installed 0.1.0)
  - notestutorial: 17.0.0
  - onlyoffice: 9.13.0 (installed 9.13.0)
  - ownpad: 0.13.2 (installed 0.13.2)
  - related_resources: 4.0.0-dev.0 (installed 1.0.3)
  - socialsharing_telegram: 4.0.1 (installed 4.0.1)
  - suspicious_login: 11.0.0-dev.0
  - timetracker: 0.0.86 (installed 0.0.86)
  - twofactor_nextcloud_notification: 7.0.0
  - user_usage_report: 3.0.0 (installed 3.0.0)
  - workflow_pdf_converter: 3.0.0 (installed 3.0.0)
Nextcloud Signing status

Nextcloud Logs

Additional info

It can be bring back by a little patch:


--- nextcloud/lib/private/Template/Template.php
+++ nextcloud/lib/private/Template/Template.php
@@ -116,7 +116,7 @@
 
                        if (is_array($additionalParams)) {
                                foreach ($additionalParams as $key => $value) {
-                                       $page->assign($key, $value);
+                                       $page->assign(strval($key), $value);
                                }
                        }
 
--- nextcloud/lib/public/AppFramework/Http/TemplateResponse.php
+++ nextcloud/lib/public/AppFramework/Http/TemplateResponse.php
@@ -189,7 +189,7 @@
                $template = Server::get(ITemplateManager::class)->getTemplate($this->appName, $this->templateName, $renderAs);
 
                foreach ($this->params as $key => $value) {
-                       $template->assign($key, $value);
+                       $template->assign(strval($key), $value);
                }
 
                return $template->fetchPage($this->params);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/private/Template/Template.php and lib/public/AppFramework/Http/TemplateResponse.php, focusing on how TemplateResponse passes parameters to the template. Reproduce the issue with an array sorted by array_multisort and integer keys, then verify that rendering completes without an error and preserves the supplied values.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.