FeedWordPress - Version 2010.0905

Version Description

  • BUGFIX: CATEGORIES AND TAGS CORRECTLY ASSIGNED IN AUTOMATIC UPDATES. Version 2010.0903 switched over to a new way of assigning categories and tags as part of its support for handling custom taxonomies. Unfortunately, the method that it uses is subjected to some checks of the current user's capabilities, which creates problems for posts that are being inserted into the WordPress database when there is no current user logged in (as, for example, when an update is being carried out from a cron job or automatic update). The result was that posts from cron jobs and automatic updates ended up with no Categories and no Tags being assigned. This bug has now been fixed: in 2010.0905, Tags and Categories should be correctly assigned to all posts, regardless of whether they were added from manual updates, cron jobs, or automatic updates.
Download this release

Release Info

Developer radgeek
Plugin Icon wp plugin FeedWordPress
Version 2010.0905
Comparing to
See all releases

Code changes from version 2010.0903 to 2010.0905

Files changed (3) hide show
  1. feedwordpress.php +3 -3
  2. readme.txt +17 -1
  3. syndicatedpost.class.php +75 -40
feedwordpress.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: FeedWordPress
4
  Plugin URI: http://feedwordpress.radgeek.com/
5
  Description: simple and flexible Atom/RSS syndication for WordPress
6
- Version: 2010.0903
7
  Author: Charles Johnson
8
  Author URI: http://radgeek.com/
9
  License: GPL
@@ -11,7 +11,7 @@ License: GPL
11
 
12
  /**
13
  * @package FeedWordPress
14
- * @version 2010.0903
15
  */
16
 
17
  # This uses code derived from:
@@ -34,7 +34,7 @@ License: GPL
34
 
35
  # -- Don't change these unless you know what you're doing...
36
 
37
- define ('FEEDWORDPRESS_VERSION', '2010.0903');
38
  define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
39
 
40
  if (!defined('FEEDWORDPRESS_BLEG')) :
3
  Plugin Name: FeedWordPress
4
  Plugin URI: http://feedwordpress.radgeek.com/
5
  Description: simple and flexible Atom/RSS syndication for WordPress
6
+ Version: 2010.0905
7
  Author: Charles Johnson
8
  Author URI: http://radgeek.com/
9
  License: GPL
11
 
12
  /**
13
  * @package FeedWordPress
14
+ * @version 2010.0905
15
  */
16
 
17
  # This uses code derived from:
34
 
35
  # -- Don't change these unless you know what you're doing...
36
 
37
+ define ('FEEDWORDPRESS_VERSION', '2010.0905');
38
  define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
39
 
40
  if (!defined('FEEDWORDPRESS_BLEG')) :
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://feedwordpress.radgeek.com/
4
  Tags: syndication, aggregation, feed, atom, rss
5
  Requires at least: 3.0
6
  Tested up to: 3.0.1
7
- Stable tag: 2010.0903
8
 
9
  FeedWordPress syndicates content from feeds you choose into your WordPress weblog.
10
 
@@ -93,6 +93,22 @@ outs, see the documentation at the [FeedWordPress project homepage][].
93
 
94
  == Changelog ==
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  = 2010.0903 =
97
 
98
  * WORDPRESS 3 REQUIRED: Please note that this release of FeedWordPress
4
  Tags: syndication, aggregation, feed, atom, rss
5
  Requires at least: 3.0
6
  Tested up to: 3.0.1
7
+ Stable tag: 2010.0905
8
 
9
  FeedWordPress syndicates content from feeds you choose into your WordPress weblog.
10
 
93
 
94
  == Changelog ==
95
 
96
+ = 2010.0905 =
97
+
98
+ * BUGFIX: CATEGORIES AND TAGS CORRECTLY ASSIGNED IN AUTOMATIC UPDATES.
99
+ Version 2010.0903 switched over to a new way of assigning categories and
100
+ tags as part of its support for handling custom taxonomies.
101
+ Unfortunately, the method that it uses is subjected to some checks of
102
+ the current user's capabilities, which creates problems for posts that
103
+ are being inserted into the WordPress database when there *is* no
104
+ current user logged in (as, for example, when an update is being carried
105
+ out from a cron job or automatic update). The result was that posts
106
+ from cron jobs and automatic updates ended up with no Categories and no
107
+ Tags being assigned. This bug has now been fixed: in 2010.0905, Tags and
108
+ Categories should be correctly assigned to all posts, regardless of
109
+ whether they were added from manual updates, cron jobs, or automatic
110
+ updates.
111
+
112
  = 2010.0903 =
113
 
114
  * WORDPRESS 3 REQUIRED: Please note that this release of FeedWordPress
syndicatedpost.class.php CHANGED
@@ -10,7 +10,7 @@ require_once(dirname(__FILE__).'/feedtime.class.php');
10
  * different feed formats, which may be useful to FeedWordPress users
