- Issue created by @greatmatter
See also https://drupal.stackexchange.com/questions/317946/webform-file-upload-fa... with questions, some answered.
- ๐บ๐ธUnited States greatmatter
While this is probably not the long-term fix, I commented out line 251 of [ROOT]/modules/contrib/webform/src/Plugin/WebformElement/WebformManagedFileBase.php:251
And this error goes away... But I'm worried that I'm opening a can of worms.
- ๐บ๐ธUnited States greatmatter
@cilefen thank you. I don't have anything like that in the config folder, but I do see the following in my site filebase:
[ROOT]/modules/contrib/webform/src/Plugin/WebformElement/WebformManagedFileBase.php:245: // Define 'webform_file_validate_extensions' which allows file [ROOT]/modules/contrib/webform/src/Plugin/WebformElement/WebformManagedFileBase.php:247: // 'webform_file_validate_extensions' will be ignored by file_validate(). [ROOT]/modules/contrib/webform/src/Plugin/WebformElement/WebformManagedFileBase.php:251: $element['#upload_validators']['webform_file_validate_extensions'] = []; [ROOT]/modules/contrib/webform/includes/webform.theme.inc:665: if (isset($upload_validators['webform_file_validate_extensions'])) {
- ๐ฏ๐ตJapan Ryo Ichiyama
I have seen the same logs as @greatmatters after updating Drupal Core to 10.2.
Additionally, the browser displays the attached error message.
The version of the Webform module (6.2.2) has not changed before or after the Core update.Any hints would be appreciated.
Also, please post the YAML of a simple form that exhibits the bug.
- ๐ฏ๐ตJapan Ryo Ichiyama
Hello.
I got an error in my local development environment, so I tried it in the staging environment and got the same error.
Below is the minimal YAML source.
file1:.
'#type': managed_file
'#title': File1
'#file_preview': file
'#file_extensions': 'pdf jpg jpeg png'
'#sanitize': true
'#button': true
'#button__title': Upload1 Hello
I've the same problem after module updated in 6.2 and also Drupal 10.2.0
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "webform_file_validate_extensions" plugin does not exist. Valid plugin IDs for Drupal\Core\Validation\ConstraintManager are: Callback, Blank, NotBlank, Email, Choice, BlockContentEntityChanged, CropTypeAspectRatioValidation, CropTypeMachineNameValidation, DateTimeFormat, QueueSize, FileIsImage, FileSizeLimit, FileExtensionSecure, FileImageDimensions, FileValidation, FileNameLength, FileUriUnique, FileExtension, jsonapi_extras__duplicate_field, LinkType, LinkNotExistingInternal, LinkExternalProtocols, LinkAccess, oembed_resource, MenuSettings, ParagraphsLibraryItemHasAllowedParagraphsType, PathAlias, RedirectSourceLinkType, SchedulerUnpublishOn, SchedulerPublishOn, TaxonomyHierarchy, UserName, UserMailRequired, ProtectedUserField, UserNameUnique, UserMailUnique, VideoEmbedValidation, MenuTreeHierarchy, ExtensionName, ExtensionExists, RequiredConfigDependencies, ConfigExists, Count, ValidKeys, Length, Null, Range, UniqueField, ComplexData, Regex, PrimitiveType, Uuid, AllowedValues, NotNull, UniquePathAlias, ValidPath, EntityUntranslatableFields, EntityChanged, ImmutableProperties, EntityHasField, Bundle, ValidReference, ReferenceAccess, EntityType, PluginExists in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /var/www/html/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
I follow this issue
I am also having the same issue with Drupal 10.2, Webform 6.2.2 and PHP 8.2. Users cannot upload files
Uncaught PHP Exception Drupal\Component\Plugin\Exception\PluginNotFoundException: "The "webform_file_validate_extensions" plugin does not exist. Valid plugin IDs for Drupal\Core\Validation\ConstraintManager are: ...
#4 allows submissions to go through so I have it as a temporary fix as well. Thanks @greatmatter
Is this problem analogous to ๐ Core version 10.2 imce error Fixed ?
- ๐บ๐ธUnited States greatmatter
@cilefen Possibly, though I don't have IMCE on any of my sites.
This might play a bigger role:
https://www.drupal.org/node/3363700 โ - file_validate and related functions are deprecated and replaced with file.validator service and Constraint plugins I said "analogous", not "caused by".
Anyway, we just got hit with this one so I have a form that reproduce this now.
- ๐ฎ๐ณIndia ankithashetty Karnataka, India
+1 to this issue.
For now tried the #4 suggestion as a workaround. I think the fact that no function exists of the name webform_file_validate_extensions is the problem here.
- ๐ฎ๐ณIndia sakthi_dev
I think the implementation is wrong here. Why we need a condition to check in preprocess_file_upload_help. The preprocess itself will get invoke on file help. Even if we want a condition there, I think it should be a variable and not as a callback function in a array. So the solution would be removing the callback function addition from WebformManagedFileBase.php and also removing the if condition from webform_preprocess_file_upload_help in webform.theme.inc.
I would go so far as to make this a critical for this module, because file uploads are a major feature.
- ๐บ๐ธUnited States DamienMcKenna NH, USA
I have a brand new 10.2.x install with Webform 6.2.x, I added a basic managed file element to the out-of-the-box contact form and could not reproduce this problem. Can someone please work out the exact steps to reproduce the problem? Thank you.
- ๐บ๐ธUnited States DamienMcKenna NH, USA
Just cross referencing the original core issue: ๐ Move file upload validation from file.module to constraint validators Fixed
- ๐บ๐ธUnited States DamienMcKenna NH, USA
FYI the core change introduced a subtle bug whereby if a validator passed through #upload_validators did not exist as a function it was assumed to be a constraint plugin, whereas lots of contrib modules used it as a namespaced variable that would ultimately be passed through to hook_file_validate().
- ๐บ๐ธUnited States DamienMcKenna NH, USA
I opened a new core issue about this: ๐ File validation logic from #3221793 broke backwards compatibility Active
- Merge request !388Issue#3409599: Resolve unfound plugin issue for file upload field. โ (Open) created by sakthi_dev
- last update
11 months ago 536 pass - Status changed to Needs review
11 months ago 3:17pm 21 December 2023 - ๐ฎ๐ณIndia sakthi_dev
Updated the code as per comment #19. Please review.
- last update
11 months ago 536 pass - ๐บ๐ธUnited States jrb Raleigh-Durham Area, NC, USA
The changes in MR 388 fixed the issue for us. Attached is a patch with the diffs as of today.
I have never installed a patch before
where do I place that patch
composer.json
"extra": {
"patches": {
"drupal/??": {
"??": " https://www.drupal.org/files/issues/2023-12-22/3409599-28.mr388.webform_... โ "}
}
}- ๐บ๐ธUnited States DamienMcKenna NH, USA
@raffie: Please see the official docs on how to use a patch file; you'll want to add it to the website project's root composer.json file: https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa... โ
Patch seems to have worked on Drupal 10.2.0, PHP 8.1.26.
composer.json example:
"extra": { ..., "patches": { "drupal/webform": { "Issue 3409599. Fix file upload.": "https://git.drupalcode.org/project/webform/-/merge_requests/388.patch" } } }
- ๐บ๐ธUnited States ethangeorgi
Patch worked for us, too. Thank you!
Drupal 10.2.0
PHP 8.1.26
MariaDB 10.4.25
drupal/webform 6.2.2 - Status changed to RTBC
11 months ago 2:11pm 4 January 2024 - ๐จ๐ฆCanada leducdubleuet Chicoutimi QC
Patch worked for us as well, thank you very much!
- Status changed to Needs work
11 months ago 4:15pm 4 January 2024 - ๐บ๐ธUnited States jrockowitz Brooklyn, NY
I understand people are trying to fix this issue, but the ticket summary should document the problem and resolution.
Right now, the MR seems to be removing file extension validation for all versions of Drupal, even though the problem is only occurring in 10.2.x
- ๐จ๐ฆCanada leducdubleuet Chicoutimi QC
As of this morning, the patch is still needed with 10.2 for the file upload to work properly so yes this is still happening.
- ๐จ๐ฆCanada leducdubleuet Chicoutimi QC
I also tested the file extension validation and it is still working even with the patch so the fix does not completely remove the file extension validation.
It removes the line :
$element['#upload_validators']['webform_file_validate_extensions'] = [];
But we still have :
$element['#upload_validators']['file_validate_extensions'] = [$this->getFileExtensions($element)];
- ๐ฎ๐ณIndia sakthi_dev
Just for clarification. The issue is because of "webform_file_validate_extensions" callback function and it doesn't exists but that is used as a if condition in the hook. Also, it is not validating the file extension but just adding the comma to the allowed list of extension in the frontend. I think this issue is not related to removing the upcoming deprecated function and also mentioned issue is not related to it.
Please correct me if I'm wrong.
Just to be clear, I am referring to testing with 10.2.x, the branch head, not with 10.2.0 release.
- ๐บ๐ธUnited States DamienMcKenna NH, USA
With the core change does this mean that the validation logic in Webform should be rewritten to be a constraint instead of just a function?
- ๐จ๐ฆCanada leducdubleuet Chicoutimi QC
I can confirm that after removing the patch from MR 388 and upgrading to Drupal core 10.2.1, the file upload is working correctly in my custom web forms.
This is great news, thanks to all for your time!
- ๐บ๐ธUnited States DamienMcKenna NH, USA
I created a new issue for replacing the validation logic with the new system: https://www.drupal.org/project/webform/issues/3413194 โจ Replace webform_file_validate_extensions with Constraint plugin Active
We could close this one as the bug is fixed in core and focus on the new plugin in the other issue.
- Status changed to Closed: outdated
11 months ago 1:35pm 8 January 2024 - ๐ง๐ทBrazil raprieto
raprieto โ changed the visibility of the branch 3409599-drupalcomponentpluginexceptionpluginnotfoundexception-the-webformfilevalidateextensions to hidden.
- ๐ง๐ทBrazil raprieto
raprieto โ changed the visibility of the branch 3409599-drupalcomponentpluginexceptionpluginnotfoundexception-the-webformfilevalidateextensions to hidden.