diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..30e5adf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +webmentions.log diff --git a/readme.txt b/readme.txt index 33a4a9b..7651c23 100644 --- a/readme.txt +++ b/readme.txt @@ -3,11 +3,10 @@ Contributors: cadeyrn Donate link: https://paypal.me/petermolnar/3 Tags: webmention, pingback, indieweb Requires at least: 4.3 -Tested up to: 4.4.2 -Stable tag: 0.5.1 +Tested up to: 4.5.3 +Stable tag: 0.6 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html -Required minimum PHP version: 5.3 Alternative [Webmentions](http://indiewebcamp.com/webmention-spec) plugin for WordPress @@ -33,6 +32,14 @@ Version numbering logic: * every .B version indicates new features. * every ..C indicates bugfixes for A.B version. += 0.6 = +*2016-07-09* + +* converted in-database queue to real queue +* keeping incoming and outgoing webmentions in webmentions.log in the plugin directory +* trigger archive.org save of source in case of incoming and target in case of outgoing webmentions + + = 0.5.1 = *2016-03-08* diff --git a/receiver.php b/receiver.php index 0de7de2..3a90961 100644 --- a/receiver.php +++ b/receiver.php @@ -273,6 +273,9 @@ class WP_Webmention_Again_Receiver extends WP_Webmention_Again { //$r = static::queue_receive( $source, $target, $post_id ); $r = static::queue_add( 'in', $source, $target, 'post', $post_id ); + // trigger archive call + wp_schedule_single_event( time() + 120, 'trigger_archive_org', array ( 'url' => $source ) ); + if ( true == $r ) { status_header( 202 ); echo 'Webmention accepted in the queue.'; @@ -324,14 +327,14 @@ class WP_Webmention_Again_Receiver extends WP_Webmention_Again { if ( ! static::is_post( $post ) ) { static::debug( " no post found for this mention, try again later, who knows?", 6); - //static::queue_del ( $received->id ); + static::queue_del ( $received->id ); continue; } // too many retries, drop this mention and walk away if ( $received->tries >= static::retry() ) { 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; } @@ -349,12 +352,11 @@ class WP_Webmention_Again_Receiver extends WP_Webmention_Again { if ( true === $ins ) { static::debug( " duplicate (or something similar): this queue element has to be ignored; deleting queue entry", 5); - //static::queue_del ( $received->id ); - static::queue_done ( $received->id ); + static::queue_del ( $received->id ); } elseif ( is_numeric( $ins ) ) { static::debug( " all went well, we have a comment id: {$ins}, deleting queue entry", 5); - static::queue_done ( $received->id ); + static::queue_del ( $received->id ); } else { static::debug( "This is unexpected. Try again.", 6); diff --git a/sender.php b/sender.php index 22efe9d..8c411d6 100644 --- a/sender.php +++ b/sender.php @@ -216,7 +216,7 @@ class WP_Webmention_Again_Sender extends WP_Webmention_Again { // too many retries, drop this mention and walk away if ( $send->tries >= static::retry() ) { static::debug( " this mention was tried earlier and failed too many times, drop it", 5); - static::queue_done ( $send->id ); + static::queue_del( $send->id ); continue; } @@ -238,7 +238,7 @@ class WP_Webmention_Again_Sender extends WP_Webmention_Again { //add_ping( $send->object_id, $send->target ); //} - static::queue_done ( $send->id, $s ); + static::queue_del ( $send->id ); } } } @@ -267,7 +267,10 @@ class WP_Webmention_Again_Sender extends WP_Webmention_Again { ) { static::debug("Refusing to selfping the self domain", 6); return false; - } + } + + // trigger archive call here + wp_schedule_single_event( time() + 120, 'trigger_archive_org', array ( 'url' => $target ) ); // discover the webmention endpoint $webmention_server_url = static::discover_endpoint( $target ); diff --git a/vendor/mf2/mf2/bin/fetch-mf2 b/vendor/mf2/mf2/bin/fetch-mf2 old mode 100755 new mode 100644 diff --git a/vendor/mf2/mf2/bin/parse-mf2 b/vendor/mf2/mf2/bin/parse-mf2 old mode 100755 new mode 100644 diff --git a/wp-webmention-again.php b/wp-webmention-again.php index 6fe3498..706a62e 100644 --- a/wp-webmention-again.php +++ b/wp-webmention-again.php @@ -3,11 +3,10 @@ Plugin Name: wp-webmention-again Plugin URI: https://github.com/petermolnar/wp-webmention-again Description: -Version: 0.5.1 +Version: 0.6 Author: Peter Molnar Author URI: http://petermolnar.eu/ License: GPLv3 -Required minimum PHP version: 5.3 */ if ( ! class_exists( 'WP_Webmention_Again' ) ): @@ -30,6 +29,8 @@ class WP_Webmention_Again { // queue & history table name const tablename = 'webmentions'; + const logfile = __DIR__ . '/webmentions.log'; + /** * regular cron interval for processing incoming * @@ -88,6 +89,8 @@ class WP_Webmention_Again { // extend current cron schedules with our entry add_filter( 'cron_schedules', array(&$this, 'add_cron_schedule' ) ); + add_action( 'trigger_archive_org', array( &$this, 'archive' ) ); + static::lookfordeleted(); } @@ -266,6 +269,8 @@ class WP_Webmention_Again { static::debug('Something went wrong: ' . $e->getMessage(), 4); } + static::log ( $direction, $source, $target ); + return $wpdb->insert_id; } @@ -710,6 +715,30 @@ class WP_Webmention_Again { } + /** + */ + public static function log( $direction, $source, $target, $object, $object_id, $epoch ) { + $date = date("c"); + $logmsg = "{$date} {$direction} {$source} {$target}\n"; + + file_put_contents ( static::logfile , $logmsg, FILE_APPEND|LOCK_EX ); + } + + /** + * + */ + public static function archive( $url ) { + $args = array( + 'timeout' => 60, + 'redirection' => 5, + 'httpversion' => '1.1', + 'user-agent' => 'Lynx/2.8.9dev.1 libwww-FM/2.14 SSL-MM/1.4.1', + ); + + return wp_remote_get( 'https://web.archive.org/save/' . $url ); + } + + } require ( __DIR__ . '/sender.php' );