WordPress.org

Make WordPress Core

Changeset 4077


Ignore:
Timestamp:
08/07/2006 03:50:55 AM (12 years ago)
Author:
ryan
Message:

Rework wp_publish_post() to use wp_update_post() again while turning off filters. Clear the cron schedule for a post when the post timestamp is updated. #2715 #2737

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-cron.php

    r3636 r4077  
    88
    99$crons = get_option('cron');
    10 if (!is_array($crons) || array_shift(array_keys($crons)) > time())
     10$keys = array_keys($crons);
     11if (!is_array($crons) || $keys[0] > time())
    1112    return;
    1213foreach ($crons as $timestamp => $cronhooks) {
  • trunk/wp-includes/cron.php

    r3931 r4077  
    5151
    5252function wp_clear_scheduled_hook( $hook ) {
    53     while ( $timestamp = wp_next_scheduled( $hook ) )
     53    $args = array_slice( func_get_args(), 1 );
     54   
     55    while ( $timestamp = wp_next_scheduled( $hook, $args ) )
    5456        wp_unschedule_event( $timestamp, $hook );
    5557}
    5658
    57 function wp_next_scheduled( $hook ) {
     59function wp_next_scheduled( $hook, $args = '' ) {
    5860    $crons = get_option( 'cron' );
    5961    if ( empty($crons) )
    6062        return false;
    6163    foreach ( $crons as $timestamp => $cron )
    62         if ( isset( $cron[$hook] ) )
    63             return $timestamp;
     64        if ( isset( $cron[$hook] ) ) {
     65            if ( empty($args) )
     66                return $timestamp;
     67            if ( $args == $cron[$hook]['args'] )
     68                return $timestamp;
     69        }
    6470    return false;
    6571}
     
    9399
    94100    $keys = array_keys( $crons );
    95     if ( array_shift( $keys ) > time() )
     101    if ( $keys[0] > time() )
    96102        return;
    97103
  • trunk/wp-includes/post.php

    r4074 r4077  
    497497
    498498    // Get the basics.
    499     $post_content    = apply_filters('content_save_pre',   $post_content);
    500     $post_excerpt    = apply_filters('excerpt_save_pre',   $post_excerpt);
    501     $post_title      = apply_filters('title_save_pre',     $post_title);
    502     $post_category   = apply_filters('category_save_pre',  $post_category);
    503     $post_status     = apply_filters('status_save_pre',    $post_status);
    504     $post_name       = apply_filters('name_save_pre',      $post_name);
    505     $comment_status  = apply_filters('comment_status_pre', $comment_status);
    506     $ping_status     = apply_filters('ping_status_pre',    $ping_status);
     499    if ( empty($no_filter) ) {
     500        $post_content    = apply_filters('content_save_pre',   $post_content);
     501        $post_excerpt    = apply_filters('excerpt_save_pre',   $post_excerpt);
     502        $post_title      = apply_filters('title_save_pre',     $post_title);
     503        $post_category   = apply_filters('category_save_pre',  $post_category);
     504        $post_status     = apply_filters('status_save_pre',    $post_status);
     505        $post_name       = apply_filters('name_save_pre',      $post_name);
     506        $comment_status  = apply_filters('comment_status_pre', $comment_status);
     507        $ping_status     = apply_filters('ping_status_pre',    $ping_status);
     508    }
    507509
    508510    // Make sure we set a valid category
     
    545547            $post_date_gmt = get_gmt_from_date($post_date);
    546548    }
    547 
     549       
    548550    if ( 'publish' == $post_status ) {
    549551        $now = gmdate('Y-m-d H:i:59');
     
    659661
    660662    if ($post_status == 'publish' && $post_type == 'post') {
    661         wp_publish_post($post_ID);
     663        do_action('publish_post', $post_ID);
     664
     665        if ( !defined('WP_IMPORTING') ) {
     666            if ( $post_pingback )
     667                $result = $wpdb->query("
     668                    INSERT INTO $wpdb->postmeta
     669                    (post_id,meta_key,meta_value)
     670                    VALUES ('$post_ID','_pingme','1')
     671                ");
     672            $result = $wpdb->query("
     673                INSERT INTO $wpdb->postmeta
     674                (post_id,meta_key,meta_value)
     675                VALUES ('$post_ID','_encloseme','1')
     676            ");
     677            wp_schedule_single_event(time(), 'do_pings');
     678        }
    662679    } else if ($post_type == 'page') {
    663680        wp_cache_delete('all_page_ids', 'pages');
     
    673690
    674691    if ( 'future' == $post_status ) {
     692        wp_clear_scheduled_hook('publish_future_post', $post_ID);
    675693        wp_schedule_single_event(mysql2date('U', $post_date), 'publish_future_post', $post_ID);
    676694    }
     
    723741
    724742function wp_publish_post($post_id) {
    725     global $wpdb;
    726 
    727743    $post = get_post($post_id);
    728744
     
    730746        return;
    731747
    732     if ( 'publish' != $post->post_status )
    733         $wpdb->query("UPDATE IGNORE $wpdb->posts SET post_status = 'publish' WHERE ID = $post_id");
    734 
    735     do_action('publish_post', $post_id);
    736 
    737     if ( defined('WP_IMPORTING') )
     748    if ( 'publish' == $post->post_status )
    738749        return;
    739750
    740     $post_pingback = get_option('default_pingback_flag');
    741     if ( $post_pingback )
    742         $result = $wpdb->query("
    743             INSERT INTO $wpdb->postmeta
    744             (post_id,meta_key,meta_value)
    745             VALUES ('$post_ID','_pingme','1')
    746         ");
    747 
    748     $result = $wpdb->query("
    749             INSERT INTO $wpdb->postmeta
    750             (post_id,meta_key,meta_value)
    751             VALUES ('$post_ID','_encloseme','1')
    752         ");
    753 
    754     wp_schedule_single_event(time(), 'do_pings');
     751    return wp_update_post(array('post_status' => 'publish', 'ID' => $post_id, 'no_filter' => true));
    755752}
    756753
Note: See TracChangeset for help on using the changeset viewer.