Making WordPress.org

Changeset 4565


Ignore:
Timestamp:
12/21/2016 07:44:58 AM (8 years ago)
Author:
dd32
Message:

Plugin Directory: When performing an initial import of a plugin, ensure that the post_modified date is not overridden by the current date.

See #1724.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php

    r4564 r4565  
    8080        }
    8181
     82        $plugin_existed_already = (bool) $plugin;
    8283        if ( ! $plugin ) {
    8384            $author_ip = $wpdb->get_var( $wpdb->prepare( 'SELECT poster_ip FROM ' . PLUGINS_TABLE_PREFIX . 'posts WHERE topic_id = %s', $topic->topic_id ) );
    8485
     86            add_filter( 'wp_insert_post_data', array( $this, 'filter_wp_insert_post_data' ), 10, 2 );
    8587            $plugin = Plugin_Directory::create_plugin_post( array(
    8688                'post_name' => $plugin_slug,
    8789                'post_status' => $status,
    8890                'post_author' => $topic->topic_poster,
    89                 'override_modified_date' => true,
    9091                'post_date_gmt' => $topic->topic_start_time,
    9192                'post_date' => $topic->topic_start_time,
     
    9495                'meta_input' => array(
    9596                    '_author_ip' => $author_ip,
    96                     '_publish'   => $topic->approved,
    9797                ),
    9898            ) );
     99            remove_filter( 'wp_insert_post_data', array( $this, 'filter_wp_insert_post_data' ) );
    99100        }
    100101        $plugin->post_status = $status;
     
    120121        $plugin->post_excerpt = trim( $readme->short_description ) ?: $headers->Description ?: $plugin->post_excerpt;
    121122
    122         // Bump last updated if the version has changed.
     123        // Bump last updated if the version has changed, but only if this isn't a fresh import.
    123124        if ( !isset( $headers->Version ) || $headers->Version != get_post_meta( $plugin->ID, 'version', true ) ) {
    124             $plugin->post_modified = $plugin->post_modified_gmt = current_time( 'mysql' );
     125            if ( $plugin_existed_already ) {
     126                $plugin->post_modified = $plugin->post_modified_gmt = current_time( 'mysql' );
     127            }
    125128        }
    126129
Note: See TracChangeset for help on using the changeset viewer.