Fixes error due to throwing exception inside array_map
This commit is contained in:
@ -105,12 +105,13 @@ class API {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// throw exception when trying to subscribe to a WP Users segment
|
// throw exception when trying to subscribe to a WP Users segment
|
||||||
$found_segments_ids = array_map(function($segment) {
|
$found_segments_ids = array();
|
||||||
|
foreach($found_segments as $segment) {
|
||||||
if($segment->type === Segment::TYPE_WP_USERS) {
|
if($segment->type === Segment::TYPE_WP_USERS) {
|
||||||
throw new \Exception(__(sprintf("Can't subscribe to a WordPress Users list with ID %d.", $segment->id), 'mailpoet'));
|
throw new \Exception(__(sprintf("Can't subscribe to a WordPress Users list with ID %d.", $segment->id), 'mailpoet'));
|
||||||
}
|
}
|
||||||
return $segment->id;
|
$found_segments_ids[] = $segment->id;
|
||||||
}, $found_segments);
|
}
|
||||||
|
|
||||||
// throw an exception when one or more segments do not exist
|
// throw an exception when one or more segments do not exist
|
||||||
if(count($found_segments_ids) !== count($segments_ids)) {
|
if(count($found_segments_ids) !== count($segments_ids)) {
|
||||||
|
Reference in New Issue
Block a user