Closed rrelmy closed 7 months ago
When using fully numeric handles for collections like "2024" the API resource configuration does not work.
"2024"
The collection is not included when enabling all resources, neither does a specific defintion like "2024" => true work.
"2024" => true
The ResourceAuthorizer checks for numeric keys and swaps the value to the key, allowing configurations like ["pages", "other_collection"] https://github.com/statamic/cms/blob/4.x/src/API/ResourceAuthorizer.php#L47
["pages", "other_collection"]
'resources' => [ 'collections' => [ "2024" => "2024", // 😏 ],
Do not use numeric handles :-D
2024
No response
Environment Application Name: <> Laravel Version: 10.45.0 PHP Version: 8.3.2 Composer Version: 2.7.1 Environment: local Debug Mode: ENABLED URL: localhost:8000 Maintenance Mode: OFF Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: NOT CACHED Drivers Broadcasting: null Cache: statamic Database: sqlite Logs: stack / daily Mail: log Queue: sync Session: file Statamic Addons: 2 Antlers: runtime Sites: 2 (Deutsch, English) Stache Watcher: Enabled Static Caching: Disabled Version: 4.49.0 PRO Statamic Addons doublethreedigital/runway: 5.6.1 statamic/seo-pro: 5.4.1
Fresh statamic/statamic site via CLI
Runtime (default)
I only tested the REST API
We would probably recommend that you don't use just numbers for collection handles (or any other kind of handle for that matter).
Bug description
When using fully numeric handles for collections like
"2024"
the API resource configuration does not work.The collection is not included when enabling all resources, neither does a specific defintion like
"2024" => true
work.Cause
The ResourceAuthorizer checks for numeric keys and swaps the value to the key, allowing configurations like
["pages", "other_collection"]
https://github.com/statamic/cms/blob/4.x/src/API/ResourceAuthorizer.php#L47Workaround
Do not use numeric handles :-D
How to reproduce
2024
Logs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
Runtime (default)
Additional details
I only tested the REST API