Changeset 6287 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php
- Timestamp:
- 12/19/2017 04:22:37 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php
r6188 r6287 62 62 $data = $this->export_and_parse_plugin( $plugin_slug ); 63 63 64 $readme = $data['readme'];65 $assets = $data['assets'];66 $headers = $data['plugin_headers'];67 $stable_tag = $data['stable_tag'];64 $readme = $data['readme']; 65 $assets = $data['assets']; 66 $headers = $data['plugin_headers']; 67 $stable_tag = $data['stable_tag']; 68 68 $tagged_versions = $data['tagged_versions']; 69 69 … … 89 89 */ 90 90 if ( 91 ( ! isset( $headers->Version ) || $headers->Version != get_post_meta( $plugin->ID, 'version', true ) ) ||91 ( ! isset( $headers->Version ) || $headers->Version != get_post_meta( $plugin->ID, 'version', true ) ) || 92 92 $plugin->post_modified == '0000-00-00 00:00:00' || 93 93 ( $svn_changed_tags && in_array( ( $stable_tag ?: 'trunk' ), $svn_changed_tags, true ) ) … … 150 150 } 151 151 152 update_post_meta( $plugin->ID, 'tagged_versions', 153 update_post_meta( $plugin->ID, 'sections', 152 update_post_meta( $plugin->ID, 'tagged_versions', wp_slash( $tagged_versions ) ); 153 update_post_meta( $plugin->ID, 'sections', wp_slash( array_keys( $readme->sections ) ) ); 154 154 update_post_meta( $plugin->ID, 'assets_screenshots', wp_slash( $assets['screenshot'] ) ); 155 update_post_meta( $plugin->ID, 'assets_icons', 156 update_post_meta( $plugin->ID, 'assets_banners', 157 update_post_meta( $plugin->ID, 'last_updated', 158 update_post_meta( $plugin->ID, 'plugin_status', 155 update_post_meta( $plugin->ID, 'assets_icons', wp_slash( $assets['icon'] ) ); 156 update_post_meta( $plugin->ID, 'assets_banners', wp_slash( $assets['banner'] ) ); 157 update_post_meta( $plugin->ID, 'last_updated', wp_slash( $plugin->post_modified_gmt ) ); 158 update_post_meta( $plugin->ID, 'plugin_status', wp_slash( $plugin->post_status ) ); 159 159 160 160 // Calculate the 'plugin color' from the average color of the banner if provided. This is used for fallback icons. … … 172 172 // Finally, set the new version live. 173 173 update_post_meta( $plugin->ID, 'stable_tag', wp_slash( $stable_tag ) ); 174 update_post_meta( $plugin->ID, 'version', 174 update_post_meta( $plugin->ID, 'version', wp_slash( $headers->Version ) ); 175 175 176 176 // Ensure that the API gets the updated data … … 208 208 $svn_revision_triggered ? 209 209 "{$plugin_slug}: ZIP build triggered by https://plugins.trac.wordpress.org/changeset/{$svn_revision_triggered}" : 210 "{$plugin_slug}: ZIP build triggered by " . php_uname( 'n'),210 "{$plugin_slug}: ZIP build triggered by " . php_uname( 'n' ), 211 211 $stable_tag 212 212 ); 213 } catch ( Exception $e ) {213 } catch ( Exception $e ) { 214 214 return false; 215 215 } … … 247 247 $tagged_versions = array_map( function( $item ) { 248 248 $trimmed_item = rtrim( $item, '/' ); 249 249 250 if ( $trimmed_item == $item ) { 250 251 // If attempting to trim `/` off didn't do anything, it was a file and we want to discard it. … … 288 289 289 290 $trunk_readme_file = self::PLUGIN_SVN_BASE . "/{$plugin_slug}/trunk/{$trunk_readme_file}"; 290 $trunk_readme = new Parser( $trunk_readme_file );291 $trunk_readme = new Parser( $trunk_readme_file ); 291 292 292 293 $stable_tag = $trunk_readme->stable_tag; … … 300 301 array( 301 302 'ignore-externals', 302 'depth' => 'files' 303 'depth' => 'files', 303 304 ) 304 305 ); … … 306 307 if ( ! $svn_export['result'] && '0.' == substr( $stable_tag, 0, 2 ) ) { 307 308 $_stable_tag = substr( $stable_tag, 1 ); 308 $svn_export = SVN::export(309 $svn_export = SVN::export( 309 310 self::PLUGIN_SVN_BASE . "/{$plugin_slug}/tags/{$_stable_tag}", 310 311 $tmp_dir . '/export', 311 312 array( 312 313 'ignore-externals', 313 'depth' => 'files' 314 'depth' => 'files', 314 315 ) 315 316 ); … … 335 336 array( 336 337 'ignore-externals', 337 'depth' => 'files' // Only export the root files, we don't need the rest to read the plugin headers/screenshots338 'depth' => 'files', // Only export the root files, we don't need the rest to read the plugin headers/screenshots 338 339 ) 339 340 ); … … 354 355 355 356 // Now we look in the /assets/ folder for banners, screenshots, and icons. 356 $assets = array( 'screenshot' => array(), 'banner' => array(), 'icon' => array() ); 357 $assets = array( 358 'screenshot' => array(), 359 'banner' => array(), 360 'icon' => array(), 361 ); 357 362 $svn_assets_folder = SVN::ls( self::PLUGIN_SVN_BASE . "/{$plugin_slug}/assets/", true /* verbose */ ); 358 363 if ( $svn_assets_folder ) { // /assets/ may not exist. … … 362 367 continue; 363 368 } 364 $type = $m['type']; 365 $filename = $asset['filename']; 366 $revision = $asset['revision']; 367 $location = 'assets'; 369 370 $type = $m['type']; 371 $filename = $asset['filename']; 372 $revision = $asset['revision']; 373 $location = 'assets'; 368 374 $resolution = isset( $m['resolution'] ) ? $m['resolution'] : false; 375 369 376 $assets[ $type ][ $asset['filename'] ] = compact( 'filename', 'revision', 'resolution', 'location' ); 370 377 } … … 373 380 // Find screenshots in the stable plugin folder (but don't overwrite /assets/) 374 381 foreach ( Filesystem::list_files( "$tmp_dir/export/", false /* non-recursive */, '!^screenshot-\d+\.(jpeg|jpg|png|gif)$!' ) as $plugin_screenshot ) { 375 $filename = basename( $plugin_screenshot );382 $filename = basename( $plugin_screenshot ); 376 383 $screenshot_id = substr( $filename, strpos( $filename, '-' ) + 1 ); 377 384 $screenshot_id = substr( $screenshot_id, 0, strpos( $screenshot_id, '.' ) ); 378 385 379 if ( isset( $assets['screenshot'][ $filename ] 386 if ( isset( $assets['screenshot'][ $filename ] ) ) { 380 387 // Skip it, it exists within /assets/ already 381 388 continue; … … 383 390 384 391 $assets['screenshot'][ $filename ] = array( 385 'filename' => $filename,386 'revision' => $svn_export['revision'],392 'filename' => $filename, 393 'revision' => $svn_export['revision'], 387 394 'resolution' => $screenshot_id, 388 'location' => 'plugin',395 'location' => 'plugin', 389 396 ); 390 397 }
Note: See TracChangeset
for help on using the changeset viewer.