Ticket #1347 (closed defect (bug): fixed)
'publish' and 'editpost' have different flow in wp-admin/post.php
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Optimization | Version: | 1.5.1 |
| Severity: | minor | Keywords: | |
| Cc: |
Description
In /wp-admin/post.php, the flow of sending pings and calling publish_post plugins is different, depending on whether the action is "publish" or "editpost".
When in the 'post' case, pings are sent, then plugins using the publish_post action are activated. When in the 'editpost' case, plugins on publish_post are executed, then pings are sent.
I recommend standardizing on one; preferably calling plugins first, then doing pings.
Attachments
Change History
comment:2
bennettmcelwee — 7 years ago
Action hooks should definitely be called before pingback/trackback/enclosures. A number of people in the forums (and me too) have problems with posts taking forever to complete because these communications operations take too long. In this case, the script terminates and the plugins never get called.
Here's how to fix this.
For the 'post' case, from post.php (1.5.1 release): <pre> 195: if ('publish' == $post_status) { 196: if ($post_pingback) 196: pingback($content, $post_ID); 197: do_enclose( $content, $post_ID ); 198: do_trackbacks($post_ID); 199: do_action('publish_post', $post_ID); 200: } </pre> The do_action from line 199 should move to line 196 at the top of the loop. This ensures that the post is completely published before pinging and trackbacking, etc.
For the 'editpost' case, from post.php (1.5.1 release): <pre> 431: 432: if ($post_status == 'publish') { 433: do_action('publish_post', $post_ID); 434: do_trackbacks($post_ID); 435: do_enclose( $content, $post_ID ); 436: if ( get_option('default_pingback_flag') ) 437: pingback($content, $post_ID); 438: } ... 448: do_action('edit_post', $post_ID); </pre> The do_action from line 448 should move to line 431 above the loop. This ensures that the edit is complete before pinging and trackbacking, etc. It also makes sense because the post must notionally be edited before it can be published, so the 'edit_post' hook should appear before the 'publish_post'.
edited on: 05-12-05 02:40
edited on: 05-12-05 02:42
comment:3
MC_incubus — 7 years ago
- Patch changed from No to Yes
Patch uploaded with bennettmcelwee's changes.
Can anyone think of any reason we shouldn't do this?
edited on: 05-12-05 23:28
- Owner changed from anonymous to matt
- fixed_in_version set to 1.5.1.1
- Status changed from new to closed
- Resolution changed from 10 to 20

