What happened?
Description
First of all, huge kudos for the move to Laravel. I am really excited about where this is heading.
I ran into a TypeError when saving a Structure section with a maxLevels value. The raw request string is assigned directly to a ?int typed property, while the identical maxAuthors field on the same form already handles this correctly with an is_numeric cast.
Steps to reproduce
- Go to Settings → Sections
- Create or edit a section of type Structure
- Enter any value in the Max Levels field
- Save
Expected behavior
The section saves successfully with the maxLevels value stored as an integer.
Actual behavior
TypeError
vendor/craftcms/cms/src/Http/Controllers/Settings/SectionsController.php:179
Cannot assign string to property CraftCms\Cms\Section\Data\Section::$maxLevels of type ?int
// Before
$section->maxLevels = $request->input('maxLevels') ?: null;
// After, mirrors the existing maxAuthors pattern on line 172
$maxLevels = $request->input('maxLevels');
$section->maxLevels = is_numeric($maxLevels) ? (int) $maxLevels : null;
Craft CMS version
6.0.0-alpha.1
PHP version
8.5
Operating system and version
ddev on macOS
Database type and version
mysql 8.4
Image driver and version
No response
Installed plugins and versions
What happened?
Description
First of all, huge kudos for the move to Laravel. I am really excited about where this is heading.
I ran into a TypeError when saving a Structure section with a maxLevels value. The raw request string is assigned directly to a ?int typed property, while the identical maxAuthors field on the same form already handles this correctly with an is_numeric cast.
Steps to reproduce
Expected behavior
The section saves successfully with the maxLevels value stored as an integer.
Actual behavior
Craft CMS version
6.0.0-alpha.1
PHP version
8.5
Operating system and version
ddev on macOS
Database type and version
mysql 8.4
Image driver and version
No response
Installed plugins and versions