Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array_key_exists(): Argument #2 ($array) must be of type array, string given in FileParameterBag Description #86

Closed
lucamillers opened this issue Jul 12, 2024 · 4 comments

Comments

@lucamillers
Copy link

While working with file uploads in Contao 4.13 using the Terminal42\mp_forms-Bundle (5.2.0), I encountered an issue where the array_key_exists() function throws an error because it is given a string instead of an array. This issue occurs in the set method of the FileParameterBag class.

To reproduce:
My case was a checkbox-menu that (thanks to conditionalFormFields) showed the user two input fields based on the checkbox-selection, a text box and a file-upload-widget. When trying to upload a file, upon clicking next, I'm getting the following error:

image

@fritzmg
Copy link
Contributor

fritzmg commented Jul 14, 2024

Even if the original error is fixed (by #84) you will still get a InvalidArgumentException error.

@zonky2
Copy link
Contributor

zonky2 commented Jan 23, 2025

I have Contao 4.13.52 and MP_Form 5.2.0 and also run into the error of #84

If I turn && into ||, I run into the exception
$value must be an array normalized by the FileUploadNormalizer service.

I have inserted a dump before the foreach on $value - it looks like this - according to the source code it should have one more level.

array:7 [▼
  "name" => "test__8.pdf"
  "type" => "application/pdf"
  "tmp_name" => "/kunden/1234/files/upload/call_2025/test01/test__8.pdf"
  "error" => 0
  "size" => 27678
  "uploaded" => true
  "uuid" => "0cde4c6b-d98f-11ef-bfa2-0242ac1b9908"
]

``In the form I have the normal upload field and not the FineUploader.

zonky2 added a commit to zonky2/contao-mp_forms that referenced this issue Jan 24, 2025
see issue terminal42#86 (comment)

It would be nice if the UT would also check this.
@mapfei
Copy link

mapfei commented Jan 27, 2025

How can the error be solved? I am using a customer installation with Contao 4.13.50 and mp-forms 5.2.0.

This is the complete error message:

[2025-01-27T07:14:55.174674+00:00] request.INFO: Matched route "tl_page.2650". {"route":"tl_page.2650","route_parameters":{"_controller":"Contao\\FrontendIndex::renderPage","_scope":"frontend","_locale":"de","_format":"html","_canonical_route":"tl_page.2650","parameters":"","pageModel":{"Contao\\PageModel":[]},"_route":"tl_page.2650","_route_object":{"Contao\\CoreBundle\\Routing\\Page\\PageRoute":[]}},"request_uri":"/online?ref=52d9075a2b0aee430f45a0ef5e8e67be&step=4","method":"POST"} []
[2025-01-27T08:14:55.185977+01:00] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2025-01-27T08:14:55.481275+01:00] contao.files.INFO: File "files/bewerbungen_rem-cpm/test__4.pdf" has been uploaded [] {"contao":{"Contao\\CoreBundle\\Monolog\\ContaoContext":"{\"func\":\"Contao\\\\FormFileUpload::validate\",\"action\":\"FILES\",\"username\":\"anon.\",\"browser\":\"Mozilla\\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/131.0.0.0 Safari\\/537.36\"}"}}
[2025-01-27T07:14:55.590938+00:00] request.CRITICAL: Uncaught PHP Exception TypeError: "array_key_exists(): Argument #2 ($array) must be of type array, string given" at /vendor/terminal42/contao-mp_forms/src/Step/FileParameterBag.php line 33 {"exception":"[object] (TypeError(code: 0): array_key_exists(): Argument #2 ($array) must be of type array, string given at /vendor/terminal42/contao-mp_forms/src/Step/FileParameterBag.php:33)"} []

@Toflar
Copy link
Member

Toflar commented Jan 27, 2025

Should be fixed with 5.2.1, I guess?

@Toflar Toflar closed this as completed Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants