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
I'm using a custom controller to receive file uploads. Those uploads are validated via a YII file extension validator. Since upgrading to PHP 8.1 the model validation failed to work and resulted in an error regarding the file extension being forbidden.
I've noticed that when I add the following option 'checkExtensionByMimeType' => false, the validation works again.
This seems to be a known problem with YII. See: yiisoft/yii2#19243
Steps to reproduce
Define a File Model using the following code:
class UploadForm extends Model
{
public ?UploadedFile $file;
public function rules(): array
{
return [
[['file'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png,jpg,jpeg,svg,pdf,doc,ppt'],
];
}
}
Validate a model containing (for example) a file named "image.png"
Expected behavior
The validation should work when uploading a file with a valid extension.
Actual behavior
The validation fails with PHP 8.1
Craft CMS version
3.8.13
PHP version
8.1
Operating system and version
linux
Database type and version
mariadb
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered:
@brandonkelly Thank you very much! I've yet to find time to review the change but I guess update Yii will do the trick, since it's a Yii problem after all.
What happened?
Description
I'm using a custom controller to receive file uploads. Those uploads are validated via a YII file extension validator. Since upgrading to PHP 8.1 the model validation failed to work and resulted in an error regarding the file extension being forbidden.
I've noticed that when I add the following option 'checkExtensionByMimeType' => false, the validation works again.
This seems to be a known problem with YII. See: yiisoft/yii2#19243
Steps to reproduce
class UploadForm extends Model
{
public ?UploadedFile $file;
}
Expected behavior
The validation should work when uploading a file with a valid extension.
Actual behavior
The validation fails with PHP 8.1
Craft CMS version
3.8.13
PHP version
8.1
Operating system and version
linux
Database type and version
mariadb
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: