You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DirectEditing Manager::getTemplates() crashes when a creator returns ATemplate objects (per interface contract) #64461
From the Nextcloud Android app (v35.0.0), tap "+" → "New document" (or spreadsheet).
App calls GET /ocs/v2.php/apps/files/api/v1/directEditing/templates/richdocuments/document (and /spreadsheet).
Expected behaviour
Template list is returned, template picker opens.
Actual behaviour
500 error, request fails every time, for every creator type (document, spreadsheet — both tested). Exception in nextcloud.log:
Cannot use object of type OCA\Richdocuments\DirectEditing\OfficeTemplate as array in file
'/var/www/html/lib/private/DirectEditing/Manager.php' line 91
This array-mutation code appears unchanged since at least Nextcloud 30 (checked v30.0.0 tag, identical logic), so it silently relied on apps returning raw arrays despite the interface declaring ATemplate[] since 18.0.0. Any app that follows the documented contract literally (as richdocuments now does, after its recent OCP\DirectEditing refactor) breaks this code with a fatal error.
Client: Nextcloud iOS 35.0.0 → "+ → New document"; the same 500 also happens from the web UI "New" menu
Cannot use object of type OCA\Richdocuments\DirectEditing\OfficeTemplate as array in .../lib/private/DirectEditing/Manager.php:91
Trigger condition: it only crashes when the creator actually has templates. Manager::getTemplates() replaces the default ['empty' => ...] with $creator->getTemplates() and then maps over it. When that returns [] (no files in the user's Templates/, no system template directory configured), the array_map callback never runs and nothing fails. As soon as a single template exists, every call to /ocs/v2.php/apps/files/api/v1/directEditing/templates/{editorId}/{creatorId} returns 500.
On my instance some accounts have 25–45 files in Templates/ and fail 100% of the time, while accounts with an empty Templates/ are unaffected — which makes the bug look client- or user-specific.
Still present on master (checked 2026-10-22): Manager.php:91-92 still indexes the elements as arrays, while ACreateFromTemplate::getTemplates() is documented as @return ATemplate[] and richdocuments returns exactly that (AbstractOfficeCreator::getTemplates() → new OfficeTemplate(...)). The app is compliant, the server is the side violating the contract.
The fix in #64494 looks exactly right (object → jsonSerialize(), array path preserved). It has had no review since 2026-09-17 and the backport requests to stable33/34/35 are still unaddressed. Is anything missing to get it merged — e.g. a regression test? Happy to help with a unit test if that is the blocker.
Impact worth noting: besides the template picker being unusable, each failed attempt writes an error to nextcloud.log, which then surfaces in the admin "Errors in the log" setup check — so a pure code defect keeps re-raising a server-health warning.
Nextcloud server 35.0.2.2 (official Docker image nextcloud:35, latest 35.x tag)
richdocuments 12.0.1 (no newer version offered by occ app:update --showonly)
Collabora CODE 26.04.5.2.1
Nextcloud Android app 35.0.1
Request: GET /ocs/v2.php/apps/files/api/v1/directEditing/templates/richdocuments/spreadsheet?format=json
Log: "Cannot use object of type OCA\Richdocuments\DirectEditing\OfficeTemplate as array in file '/var/www/html/lib/private/DirectEditing/Manager.php' line 91"
The app shows "Fout bij ophalen sjablonen" (error fetching templates) when creating a new spreadsheet, both in my own folder and in a Team folder.
Creating the same file type from the web interface works. Opening and saving existing documents also works.
Activity
icewind1991 commentedon Sep 17, 2026
Thanks for the report and finding the root cause, fix is here: #64494
jim-sang commentedon Oct 22, 2026
Independent confirmation on the current stable branch, plus one detail that may explain why this is only reported occasionally.
Reproducible on 35.0.2.2 (not only 34.x)
richdocuments12.0.1 (current latest release)Cannot use object of type OCA\Richdocuments\DirectEditing\OfficeTemplate as array in .../lib/private/DirectEditing/Manager.php:91Trigger condition: it only crashes when the creator actually has templates.
Manager::getTemplates()replaces the default['empty' => ...]with$creator->getTemplates()and then maps over it. When that returns[](no files in the user'sTemplates/, no system template directory configured), thearray_mapcallback never runs and nothing fails. As soon as a single template exists, every call to/ocs/v2.php/apps/files/api/v1/directEditing/templates/{editorId}/{creatorId}returns 500.On my instance some accounts have 25–45 files in
Templates/and fail 100% of the time, while accounts with an emptyTemplates/are unaffected — which makes the bug look client- or user-specific.Still present on master (checked 2026-10-22):
Manager.php:91-92still indexes the elements as arrays, whileACreateFromTemplate::getTemplates()is documented as@return ATemplate[]andrichdocumentsreturns exactly that (AbstractOfficeCreator::getTemplates()→new OfficeTemplate(...)). The app is compliant, the server is the side violating the contract.The fix in #64494 looks exactly right (object →
jsonSerialize(), array path preserved). It has had no review since 2026-09-17 and the backport requests to stable33/34/35 are still unaddressed. Is anything missing to get it merged — e.g. a regression test? Happy to help with a unit test if that is the blocker.Impact worth noting: besides the template picker being unusable, each failed attempt writes an error to
nextcloud.log, which then surfaces in the admin "Errors in the log" setup check — so a pure code defect keeps re-raising a server-health warning.reef2009 commentedon Oct 25, 2026
Still reproducible on current releases.
Request: GET /ocs/v2.php/apps/files/api/v1/directEditing/templates/richdocuments/spreadsheet?format=json
Log: "Cannot use object of type OCA\Richdocuments\DirectEditing\OfficeTemplate as array in file '/var/www/html/lib/private/DirectEditing/Manager.php' line 91"
The app shows "Fout bij ophalen sjablonen" (error fetching templates) when creating a new spreadsheet, both in my own folder and in a Team folder.
Creating the same file type from the web interface works. Opening and saving existing documents also works.