Skip to content

Commit

Permalink
Bugfix: don't overwrite a slug if the user has manually edited it fro…
Browse files Browse the repository at this point in the history
…m within WordPress. Props Chris Fritz.
  • Loading branch information
Charles Johnson committed Nov 28, 2012
1 parent 09684f0 commit ffded62
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
6 changes: 3 additions & 3 deletions feedwordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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')) :
Expand Down
15 changes: 12 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 =

Expand Down
11 changes: 9 additions & 2 deletions syndicatedpost.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion syndicationdataqueries.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit ffded62

Please sign in to comment.