Hello,
I found a bug in the HubSpot addon when saving a HubSpot settings section of a form in WordPress.
During the save process, the addon fetches all form names from the connected HubSpot account and checks each name/GUID to ensure uniqueness. The issue occurs in the is_form_name_unique function of the GFFeedAddOn class, which accesses the name property of each form without verifying if it is set.
In my case, this causes an error that triggers a generic failure and creates an orphan blank form in my HubSpot account.
To fix this, you can add the following snippet at the start of the loop that checks each form:
if ( ! isset( $form['name'], $form['guid'] ) ) {
continue;
}
Do you have a GitHub repository? I can create a simple PR with this fix, or can you handle this error? Currently, this block has no proper error handling. This is the final function with the fix:
private function is_form_name_unique( $field_value, $forms, $settings ) {
$form_name = $field_value . $this->get_hubspot_formname_warning();
$unique = true;
foreach ( $forms as $form ) {
if ( ! isset( $form['name'], $form['guid'] ) ) {
continue;
}
if ( $form['name'] === $form_name && $settings['_hs_form_guid'] !== $form['guid'] ) {
$unique = false;
}
}
return $unique;
}
I attach some screen, too. Thank you for your work,
Alessandro.