11
  * who make use of feed data in PHP add-ons and filters.
12
  *
13
- * @version 2010.0814
14
  */
15
  class SyndicatedPost {
16
  var $item = null; // MagpieRSS representation
@@ -1363,8 +1363,8 @@ class SyndicatedPost {
1363
  return $ret;
1364
  } /* function SyndicatedPost::store () */
1365
 
1366
- function insert_new () {
1367
- global $wpdb, $wp_db_version;
1368
 
1369
  $dbpost = $this->normalize_post(/*new=*/ true);
1370
  if (!is_null($dbpost)) :
@@ -1378,41 +1378,33 @@ class SyndicatedPost {
1378
  // user who has `unfiltered_html` capability.
1379
  add_filter('content_save_pre', array($this, 'avoid_kses_munge'), 11);
1380
 
1381
- $this->_wp_id = wp_insert_post($dbpost);
1382
-
1383
- // Turn off ridiculous fucking kludges #1 and #2
1384
- remove_action('_wp_put_post_revision', array($this, 'fix_revision_meta'));
1385
- remove_filter('content_save_pre', array($this, 'avoid_kses_munge'), 11);
1386
-
1387
- $this->validate_post_id($dbpost, array(__CLASS__, __FUNCTION__));
1388
- endif;
1389
- } /* SyndicatedPost::insert_new() */
1390
-
1391
- function update_existing () {
1392
- global $wpdb;
1393
-
1394
- // Why the fuck doesn't wp_insert_post already do this?
1395
- $dbpost = $this->normalize_post(/*new=*/ false);
1396
- if (!is_null($dbpost)) :
1397
- $dbpost['post_pingback'] = false; // Tell WP 2.1 and 2.2 not to process for pingbacks
1398
-
1399
- // This is a ridiculous fucking kludge necessitated by WordPress 2.6 munging authorship meta-data
1400
- add_action('_wp_put_post_revision', array($this, 'fix_revision_meta'));
1401
-
1402
- // Kludge to prevent kses filters from stripping the
1403
- // content of posts when updating without a logged in
1404
- // user who has `unfiltered_html` capability.
1405
- add_filter('content_save_pre', array($this, 'avoid_kses_munge'), 11);
1406
-
1407
- // Don't munge status fields that the user may have reset manually
1408
- if (function_exists('get_post_field')) :
1409
  $doNotMunge = array('post_status', 'comment_status', 'ping_status');
 
1410
  foreach ($doNotMunge as $field) :
1411
  $dbpost[$field] = get_post_field($field, $this->wp_id());
1412
  endforeach;
1413
  endif;
 
 
 
 
 
 
 
 
 
1414
 
1415
  $this->_wp_id = wp_insert_post($dbpost);
 
 
 
 
 
 
 
1416
 
1417
  // Turn off ridiculous fucking kludges #1 and #2
1418
  remove_action('_wp_put_post_revision', array($this, 'fix_revision_meta'));
@@ -1420,6 +1412,14 @@ class SyndicatedPost {
1420
 
1421
  $this->validate_post_id($dbpost, array(__CLASS__, __FUNCTION__));
1422
  endif;
 
 
 
 
 
 
 
 
1423
  } /* SyndicatedPost::update_existing() */
1424
 
1425
  /**
@@ -1543,15 +1543,50 @@ class SyndicatedPost {
1543
  return $wpdb->escape($this->post['post_content']);
1544
  }
1545
 
1546
- // SyndicatedPost::add_rss_meta: adds interesting meta-data to each entry
1547
- // using the space for custom keys. The set of keys and values to add is
1548
- // specified by the keys and values of $post['meta']. This is used to
1549
- // store anything that the WordPress user might want to access from a
1550
- // template concerning the post's original source that isn't provided
1551
- // for by standard WP meta-data (i.e., any interesting data about the
1552
- // syndicated post other than author, title, timestamp, categories, and
1553
- // guid). It's also used to hook into WordPress's support for
1554
- // enclosures.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1555
  function add_rss_meta ($new_status, $old_status, $post) {
1556
  FeedWordPress::diagnostic('syndicated_posts:meta_data', 'Adding post meta-data: {'.implode(", ", array_keys($this->post['meta'])).'}');
1557
 
10
  * different feed formats, which may be useful to FeedWordPress users
11
  * who make use of feed data in PHP add-ons and filters.
12
  *
13
+ * @version 2010.0905
14
  */
15
  class SyndicatedPost {
16
  var $item = null; // MagpieRSS representation
1363
  return $ret;
1364
  } /* function SyndicatedPost::store () */
1365
 
1366
+ function insert_post ($update = false) {
1367
+ global $wpdb;
1368
 
1369
  $dbpost = $this->normalize_post(/*new=*/ true);
1370
  if (!is_null($dbpost)) :
1378
  // user who has `unfiltered_html` capability.
1379
  add_filter('content_save_pre', array($this, 'avoid_kses_munge'), 11);
1380
 
1381
+ if ($update and function_exists('get_post_field')) :
1382
+ // Don't munge status fields that the user may
1383
+ // have reset manually
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1384
  $doNotMunge = array('post_status', 'comment_status', 'ping_status');
1385
+
1386
  foreach ($doNotMunge as $field) :
1387
  $dbpost[$field] = get_post_field($field, $this->wp_id());
1388
  endforeach;
1389
  endif;
1390
+
1391
+ // WP3's wp_insert_post scans current_user_can() for the
1392
+ // tax_input, with no apparent way to override. Ugh.
1393
+ add_action(
1394
+ /*hook=*/ 'transition_post_status',
1395
+ /*callback=*/ array(&$this, 'add_terms'),
1396
+ /*priority=*/ -10001, /* very early */
1397
+ /*arguments=*/ 3
1398
+ );
1399
 
1400
  $this->_wp_id = wp_insert_post($dbpost);
1401
+
1402
+ remove_action(
1403
+ /*hook=*/ 'transition_post_status',
1404
+ /*callback=*/ array(&$this, 'add_terms'),
1405
+ /*priority=*/ -10001, /* very early */
1406
+ /*arguments=*/ 3
1407
+ );
1408
 
1409
  // Turn off ridiculous fucking kludges #1 and #2
1410
  remove_action('_wp_put_post_revision', array($this, 'fix_revision_meta'));
1412
 
1413
  $this->validate_post_id($dbpost, array(__CLASS__, __FUNCTION__));
1414
  endif;
1415
+ } /* function SyndicatedPost::insert_post () */
1416
+
1417
+ function insert_new () {
1418
+ $this->insert_post(/*update=*/ false);
1419
+ } /* SyndicatedPost::insert_new() */
1420
+
1421
+ function update_existing () {
1422
+ $this->insert_post(/*update=*/ true);
1423
  } /* SyndicatedPost::update_existing() */
1424
 
1425
  /**
1543
  return $wpdb->escape($this->post['post_content']);
1544
  }
1545
 
1546
+ /**
1547
+ * SyndicatedPost::add_terms() -- if FeedWordPress is processing an
1548
+ * automatic update, that generally means that wp_insert_post() is being
1549
+ * called under the user credentials of whoever is viewing the blog at
1550
+ * the time -- which usually means no user at all. But wp_insert_post()
1551
+ * checks current_user_can() before assigning any of the terms in a
1552
+ * post's tax_input structure -- which is unfortunate, since
1553
+ * current_user_can() always returns FALSE when there is no current user
1554
+ * logged in. Meaning that automatic updates get no terms assigned.
1555
+ *
1556
+ * So, wp_insert_post() is not going to do the term assignments for us.
1557
+ * If you want something done right....
1558
+ *
1559
+ * @param string $new_status Unused action parameter.
1560
+ * @param string $old_status Unused action parameter.
1561
+ * @param object $post The database record for the post just inserted.
1562
+ */
1563
+ function add_terms ($new_status, $old_status, $post) {
1564
+ if ( is_array($this->post) and isset($this->post['tax_input']) and is_array($this->post['tax_input']) ) :
1565
+ foreach ($this->post['tax_input'] as $taxonomy => $terms) :
1566
+ if (is_array($terms)) :
1567
+ $terms = array_filter($terms); // strip out empties
1568
+ endif;
1569
+
1570
+ wp_set_post_terms($post->ID, $terms, $taxonomy);
1571
+ endforeach;
1572
+ endif;
1573
+ } /* SyndicatedPost::add_terms () */
1574
+
1575
+ /**
1576
+ * SyndicatedPost::add_rss_meta: adds interesting meta-data to each entry
1577
+ * using the space for custom keys. The set of keys and values to add is
1578
+ * specified by the keys and values of $post['meta']. This is used to
1579
+ * store anything that the WordPress user might want to access from a
1580
+ * template concerning the post's original source that isn't provided
1581
+ * for by standard WP meta-data (i.e., any interesting data about the
1582
+ * syndicated post other than author, title, timestamp, categories, and
1583
+ * guid). It's also used to hook into WordPress's support for
1584
+ * enclosures.
1585
+ *
1586
+ * @param string $new_status Unused action parameter.
1587
+ * @param string $old_status Unused action parameter.
1588
+ * @param object $post The database record for the post just inserted.
1589
+ */
1590
  function add_rss_meta ($new_status, $old_status, $post) {
1591
  FeedWordPress::diagnostic('syndicated_posts:meta_data', 'Adding post meta-data: {'.implode(", ", array_keys($this->post['meta'])).'}');
1592