As an update, I’ve identified the cause of this issue as a bug in the Divi theme, not correctly handling the cause of the exception thrown when MailPoet API getSubscriber function is called. Rather than checking the code of the exception (APIException::SUBSCRIBER_NOT_EXISTS being a valid response when testing to see if the subscriber exists), it treats all exceptions as errors.
I’ve raised this with the Divi support team.
Hi, i also have this problem.
How is this topic solved?
Hello. I am having the same problem. How is this solved?
Hi both… I’d thought it looked like a longstanding bug in the Divi theme and no one had been using it… so interesting a few others are also seeing it.
The error message itself comes from line 357 of MailPoet’s API.php (/mailpoet/lib/API/MP/v1/API/php), in the function getSubscriber(); an exception is thrown when this function is called and the subscriber doesn’t exist.
However the issue is not there, as that is correct behavior, but within the calling function within the Divi theme files, \Divi\core\components\api\email\_MailPoet3.php, line 165 within the subscribe() function. This should handle the exception gracefully as an expected response when the user is new.
I’ve changed the code that checks if a subscriber already exists as follows:
/**
* Check if the subscriber with this email already exists.
*/
try {
$subscriber = \MailPoet\API\API::MP( 'v1' )->getSubscriber( $subscriber_data['email'] );
} catch ( \MailPoet\API\MP\v1\APIException $exception ) {
switch ($exception->GetCode()) {
case \MailPoet\API\MP\v1\APIException::SUBSCRIBER_NOT_EXISTS:
// valid result when subscriber does not exist; do nothing
break;
default:
$result = $exception->getMessage();
}
} catch ( Exception $exception ) {
$result = $exception->getMessage();
}
I’ve sent this to Elegant Themes in response to the ticket so hopefully they’ll patch a subsequent version of Divi directly.
I’ve not looked at putting this into a child theme, but I guess that would be the right way to temporarily fix this until Divi to issue an update.
-
This reply was modified 5 years, 3 months ago by
olicuk. Reason: added further detail
Hi Olicuk!
Thanks for the update!.
I don’t feel comfertable changing codes, cause I think I would mess it up.(;-)
I hope Divi will react to your ticket and hope they will soon send a patch for this issue.
Best regards, Chris.
Hi Olicuk,
For the record I also get this error.
Hopefully Divi and MailPoet can resolve this between them.
Regards, Steve