Permalink
Browse files

Bugfix: don't overwrite a slug if the user has manually edited it fro…

…m within WordPress. Props Chris Fritz.
  • Loading branch information...
1 parent 09684f0 commit ffded621111af11c16384b045a6ed1819409efbd Charles Johnson committed Nov 28, 2012
Showing with 25 additions and 9 deletions.
  1. +3 −3 feedwordpress.php
  2. +12 −3 readme.txt
  3. +9 −2 syndicatedpost.class.php
  4. +1 −1 syndicationdataqueries.class.php
View
@@ -3,15 +3,15 @@
Plugin Name: FeedWordPress
Plugin URI: http://feedwordpress.radgeek.com/
Description: simple and flexible Atom/RSS syndication for WordPress
-Version: 2012.0810
+Version: 2012.1128
Author: Charles Johnson
Author URI: http://radgeek.com/
License: GPL
*/
/**
* @package FeedWordPress
- * @version 2012.0810
+ * @version 2012.1128
*/
# This uses code derived from:
@@ -34,7 +34,7 @@
# -- Don't change these unless you know what you're doing...
-define ('FEEDWORDPRESS_VERSION', '2012.0810');
+define ('FEEDWORDPRESS_VERSION', '2012.1128');
define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
if (!defined('FEEDWORDPRESS_BLEG')) :
View
@@ -3,7 +3,7 @@ Contributors: Charles Johnson
Donate link: http://feedwordpress.radgeek.com/
Tags: syndication, aggregation, feed, atom, rss
Requires at least: 3.0
-Tested up to: 3.3.2
+Tested up to: 3.4.2
Stable tag: 2011.1019
FeedWordPress syndicates content from feeds you choose into your WordPress weblog.
@@ -96,8 +96,17 @@ outs, see the documentation at the [FeedWordPress project homepage][].
= Trunk =
-* USER-AGENT STRING: FeedWordPress now sends a distinctive User-Agent string
- identifying itself, and noting that it is a feed aggregator.
+* BUGFIX: MANUALLY EDITED POST SLUGS NOT OVERWRITTEN. Thanks to a report
+ by Chris Fritz, I've identified some code that causes post slugs for the
+ posts generated by FWP to be rewritten with every update, even if the
+ user has manually updated the slug from within the WordPress editing
+ interface. This has been fixed: FWP will continue to generate new slugs
+ for syndicated posts, but when syndicated posts are updated, they will
+ retain the slug that they had at the time of the update; any manual
+ changes to the post slug should be preserved.
+
+* USER-AGENT STRING: FeedWordPress now sends a distinctive User-Agent
+ string identifying itself, and noting that it is a feed aggregator.
= 2011.1019 =
View
@@ -30,6 +30,7 @@ class SyndicatedPost {
var $_freshness = null;
var $_wp_id = null;
+ var $_wp_post = null;
/**
* SyndicatedPost constructor: Given a feed item and the source from
@@ -1343,7 +1344,8 @@ function freshness () {
endif;
$this->_freshness = 1; // Updated content
$this->_wp_id = $old_post->ID;
-
+ $this->_wp_post = $old_post;
+
// We want this to keep a running list of all the
// processed update hashes.
$this->post['meta']['syndication_item_hash'] = array_merge(
@@ -1473,8 +1475,13 @@ function store () {
if (!$this->filtered() and $freshness > 0) :
// Filter some individual fields
+ // If there already is a post slug (from syndication or by manual
+ // editing) don't cause WP to overwrite it by sending in a NULL
+ // post_name. Props Chris Fritz 2012-11-28.
+ $post_name = (is_null($this->_wp_post) ? NULL : $this->_wp_post->post_name);
+
// Allow filters to set post slug. Props niska.
- $post_name = apply_filters('syndicated_post_slug', NULL, $this);
+ $post_name = apply_filters('syndicated_post_slug', $post_name, $this);
if (!empty($post_name)) :
$this->post['post_name'] = $post_name;
endif;
@@ -121,7 +121,7 @@ function posts_fields ($fields, &$query) {
if ($f = $query->get('fields')) :
switch ($f) :
case '_synfresh' :
- $fields = "{$wpdb->posts}.ID, {$wpdb->posts}.guid, {$wpdb->posts}.post_modified_gmt";
+ $fields = "{$wpdb->posts}.ID, {$wpdb->posts}.guid, {$wpdb->posts}.post_modified_gmt, {$wpdb->posts}.post_name";
break;
case '_synfrom' :
$fields = "{$wpdb->posts}.ID, {$wpdb->posts}.guid, {$wpdb->posts}.post_title, {$wpdb->postmeta}.meta_value";

0 comments on commit ffded62

Please sign in to comment.