You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.
Issue: post data can be incorrect in certain circumstances
Cause: save_post action is used for npr_push()
Suggested fix: use publish_post instead
In debugging a problem with audio not being attached to our pushed posts, we discovered an incompatibility between WP-DS-NPR-API and a Wordpress Mu plugin we use, Sitewide Tags. The $post object used in post_to_nprml_story() corresponded to a copy of the original post created by the Sitewide Tags plugin.
This led me to notice that the add_action() function in the plugin file push_story.php that calls npr_push() is attached to Wordpress action hook save_post. This caused a problem, because under some conditions it's possible for save_post to return post data from an unintended post, such as a post revision (or, in this case, the reference copy of the post made by Sitewide Tags).
While save_post does usually work, the better action to use in this case is publish_post, which is a very similar—but not identical—action; publish_post always returns the actual post's data, and only when its transition status goes to 'publish'.
(side note: the decision to use save_post when this plugin was written likely arose because publish_post was previously mistakenly marked as deprecated in the Wordpress API reference)
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Issue: post data can be incorrect in certain circumstances
Cause: save_post action is used for npr_push()
Suggested fix: use publish_post instead
In debugging a problem with audio not being attached to our pushed posts, we discovered an incompatibility between WP-DS-NPR-API and a Wordpress Mu plugin we use, Sitewide Tags. The $post object used in post_to_nprml_story() corresponded to a copy of the original post created by the Sitewide Tags plugin.
This led me to notice that the add_action() function in the plugin file push_story.php that calls npr_push() is attached to Wordpress action hook save_post. This caused a problem, because under some conditions it's possible for save_post to return post data from an unintended post, such as a post revision (or, in this case, the reference copy of the post made by Sitewide Tags).
While save_post does usually work, the better action to use in this case is publish_post, which is a very similar—but not identical—action; publish_post always returns the actual post's data, and only when its transition status goes to 'publish'.
(side note: the decision to use save_post when this plugin was written likely arose because publish_post was previously mistakenly marked as deprecated in the Wordpress API reference)
The text was updated successfully, but these errors were encountered: