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
WebformMailchimpHandlerplugin. - Provide an "Update" button so a user can do it manually in UI.
Remaining tasks
Discuss.
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 2932366-provide-update-button.10.patch | 2.54 KB | primsi |
| #10 | 2932366-provide-update-button.10.interdiff.txt | 1.73 KB | primsi |
| #10 | handler_modal_10.png | 119.47 KB | primsi |
| #8 | handler_modal.png | 136.03 KB | primsi |
| #7 | 2932366-provide-update-button.7.patch | 3.04 KB | primsi |
Comments
Comment #2
miro_dietikerFrom 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.
Comment #3
miro_dietikerDid 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.
Comment #4
primsi commentedInitial 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.
Comment #5
miro_dietikerYou 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.
Comment #6
miro_dietikerThis seems to me like unclean empty options handling:
The empty option key should be present and this should not be an regular options value. Also especially not of selection is required.
Comment #7
primsi commentedI'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
Comment #8
primsi commentedComment #9
miro_dietikerThis 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 ;-)
Comment #10
primsi commented- removed the group
- renamed button
- moved button
Comment #12
miro_dietikerAwesome, committed.
More UI improvements like horizontal wrapping in follow-ups.