Fatal Error
-
I just saw a fatal error in my log:
PHP Fatal error: Cannot use object of type WP_Error as array in /…/wp-content/plugins/postmark-approved-wordpress-plugin/postmark.php on line 306, referer: …/wp-admin/edit-comments.php
I noticed there is no check if $response was in fact filled by the WP_Error class, so I changed the pm_send_mail function (at the bottom of postmark.php) a bit:
Original:
function pm_send_mail($headers, $email){ $args = array( 'headers' => $headers, 'body' => json_encode($email) ); $response = wp_remote_post(POSTMARK_ENDPOINT, $args); if($response['response']['code'] == 200) { return true; } else { return false; } }
What I currently use:
function pm_send_mail($headers, $email){ $args = array( 'headers' => $headers, 'body' => json_encode($email) ); $response = wp_remote_post(POSTMARK_ENDPOINT, $args); if ( is_wp_error( $response ) ) return false; // added to check whether $response is filled by WP_Error, if so: return false if($response['response']['code'] == 200) { return true; } else { return false; } }
https://www.ads-software.com/plugins/postmark-approved-wordpress-plugin/
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Fatal Error’ is closed to new replies.