Ticket #1347 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

'publish' and 'editpost' have different flow in wp-admin/post.php

Reported by: skippy Assigned to: matt
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

post.php.diff (0.8 kB) - added by skippy on 05/21/05 06:39:02.

Change History

05/11/05 19:42:04 changed by skippy

  • Patch set to No.

05/12/05 02:38:48 changed by bennettmcelwee

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

05/12/05 23:28:15 changed by MC_incubus

  • 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

05/13/05 21:48:38 changed by matt

  • 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.

05/21/05 06:39:02 changed by skippy

  • attachment post.php.diff added.