- ๐ฌ๐งUnited Kingdom joehuggans Harrogate, UK
joe huggans โ made their first commit to this issueโs fork.
- Merge request !55Issue #3134078 - Conflicting name with other element(s) โ (Open) created by Unnamed author
- ๐ฌ๐งUnited Kingdom joehuggans Harrogate, UK
I may have opened an MR into the wrong branch (2.1), apologies and please advise if so. I can create some tests if you need?
- ๐ฌ๐งUnited Kingdom joehuggans Harrogate, UK
The tests are failing for this because the $form['elements'] array does not always exist, it exists for webforms but not necessarily other forms.
I'm not sure if there is a consistent way to check if a form element exists, can we assume they are always in either $form or $form['elements']?
If not, would it be better to just add a random suffix to the end of the name of the field?
- Merge request !56Check if form is a webform and alter the honeypot field name if the same key already exists. โ (Merged) created by Unnamed author
- ๐ฌ๐งUnited Kingdom joehuggans Harrogate, UK
Created new branch (3134078-for-2.2 ) from 2.2, and opened MR (merge request !56) for 2.2. Will work on tests next.
- ๐บ๐ธUnited States tr Cascadia
This really does need to be done in 2.2, not in 2.1.
The MR!55 is unusable because it is mostly changes to make 2.1 identical to 2.2 by cherry-picking commits that were made to 2.2.
The MR should really be just a few lines of code. And it should include a test case to test this specific new feature. - ๐ฌ๐งUnited Kingdom joehuggans Harrogate, UK
Some tests provided, let me know if I can improve these in any way or if I've done anything wrong and I will fix it.
I'm not sure how to get past the phpstan failure in the tests.
- ๐บ๐ธUnited States tr Cascadia
The phpstan error is because the real class name should be \Drupal\Component\Serialization\Yaml
The "Core" version is just an alias, which I guess phpstan doesn't like for some reason. Best to change it to Component everywhere IMO.
Also, "webform" should be added to the cspell list in .gitlab-ci.ymlBut other than that it looks great.
- ๐ฌ๐งUnited Kingdom joehuggans Harrogate, UK
Thank you for the help! All seems to be passed now.
- ๐บ๐ธUnited States tr Cascadia
This looks good to me. I will leave this issue open for a few days to allow people to comment if they want, then I will commit it.
-
tr โ
committed 911a0f93 on 2.2.x authored by
joe huggans โ
Issue #3134078 by joe huggans, tarik.cipix: Conflicting name with other...
-
tr โ
committed 911a0f93 on 2.2.x authored by
joe huggans โ
- ๐บ๐ธUnited States pcate
After updating to version
2.2.1
I've started getting webform error messages related to this change.The error is:
TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in array_key_exists() (line 151 of modules/contrib/honeypot/src/HoneypotService.php). Drupal\honeypot\HoneypotService->addFormProtection() (Line: 234) honeypot_webform_submission_form_alter() (Line: 552) Drupal\Core\Extension\ModuleHandler->alter() (Line: 78) Drupal\webform\WebformThirdPartySettingsManager->alter() (Line: 678) Drupal\webform\WebformSubmissionForm->buildForm() call_user_func_array() (Line: 536) Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 284) Drupal\Core\Form\FormBuilder->buildForm() (Line: 48) Drupal\Core\Entity\EntityFormBuilder->getForm() (Line: 1250) Drupal\webform\Entity\Webform->getSubmissionForm() (Line: 112) Drupal\webform\Element\Webform::preRenderWebformElement() call_user_func_array() (Line: 113)
It appears that are circumstances where the
$form['elements']
is not set on webforms. It seems in my clients case to be related to access controls where the form may not be rendered if the user is logged in.I think we need to check if the
$form['elements']
is also set in the if statement on line 151 ofHoneypotService.php
- ๐ฌ๐งUnited Kingdom joehuggans Harrogate, UK
Yes, we need to check $form['elements'] exists, I tried to create a new MR but made a mess of it, sorry.
- ๐บ๐ธUnited States tr Cascadia
MR should be good now. Can you modify the test too, to check for this case?
- ๐ฌ๐งUnited Kingdom joehuggans Harrogate, UK
I'm able to recreate the error from #29 with a CLOSED webform, but unable to replicate by changing the access setting for the Webform.
I will add a test, not sure exactly what to test for but this test checks that the filename has not been altered for the honeypot field.
- ๐บ๐ธUnited States pcate
I'm able to recreate the error from #29 with a CLOSED webform, but unable to replicate by changing the access setting for the Webform.
After some more testing, the settings which triggers the error for me were:
- In the "Submissions" tab, enable the "Confidential submissions" option.
- Note: If you have the "General" > "Disable saving of submissions" option enabled, you won't see this option.
- Set the Access > "Create submissions" permissions to be both anonymous and authenticated users.
- Visit the form while logged in as a basic authenticated user who doesn't have any permissions to bypass access restrictions.
- In the "Submissions" tab, enable the "Confidential submissions" option.
- ๐ฌ๐งUnited Kingdom joehuggans Harrogate, UK
Thanks @pcate. Using your instructions I have managed to recreate the error, and it is fixed by checking if
$form['#webform_id']
is empty.@tr do you require a test for these circumstances also?
- ๐บ๐ธUnited States tr Cascadia
@pcate: If you apply the patch from MR!57, does it fix the issue on your site?
@joe huggans: I think the MR and the test are fine as they are, if @pcate can confirm that it fixes the problem on his site.
- ๐บ๐ธUnited States pcate
@pcate: If you apply the patch from MR!57, does it fix the issue on your site?
@tr, I've tested MR #57 and can confirm it does fix the error.
- ๐บ๐ธUnited States jackfoust
This seems to have addressed my issues in https://www.drupal.org/project/honeypot/issues/3506174 ๐ PHP errors when a webform is closed Active
-
tr โ
committed a544a9fc on 2.2.x authored by
joe huggans โ
Issue #3134078 by joe huggans: Conflicting name with other element(s)
-
tr โ
committed a544a9fc on 2.2.x authored by
joe huggans โ
- ๐ธ๐ฎSlovenia KlemenDEV
This was not released yet, right? I see this issue mentioned in https://www.drupal.org/project/honeypot/releases/2.2.1 โ , but afaik 2.2.1 introduced https://www.drupal.org/project/honeypot/issues/3506174 ๐ PHP errors when a webform is closed Active , which is marked as duplicate of this issue
- ๐บ๐ธUnited States tr Cascadia
A problem with the initial commit was reported in #29 so the issue was reopened to fix that problem.
2.2.1 has MR!56, the next release will also have MR!57. You can use the patch from MR!57 or use the -dev release if you want the fix immediately. - ๐ธ๐ฎSlovenia KlemenDEV
Aha, sorry, got confused for a second. Thanks for the clarification!
Automatically closed - issue fixed for 2 weeks with no activity.