Remove button seems to have not been working since version beta4, tested so far with Drupal core version 8.9+ and 9.1+.
#3057727: Remove button does not function for multiple files → - Creates a patch but omits the call to parent::processManagedFile() https://www.drupal.org/project/s3fs_cors/issues/3057727#comment-13987061 →
What I'm seeing through debug is that at the beginning of S3fsCorsFile::processManagedFile() we have:
$element['remove_button']['#submit'] = [
0 => "file_managed_file_submit",
1 => [
0 = "Drupal\s3fs_cors\Plugin\Field\FieldWidget\S3fsCorsFileWidget",
1 = "submit",
],
]
Then after the call to parent::processManagedFile we have:
$element['remove_button']['#submit'] = [
0 => "file_managed_file_submit",
]
Looking at where the #process callbacks are set, I notice that in version beta3 we had:
$element['#process'] = [$element_info['#process'][0], $element['#process'][1]];
Which then yields:
#process => [
0 => [
0 => "Drupal\s3fs_cors\Element\S3fsCorsFile",
1 => "processManagedFile"
],
1 => [
0 => "Drupal\inline_form_errors\RenderElementHelper",
1 => "processElement"
]
]
But when it changed the code to append instead of replace #process with:
$element['#process'][] = $element_info['#process'][0];
$element['#process'][] = $element['#process'][1];
That yields an array with the parent already in there, called statically.
I believe it's then being called twice. I'm not entirely sure how this is working for some sites, but I think we don't need the call to the parent.
- Create s3fs file field with any cardinality
- Creating an entity works as expected, saving works as expected
- Reload entity and try to delete existing file
- No JS errors show, no watchdog errors show
Needs review
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.