Changeset 5147 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/bin/rebuild-zip.php
- Timestamp:
- 03/13/2017 05:56:27 AM (8 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/bin/rebuild-zip.php
r5139 r5147 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory; 3 use WordPressdotorg\Plugin_Directory\Tools\SVN; 3 4 4 5 // This script should only be called in a CLI environment. … … 7 8 } 8 9 9 ob_start();10 //ob_start(); 10 11 11 $opts = getopt( '', array( 'url:', 'abspath:', 'plugin:', ' changed-tags:', 'async' ) );12 $opts = getopt( '', array( 'url:', 'abspath:', 'plugin:', 'versions:', 'async' ) ); 12 13 13 14 // Guess the default parameters: … … 15 16 $opts['plugin'] = $argv[1]; 16 17 $argv[1] = '--plugin ' . $argv[1]; 18 } 19 if ( empty( $opts ) && $argc == 3 ) { 20 $opts['plugin'] = $argv[1]; 21 $argv[1] = '--plugin ' . $argv[1]; 22 23 $opts['versions'] = $argv[2]; 24 $argv[2] = '--versions ' . $argv[2]; 17 25 } 18 26 if ( empty( $opts['url'] ) ) { … … 22 30 $opts['abspath'] = substr( __DIR__, 0, strpos( __DIR__, 'wp-content' ) ); 23 31 } 24 25 if ( empty( $opts['changed-tags'] ) ) { 26 $opts['changed-tags'] = array( 'trunk' ); 27 } else { 28 $opts['changed-tags'] = explode( ',', $opts['changed-tags'] ); 32 if ( empty( $opts['versions'] ) ) { 33 $opts['versions'] = ''; 29 34 } 30 31 $opts['async'] = isset( $opts['async'] );32 35 33 36 foreach ( array( 'url', 'abspath', 'plugin' ) as $opt ) { … … 36 39 fwrite( STDERR, "Usage: php {$argv[0]} --plugin hello-dolly --abspath /home/example/public_html --url https://wordpress.org/plugins/\n" ); 37 40 fwrite( STDERR, "--url and --abspath will be guessed if possible.\n" ); 38 die();41 exit(1); 39 42 } 40 43 } … … 52 55 fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . " --url " . get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" ); 53 56 } 54 die();57 exit(1); 55 58 } 56 59 57 $plugin_slug 58 $ changed_tags = $opts['changed-tags'];59 $start_time 60 $plugin_slug = $opts['plugin']; 61 $versions = array_filter( array_unique( array_map( 'trim', (array) explode( ',', $opts['versions'] ) ) ), 'strlen' ); 62 $start_time = microtime(1); 60 63 61 // If async, queue it to be parsed instead. 62 if ( $opts['async'] ) { 63 Jobs\Plugin_Import::queue( $plugin_slug, array( 'tags_touched' => $changed_tags ) ); 64 echo "Queueing Import for $plugin_slug... OK\n"; 65 die(); 64 if ( empty( $versions ) ) { 65 // Rebuild them all! 66 $svn_tags = SVN::ls( "http://plugins.svn.wordpress.org/{$plugin_slug}/tags/" ); 67 if ( false === $svn_tags ) { 68 fwrite( STDERR, "Error! Failed to retrieve SVN tag listing." ); 69 exit(1); 70 } 71 72 $versions = array_map( 73 function( $dir ) { return trim( $dir, '/' ); }, 74 $svn_tags 75 ); 76 $versions[] = 'trunk'; 66 77 } 67 78 68 echo "Processing Import for $plugin_slug... "; 79 if ( ! $versions ) { 80 fwrite( STDERR, "Error! No versions specified (or we couldn't find any)" ); 81 exit(1); 82 } 83 84 echo "Rebuilding ZIPs for $plugin_slug... "; 69 85 try { 70 $importer = new CLI\Import; 71 $importer->import_from_svn( $plugin_slug, $changed_tags ); 86 $zip_builder = new ZIP\Builder(); 87 $zip_builder->build( 88 $plugin_slug, 89 $versions, 90 "{$plugin_slug}: Rebuild triggered by " . php_uname('n' ) 91 ); 92 72 93 echo "OK. Took " . round( microtime(1) - $start_time, 2 ) . "s\n"; 73 94 } catch( \Exception $e ) { 74 echo "Failed. Took " . round( microtime(1) - $start_time, 2 ) . "s\n"; 75 76 fwrite( STDERR, "[{$plugin_slug}] Plugin Import Failed: " . $e->getMessage() . "\n" ); 95 fwrite( STDERR, "{$plugin_slug}: Zip Rebuild failed: " . $e->getMessage() . "\n" ); 77 96 exit(1); 78 97 }
Note: See TracChangeset
for help on using the changeset viewer.