Problem/Motivation

#2932061: Clear cache when Mailchimp API key gets updated is going to provide an option to clear Mailchimp cache when API key changes in the configuration.

However, API key change is not the only case where a user/administrator can get cached data. Once a new list is created in Mailchimp, the same list becomes visible in webform_mailchimp as soon as we clear mailchimp cache data. Until then, it is not available at all.

Proposed resolution

To prevent the above, we should either:

  • Not use cached (list) data in WebformMailchimpHandler plugin.
  • Provide an "Update" button so a user can do it manually in UI.

Remaining tasks

Discuss.

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mbovan created an issue. See original summary.

miro_dietiker’s picture

Priority: Normal » Major

From the current tests i don't think we should omit caches.
Already now, when opening the handler edit dialog it takes long.
We whould try to quickly load initially and offer optional update.

Major because stale caches can result in wrong selections and unexpected (currently pretty silent) submission handler fails.

miro_dietiker’s picture

Did some setups in production and it was pretty annoying.
The only action that made newly created MailChimp groups show up when editing the handler was a global Cache clear...
Users without superadmin permissions won't be able to handle such a situation.

Primsi’s picture

Status: Active » Needs review
FileSize
2.18 KB

Initial patch for this.

Wrapped the button in a fieldset that a description can be provided. Also it seems that we don't need to clear the cache manually because mailchimp_get_lists() can do that.

From what I tested all relevant stuff is populated with new data. Not sure if I missed something.

miro_dietiker’s picture

You write that groups are retrieved separately and not cached. However i reported this isssue because when a new group is added on mailchimp side, even reloading the form edit / handler overview and reclicking the handler edit Button didn‘t help to make the new group show up.

Maybe the new code updating the list implicitly also updated the groups? Plt double check.

miro_dietiker’s picture

Status: Needs review » Needs work

This seems to me like unclean empty options handling:

$options[''] = t('- Select an option -');

The empty option key should be present and this should not be an regular options value. Also especially not of selection is required.

Primsi’s picture

Status: Needs work » Needs review
FileSize
3.13 KB
3.04 KB

I've re-checked the group part: the interest groups part is built by mailchimp_interest_groups_form_elements() which doesn't have any caching mechanism. Also tested it manually by renaming and adding a group on Mailchimp.

Also moved the logic to the submit handler following Berdirs suggestion, and corrected other missing #empty_option

Primsi’s picture

FileSize
136.03 KB

miro_dietiker’s picture

Status: Needs review » Needs work

This update / cache clear is only needed to make these things show up:
* New lists
* New group categories

Thus, let's put the button on the same line as the list selection.
Name it
* Refresh lists & groups

We don't need any explanation, details element or any description IMHO.
Changes are that the wrapping can be done by attaching some wrapper / inline classes - Berdir said ;-)

Primsi’s picture

Status: Needs work » Needs review
FileSize
119.47 KB
1.73 KB
2.54 KB

- removed the group
- renamed button
- moved button

  • miro_dietiker committed e6e4098 on 8.x-5.x authored by Primsi
    Issue #2932366 by Primsi, miro_dietiker: Provide "Update" button when...
miro_dietiker’s picture

Status: Needs review » Fixed

Awesome, committed.
More UI improvements like horizontal wrapping in follow-ups.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.