Skip to content

Commit 9b13927

Browse files
committedSep 21, 2020
fix site transient for gdpr field response
1 parent 5f1151f commit 9b13927

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
 

‎includes/api/class-mailchimp-api.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1596,13 +1596,13 @@ public function getCachedGDPRFields($list_id, $minutes = 5)
15961596
$GDPRfields = get_site_transient($transient);
15971597

15981598
// only return the values if it's a false - or an array
1599-
if ($GDPRfields === false || is_array($GDPRfields)) return $GDPRfields;
1599+
if (is_array($GDPRfields)) return $GDPRfields;
16001600

16011601
try {
16021602
$GDPRfields = $this->getGDPRFields($list_id);
16031603
set_site_transient($transient, $GDPRfields, 60 * $minutes);
16041604
} catch (\Exception $e) {
1605-
$GDPRfields = false;
1605+
$GDPRfields = array();
16061606
}
16071607

16081608
return $GDPRfields;

‎includes/class-mailchimp-woocommerce-newsletter.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ public function applyNewsletterField($checkout)
7070
$checkbox .= '</p>';
7171
$checkbox .= '<div class="clear"></div>';
7272

73-
if ($GDPRfields) {
73+
// only render these fields if it's an array that has valid data.
74+
if (!empty($GDPRfields) && is_array($GDPRfields)) {
7475
$checkbox .= "<div id='mailchimp-gdpr-fields'><p>";
7576
$checkbox .= __('Please select all the ways you would like to hear from us', 'mailchimp-for-woocommerce');
7677
$checkbox .= "<div class='clear'></div>";

0 commit comments

Comments
 (0)