WordPress.org

Making WordPress.org

Changeset 5200


Ignore:
Timestamp:
03/29/2017 11:04:05 PM (2 years ago)
Author:
dd32
Message:

Plugin Directory: Remove the import-from-bbPress code for statuses & plugin posts.
This caused a plugin which had been marked as closed after the directory launch to have it's status set back to publish, this happened as it pulled the previous status from bbPress over.
The only status change which should happen post-commit is the approvad -> published change, which is now handled here.

Fixes #2635

File:
1 edited

Legend:

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

    r5147 r5200  
    5757        $plugin = Plugin_Directory::get_plugin_post( $plugin_slug );
    5858        if ( ! $plugin ) {
    59 // TODO         throw new Exception( "Unknown Plugin" );
     59            throw new Exception( "Unknown Plugin" );
    6060        }
    6161
    6262        $data = $this->export_and_parse_plugin( $plugin_slug );
    63 
    64     // TODO: During development while the bbPress variant is still running, we'll pull details from it and allow importing of any plugin.
    65         $topic = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . PLUGINS_TABLE_PREFIX . 'topics WHERE topic_slug = %s', $plugin_slug ) );
    66 
    67         if ( ! $plugin && ! $topic ) {
    68             throw new Exception( "Unknown Plugin" );
    69         }
    70 
    71         // TODO: During development we're just going to import status from bbPress.
    72         $status = 'publish';
    73         if ( 2 == $topic->topic_open ) {
    74             $status = 'approved';
    75         } elseif ( 2 == $topic->forum_id ) {
    76             $status = 'pending';
    77         } elseif ( 4 == $topic->forum_id || 'rejected-' == substr( $topic->topic_slug, 0, 9 ) ) {
    78             $status = 'rejected';
    79         } elseif ( 1 == $topic->forum_id && 0 == $topic->topic_open ) {
    80             $status = 'closed';
    81         } elseif ( 3 == $topic->topic_open ) {
    82             $status = 'disabled';
    83         }
    84 
    85         $plugin_existed_already = (bool) $plugin;
    86         if ( ! $plugin ) {
    87             $author_ip = $wpdb->get_var( $wpdb->prepare( 'SELECT poster_ip FROM ' . PLUGINS_TABLE_PREFIX . 'posts WHERE topic_id = %s', $topic->topic_id ) );
    88 
    89             add_filter( 'wp_insert_post_data', array( $this, 'filter_wp_insert_post_data' ), 10, 2 );
    90             $plugin = Plugin_Directory::create_plugin_post( array(
    91                 'post_name' => $plugin_slug,
    92                 'post_status' => $status,
    93                 'post_author' => $topic->topic_poster,
    94                 'post_date_gmt' => $topic->topic_start_time,
    95                 'post_date' => $topic->topic_start_time,
    96                 'post_modified' => $topic->topic_time,
    97                 'post_modified_gmt' => $topic->topic_time,
    98                 'meta_input' => array(
    99                     '_author_ip' => $author_ip,
    100                 ),
    101             ) );
    102             remove_filter( 'wp_insert_post_data', array( $this, 'filter_wp_insert_post_data' ) );
    103         }
    104         $plugin->post_status = $status;
    10563
    10664        $readme = $data['readme'];
     
    12987                $plugin->post_modified = $plugin->post_modified_gmt = current_time( 'mysql' );
    13088            }
     89        }
     90
     91        // Plugins should move from 'approved' to 'publish' on first parse
     92        // `export_and_parse_plugin()` will throw an exception in the case where plugin files cannot be found,
     93        // so by this time the plugin should be live.
     94        if ( 'approved' === $plugin->post_status ) {
     95            $plugin->post_status = 'publish';
    13196        }
    13297
Note: See TracChangeset for help on using the changeset viewer.