Making WordPress.org


Ignore:
Timestamp:
02/04/2018 11:26:05 AM (9 years ago)
Author:
ocean90
Message:

Translate, Plugin Directory: Fill plugin details for existing projects with old data in case the API is unreachable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-plugin-directory/inc/cli/class-set-plugin-project.php

    r5384 r6533  
    4545                }
    4646
     47                $plugin_project = GP::$project->by_path( $plugin_project_path );
     48
    4749                // Get plugin details from the API.
    4850                $plugin_details = $this->get_plugin_details( $plugin_slug );
    … …  
    5052                        WP_CLI::warning( "The plugin API couldn't be reached." );
    5153
    52                         /*
    53                          * That's usally the case for the initial commit.
    54                          * Provide a mockup which contains the necessary plugin details.
    55                          */
    56                         $plugin_details = new stdClass();
    57                         $plugin_details->name = $plugin_slug;
    58                         $plugin_details->short_description = '';
    59                         $plugin_details->stable_tag = 'trunk';
     54                        if ( ! $plugin_project ) {
     55                                /*
     56                                 * That's usally the case for the initial commit.
     57                                 * Provide a mockup which contains the necessary plugin details.
     58                                 */
     59                                $plugin_details = new stdClass();
     60                                $plugin_details->name = $plugin_slug;
     61                                $plugin_details->short_description = '';
     62                                $plugin_details->stable_tag = 'trunk';
     63                        } else {
     64                                // Fill details with old data in case the API is down.
     65                                $plugin_details = new stdClass();
     66                                $plugin_details->name = $plugin_project->name;
     67                                $plugin_details->short_description = $plugin_project->description;
     68                                $plugin_details->stable_tag = 'trunk';
     69                        }
    6070                }
    6171
    … …  
    6878                        'active'            => 1,
    6979                );
    70 
    71                 $plugin_project = GP::$project->by_path( $plugin_project_path );
    7280
    7381                // Is this a new or an existing project?
Note: See TracChangeset for help on using the changeset viewer.