onOffice-Web-Org / oo-wp-plugin

onOffice for WP-Websites
https://wp-plugin.onoffice.com
GNU General Public License v3.0
9 stars 9 forks source link

Fix newsletter field that breaks forms #386

Closed jmaas-onoffice closed 1 year ago

jmaas-onoffice commented 1 year ago

We have a special newsletter field

For most forms, in the category "Special Fields" there is a "Newsletter" field. It is shown as a checkbox instead of the single select field from the "Administration" category.

image

When a form is sent with the newsletter field, it errors

When a form uses that newsletter field, it cannot be sent. The user is shown an error.

As a minimal reproducible example, you can create a new contact form with just this newsletter field.

image

The log contains the following error message:

[01-Dec-2022 08:34:13 UTC] [onOffice-Plugin]: onOffice\WPlugin\Field\UnknownFieldException in /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/Types/FieldsCollection.php:98
Stack trace:
#0 /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/FormData.php(134): onOffice\WPlugin\Types\FieldsCollection->getFieldByModuleAndName('address', 'newsletter')
#1 /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/Form/FormAddressCreator.php(111): onOffice\WPlugin\FormData->getAddressData(Object(onOffice\WPlugin\Types\FieldsCollection))
#2 /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/Form/FormAddressCreator.php(73): onOffice\WPlugin\Form\FormAddressCreator->getAddressDataForApiCall(Object(onOffice\WPlugin\FormData))
#3 /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/FormPostContact.php(139): onOffice\WPlugin\Form\FormAddressCreator->createOrCompleteAddress(Object(onOffice\WPlugin\FormData), false, '')
#4 /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/FormPostContact.php(92): onOffice\WPlugin\FormPostContact->createAddress(Object(onOffice\WPlugin\FormData))
#5 /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/FormPost.php(131): onOffice\WPlugin\FormPostContact->analyseFormContentByPrefix(Object(onOffice\WPlugin\FormData))
#6 /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/FormPostHandler.php(89): onOffice\WPlugin\FormPost->initialCheck(Object(onOffice\WPlugin\DataFormConfiguration\DataFormConfigurationContact), 1)
#7 /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-includes/class-wp-hook.php(308): onOffice\WPlugin\FormPostHandler::initialCheck(Object(WP))
#8 /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array)
#9 /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#10 /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-includes/class-wp.php(797): do_action_ref_array('wp', Array)
#11 /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-includes/functions.php(1332): WP->main('')
#12 /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-blog-header.php(16): wp()
#13 /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/index.php(17): require('/www/htdocs/w01...')
#14 {main}

This problem also occurs on plugin version 3.2, so it exists for quite a while already.

The newsletter field should work

Adding that newsletter field should not crash the form submission, but properly send a double opt-in email to the user.

jmaas-onoffice commented 1 year ago

I'm not sure what the issue is, so I can't predict how much time it will. During ramp-up, could we prioritize this issue? If it takes more than a few hours to resolve, tell me so that we can put this in the next cycle. :)

dai-eastgate commented 1 year ago

@jmaas-onoffice I think we can put this in the next cycle.

jmaas-onoffice commented 1 year ago

@dai-eastgate Could you explain a bit what the problem is and how much time you think it is worth taking to fix it? That helps me understand it and schedule it for the next cycle. :)

dai-eastgate commented 1 year ago

@jmaas-onoffice I did some research and was looking to see where it went wrong. Currently in the get field of the loop it is returning null and i am checking if it is missing data. It's a bug that pops up in this cycle so I think I'll fix it during the acceleration

jmaas-onoffice commented 1 year ago

Ok, sounds good. Thanks! :)

hungnc89 commented 1 year ago

@jmaas-onoffice after re-search and discussion with @dai-eastgate , We see a lot of unclear a part of code , need to learn more and it will take a long time, I suggest to do this issue in the next cycle

jmaas-onoffice commented 1 year ago

Moved into discussions as a pitch: https://github.com/onOffice-Web-Org/oo-wp-plugin/discussions/390