Define default variable values in cases when they can be undefined
This commit is contained in:
@ -194,6 +194,7 @@ class Import {
|
||||
}
|
||||
|
||||
function transformSubscribersData($subscribers, $columns) {
|
||||
$transformed_subscribers = [];
|
||||
foreach($columns as $column => $data) {
|
||||
$transformed_subscribers[$column] = array_column($subscribers, $data['index']);
|
||||
}
|
||||
@ -227,6 +228,7 @@ class Import {
|
||||
$wp_users = array_filter(array_column($temp_existing_subscribers, 'wp_user_id'));
|
||||
// create a new two-dimensional associative array with existing subscribers ($existing_subscribers)
|
||||
// and reduce $subscribers_data to only new subscribers by removing existing subscribers
|
||||
$existing_subscribers = [];
|
||||
$subscribers_emails = array_flip($subscribers_data['email']);
|
||||
foreach($temp_existing_subscribers as $temp_existing_subscriber) {
|
||||
$existing_subscriber_key = $subscribers_emails[$temp_existing_subscriber['email']];
|
||||
|
@ -45,6 +45,7 @@ class MailChimp {
|
||||
return $this->throwException('API');
|
||||
}
|
||||
|
||||
$lists = [];
|
||||
foreach($response->data as $list) {
|
||||
$lists[] = array(
|
||||
'id' => $list->id,
|
||||
@ -65,6 +66,8 @@ class MailChimp {
|
||||
}
|
||||
|
||||
$bytes_fetched = 0;
|
||||
$subscribers = [];
|
||||
$header = [];
|
||||
foreach($lists as $list) {
|
||||
$url = sprintf($this->export_url, $this->data_center, $this->api_key, $list);
|
||||
$connection = @fopen($url, 'r');
|
||||
@ -72,7 +75,6 @@ class MailChimp {
|
||||
return $this->throwException('connection');
|
||||
}
|
||||
$i = 0;
|
||||
$header = array();
|
||||
while(!feof($connection)) {
|
||||
$buffer = fgets($connection, 4096);
|
||||
if(trim($buffer) !== '') {
|
||||
@ -124,6 +126,7 @@ class MailChimp {
|
||||
}
|
||||
|
||||
function throwException($error) {
|
||||
$errorMessage = __('Unknown MailChimp error message.', 'mailpoet');
|
||||
switch($error) {
|
||||
case 'API':
|
||||
$errorMessage = __('Invalid API Key.', 'mailpoet');
|
||||
|
Reference in New Issue
Block a user