impress-org / givewp

GiveWP - The #1 Donation Plugin for WordPress. Easily accept donations and fundraise using your WordPress website.
https://givewp.com/
GNU General Public License v3.0
345 stars 191 forks source link

Form Field Manager - HTML and Action Hook cause bugs #7176

Closed pulsovi closed 10 months ago

pulsovi commented 10 months ago

Discussed in https://github.com/impress-org/givewp/discussions/7170

Originally posted by **pulsovi** January 4, 2024 Hi, I am a WordPress plugin developer and I am working on a website customization plugin for a client. During my work, I detected a bug in this plugin: https://givewp.com/addons/form-field-manager/ ## Scope I noticed that the management of the `name` property of unconventional fields is buggy. Precisely in the `action_hook` and `html` custom fields that can be added by the plugin. ## Symptoms 'name' (Meta_key) conflict with other fields, so : - Unable to remove the `_1` postfix from meta_key of the follower field ## Test steps 1. Open form edit page - The publication state of the form must be 'publish' - The Form Field Manager section must be empty 2. Add Text field 3. Give it a Field label (so Meta Key) 4. Add HTML field 5. Save the form 6. Swap the position of the two fields (HTML before, Text after) 7. Save the form ### What should happen The text field must keep its meta key value ### What do happen The text field meta key is suffixed with `_1` ## Diagnosis Here are my observations: The `HTML` field section do not includes any hidden ``s for its name. seeing `give-form-field-manager/includes/admin/admin-form.php@save_form_meta`. When submitting (POST) the form admin page, the `"name"` of the `"html"` field will be taken from the value saved for the field which is at its position in the order of the list of fields. But at this position, there was the **text** field. It's therefore its name which is monopolized by the HTML and which is now reserved and prohibited for other fields So, when saving the text field, a suffix is added to its name and can no longer be removed.
JoshuaHungDinh commented 10 months ago

Hi @pulsovi,

Thank you for bringing this to our attention and taking the time to write out a detailed report. I've initiated an internal ticket to address and prioritize your feedback.

Because this is specific to the Form Field Manager add-on and not our core plugin, I've closed the issue. I might suggest posting any future bug reports through this public channel https://feedback.givewp.com/bug-reports - unless you are including a PR. This will allow others to vote on your feedback, as well as allow you to follow the internal status of the issue.

JoshuaHungDinh commented 10 months ago

Reference: https://github.com/impress-org/givewp/issues/7175