fixing previously unchecked response code for sending; switched any code that earlier deleted database entries to done;
This commit is contained in:
parent
3063d956be
commit
fcf6476f9f
3 changed files with 56 additions and 6 deletions
|
@ -328,7 +328,7 @@ class WP_Webmention_Again_Receiver extends WP_Webmention_Again {
|
||||||
// too many retries, drop this mention and walk away
|
// too many retries, drop this mention and walk away
|
||||||
if ( $received->tries >= static::retry() ) {
|
if ( $received->tries >= static::retry() ) {
|
||||||
static::debug( " this mention was tried earlier and failed too many times, drop it", 5);
|
static::debug( " this mention was tried earlier and failed too many times, drop it", 5);
|
||||||
static::queue_del ( $received->id );
|
//static::queue_del ( $received->id );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +349,8 @@ class WP_Webmention_Again_Receiver extends WP_Webmention_Again {
|
||||||
|
|
||||||
if ( true === $ins ) {
|
if ( true === $ins ) {
|
||||||
static::debug( " duplicate (or something similar): this queue element has to be ignored; deleting queue entry", 5);
|
static::debug( " duplicate (or something similar): this queue element has to be ignored; deleting queue entry", 5);
|
||||||
static::queue_del ( $received->id );
|
//static::queue_del ( $received->id );
|
||||||
|
static::queue_done ( $received->id );
|
||||||
}
|
}
|
||||||
elseif ( is_numeric( $ins ) ) {
|
elseif ( is_numeric( $ins ) ) {
|
||||||
static::debug( " all went well, we have a comment id: {$ins}, deleting queue entry", 5);
|
static::debug( " all went well, we have a comment id: {$ins}, deleting queue entry", 5);
|
||||||
|
|
24
sender.php
24
sender.php
|
@ -217,8 +217,8 @@ class WP_Webmention_Again_Sender extends WP_Webmention_Again {
|
||||||
// try sending
|
// try sending
|
||||||
$s = static::send( $send->source, $send->target );
|
$s = static::send( $send->source, $send->target );
|
||||||
|
|
||||||
if ( is_wp_error ( $s ) ) {
|
if ( false == $s ) {
|
||||||
static::debug( " sending failed: " . $s->get_error_message(), 5);
|
static::debug( " sending failed: ", 5);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
static::debug( " sending succeeded!", 5);
|
static::debug( " sending succeeded!", 5);
|
||||||
|
@ -274,7 +274,25 @@ class WP_Webmention_Again_Sender extends WP_Webmention_Again {
|
||||||
// use the response to do something usefull
|
// use the response to do something usefull
|
||||||
// do_action( 'webmention_post_send', $response, $source, $target, $post_ID );
|
// do_action( 'webmention_post_send', $response, $source, $target, $post_ID );
|
||||||
|
|
||||||
return $response;
|
if ( is_wp_error( $response ) ) {
|
||||||
|
static::debug( "sending failed: " . $response->get_error_message(), 4);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! is_array( $response ) || ! isset( $response['response'] ) || ! isset( $response['response']['code'] ) || empty( $response['response']['code'] ) ) {
|
||||||
|
static::debug( "sending failed: the response is empty", 4);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( 200 <= $response['response']['code'] && 300 > $response['response']['code'] ) {
|
||||||
|
static::debug( "sending succeeded: ${$response['response']['code']}, message: {$response['response']['message']}", 5);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
static::debug( "wrong response code, this sending probably failed: {$response['response']['code']}, message: {$response['response']['message']}", 4);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -332,6 +332,8 @@ class WP_Webmention_Again {
|
||||||
static::debug('Something went wrong: ' . $e->getMessage(), 4);
|
static::debug('Something went wrong: ' . $e->getMessage(), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//do_action ( 'wp_webmention_again_done', $id );
|
||||||
|
|
||||||
return $req;
|
return $req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +356,7 @@ class WP_Webmention_Again {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$dbname = $wpdb->prefix . static::tablename;
|
$dbname = $wpdb->prefix . static::tablename;
|
||||||
|
|
||||||
$q = $wpdb->prepare( "SELECT * FROM `{$dbname}` WHERE `direction` = '%s' and `status` = 0 LIMIT %d;", $direction, $limit );
|
$q = $wpdb->prepare( "SELECT * FROM `{$dbname}` WHERE `direction` = '%s' and `status` = 0 and `tries` < ". static::retry() ." LIMIT %d;", $direction, $limit );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$req = $wpdb->get_results( $q );
|
$req = $wpdb->get_results( $q );
|
||||||
|
@ -405,6 +407,35 @@ class WP_Webmention_Again {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get a single webmention based on id
|
||||||
|
*
|
||||||
|
* @param int $id webmention id
|
||||||
|
*
|
||||||
|
* @return array of webmention
|
||||||
|
*
|
||||||
|
*
|
||||||
|
public static function webmention_get ( $id ) {
|
||||||
|
|
||||||
|
global $wpdb;
|
||||||
|
$dbname = $wpdb->prefix . static::tablename;
|
||||||
|
|
||||||
|
$q = $wpdb->prepare( "SELECT * FROM `{$dbname}` WHERE `id` = '%d'", $id );
|
||||||
|
|
||||||
|
try {
|
||||||
|
$req = $wpdb->get_results( $q );
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
static::debug('Something went wrong: ' . $e->getMessage(), 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty ( $req ) )
|
||||||
|
return $req;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* extended wp_remote_get with debugging
|
* extended wp_remote_get with debugging
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue