Skip to content

pp_get_post_id mistakenly assumes post is glob

Home Forums Technical Issues pp_get_post_id mistakenly assumes post is glob

This topic contains 1 reply, has 2 voices, and was last updated by 3 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #22515 Reply

    When creating a new post using wp_insert_post we should get a post without a post_parent (set to ID of 0), however the plugin is giving us a post_parent of the parent of the current page. I think I’ve nailed it down to line 12 of pp-collaborative-editing/admin/post-save-hierarchical_ppce.php where it says $post = pp_get_post_id();

    This section of the code has no context of what is going on, whether we are updating a post or creating a new one. It just assumes we are working off the current global $post object, which is not true if you are trying to programmatically create a post. Basically, the program flow follows these steps:

    1. We call wp_insert_post to create a new post, explicitly setting the post_parent argument to 0
    2. The WP core code calls sanitize_post within wp_insert_post
    3. sanitize_posts calls sanitize_post_field
    4. sanitize_post_field calls the pre_post_parent filter
    5. The pre_post_filter calls PPCE_AdminFilters::flt_page_parent
    6. PPCE_AdminFilters::flt_page_parent returns PPCE_PostSaveHierarchical::flt_page_parent
    7. This is where the code then calls pp_get_post_id which mistakenly assumes which post we are working on as the global $post

    Since this is happening on the wp_insert_post, the PPCE plugin is basically making a wrongful assumption in each time that a post is inserted. We have one confirmed scenario where this is happening, but it could definitely happen in other places.

    #22557 Reply

    [ login required ]

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Registered members have full access to Pro support forums here.

Feel free to log in or purchase a support key.