TemplateResponse don't accept integer key after upgrade to nc 32

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 32.0.3
  • Operating system and version (e.g., Ubuntu 24.04):
    • debian trixie
  • Web server and version (e.g, Apache 2.4.25):
    • apache 2.4.65-2
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • -
  • PHP version (e.g, 8.3):
    • 8.4
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • after update from 31.0.9 yesterday
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • a virtual maschine (kvm)
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

TemplateResponse don’t accept integer key after upgrade to nc 32.

Steps to replicate it (hint: details matter!):

  1. write a app with an array have interger keys. i. e.
    $alle = $this->service->efindall() ;
    $myarray = json_decode(json_encode($alle), true);
    array_multisort($edate, SORT_DESC, $myarray);
    return new TemplateResponse(‘myapp1’, ‘rufmich’, $myarray );

  2. fill a mysql-source to efindall() with multiple rows and columns (once with ‘edate’)

  3. test the app in nc 31.0.9 - all will work fine

  4. test the same app with nc 32.0.3 - internal server error “Argument #1 ($key) must be of type string, int given

Log entries

Nextcloud

{"reqId":"mIPoIHGONhHENqwgqwxJ","level":3,"time":"2025-12-16T13:14:25+00:00","remoteAddr":"X.Y.Z.A","user":"XXXXX","app":"index","method":"GET","url":"/nextcloud/index.php/apps/myapp1/rufmich","message":"OC\\Template\\Base::assign(): Argument #1 ($key) must be of type string, int given, called in /var/www/nextcloud/lib/public/AppFramework/Http/TemplateResponse.php on line 192","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0","version":"32.0.3.2","exception":{"Exception":"TypeError","Message":"OC\\Template\\Base::assign(): Argument #1 ($key) must be of type string, int given, called in /var/www/nextcloud/lib/public/AppFramework/Http/TemplateResponse.php on line 192","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/public/AppFramework/Http/TemplateResponse.php","line":192,"function":"assign","class":"OC\\Template\\Base","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":163,"function":"render","class":"OCP\\AppFramework\\Http\\TemplateResponse","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":153,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":321,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":1061,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/nextcloud/index.php","line":25,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/nextcloud/lib/private/Template/Base.php","Line":78,"message":"OC\\Template\\Base::assign(): Argument #1 ($key) must be of type string, int given, called in /var/www/nextcloud/lib/public/AppFramework/Http/TemplateResponse.php on line 192","exception":{},"CustomMessage":"OC\\Template\\Base::assign(): Argument #1 ($key) must be of type string, int given, called in /var/www/nextcloud/lib/public/AppFramework/Http/TemplateResponse.php on line 192"}}

Configuration

Nextcloud

The output of occ config:list system

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "overwrite.cli.url":"***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "32.0.3.2",
        "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": [],
        "updater.secret": "***REMOVED SENSITIVE VALUE***"
    }
}

Apps

Enabled:

  • activity: 5.0.0-dev.0
  • admin_audit: 1.22.0
  • app_api: 32.0.0
  • bruteforcesettings: 5.0.0-dev.0
  • calendar: 6.1.1
  • circles: 32.0.0
  • cloud_federation_api: 1.16.0
  • comments: 1.22.0
  • contacts: 8.1.1
  • contactsinteraction: 1.13.1
  • dav: 1.34.2
  • dienste: 0.0.3
  • event_update_notification: 2.7.0
  • federatedfilesharing: 1.22.0
  • files: 2.4.0
  • files_downloadlimit: 5.0.0-dev.0
  • files_pdfviewer: 5.0.0-dev.0
  • files_reminders: 1.5.0
  • files_sharing: 1.24.1
  • files_trashbin: 1.22.0
  • files_versions: 1.25.0
  • firstrunwizard: 5.0.0-dev.0
  • forms: 5.2.3
  • logreader: 5.0.0-dev.0
  • lookup_server_connector: 1.20.0
  • mail: 5.6.4
  • nextcloud_announcements: 4.0.0-dev.0
  • notes: 4.12.4
  • notifications: 5.0.0-dev.0
  • oauth2: 1.20.0
  • password_policy: 4.0.0-dev.0
  • personenbogen: 0.0.8
  • photos: 5.0.0-dev.1
  • polls: 8.5.0
  • privacy: 4.0.0-dev.0
  • profile: 1.1.0
  • provisioning_api: 1.22.0
  • qownnotesapi: 25.8.0
  • recommendations: 5.0.0-dev.0
  • richdocuments: 9.0.2
  • richdocumentscode: 25.4.702
  • serverinfo: 4.0.0-dev.0
  • settings: 1.15.1
  • sharebymail: 1.22.0
  • spreed: 22.0.6
  • statistik: 0.0.1
  • support: 4.0.0-dev.0
  • survey_client: 4.0.0-dev.0
  • systemtags: 1.22.0
  • tasks: 0.17.1
  • text: 6.0.1
  • theming: 2.7.0
  • timemanager: 0.3.19
  • twofactor_backupcodes: 1.21.0
  • twofactor_totp: 14.0.0
  • updatenotification: 1.22.0
  • user_ldap: 1.23.0
  • user_status: 1.12.0
  • viewer: 5.0.0-dev.0
  • weather_status: 1.12.0
  • webhook_listeners: 1.3.0
  • workflowengine: 2.14.0

On nc 31.0.12 all works fine too. Only in 32 the error is seen.

I found a workarround. Two lines must comment out:

In
lib/public/AppFramework/Http/TemplateResponse.php
and
lib/private/Template/Template.php

/* declare(strict_types=1); */

I know, that is only a quick and dirty solution. Eventually is better in

lib/private/Template/Template.php line 119

$pageassign($key, $value); change to $pageassign(strval($key), $value);

and in lib/public/AppFramework/Http/TemplateResponse.php line 192

$templateassign($key, $value); change to $templateassign(strval($key), $value);

Then the strict_type-setting can stay in original way. After change this two lines all my apps works fine again.