Changeset 6287 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/bin/rebuild-zip.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/bin/rebuild-zip.php
r6235 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory; 3 3 4 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 4 5 use WordPressdotorg\Plugin_Directory\Tools\SVN; … … 17 18 if ( empty( $opts ) && $argc == 2 ) { 18 19 $opts['plugin'] = $argv[1]; 19 $argv[1] = '--plugin ' . $argv[1];20 $argv[1] = '--plugin ' . $argv[1]; 20 21 } 21 22 if ( empty( $opts ) && $argc == 3 ) { 22 23 $opts['plugin'] = $argv[1]; 23 $argv[1] = '--plugin ' . $argv[1];24 $argv[1] = '--plugin ' . $argv[1]; 24 25 25 26 $opts['versions'] = $argv[2]; 26 $argv[2] = '--versions ' . $argv[2];27 $argv[2] = '--versions ' . $argv[2]; 27 28 } 28 29 if ( empty( $opts['url'] ) ) { … … 41 42 fwrite( STDERR, "Usage: php {$argv[0]} --plugin hello-dolly --abspath /home/example/public_html --url https://wordpress.org/plugins/\n" ); 42 43 fwrite( STDERR, "--url and --abspath will be guessed if possible.\n" ); 43 exit( 1);44 exit( 1 ); 44 45 } 45 46 } … … 49 50 $_SERVER['REQUEST_URI'] = parse_url( $opts['url'], PHP_URL_PATH ); 50 51 51 include rtrim( $opts['abspath'], '/' ) . '/wp-load.php';52 require rtrim( $opts['abspath'], '/' ) . '/wp-load.php'; 52 53 53 54 if ( ! class_exists( '\WordPressdotorg\Plugin_Directory\Plugin_Directory' ) ) { … … 55 56 if ( defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) { 56 57 fwrite( STDERR, "Run the following command instead:\n" ); 57 fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . " --url ". get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" );58 fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . ' --url ' . get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" ); 58 59 } 59 exit( 1);60 exit( 1 ); 60 61 } 61 62 62 63 $plugin_slug = $opts['plugin']; 63 64 $versions = array_filter( array_unique( array_map( 'trim', (array) explode( ',', $opts['versions'] ) ) ), 'strlen' ); 64 $start_time = microtime( 1);65 $start_time = microtime( 1 ); 65 66 66 67 if ( empty( $versions ) ) { … … 72 73 } 73 74 74 $versions = array_map( 75 function( $dir ) { return trim( $dir, '/' ); }, 76 $svn_tags 77 ); 75 $versions = array_map( function( $dir ) { 76 return trim( $dir, '/' ); 77 }, $svn_tags ); 78 78 $versions[] = 'trunk'; 79 79 } … … 81 81 if ( ! $versions ) { 82 82 fwrite( STDERR, "{$plugin_slug}: Error! No versions specified.\n" ); 83 exit( 1);83 exit( 1 ); 84 84 } 85 85 … … 90 90 $plugin_post = Plugin_Directory::get_plugin_post( $plugin_slug ); 91 91 if ( ! $plugin_post ) { 92 throw new Exception( "Could not locate plugin post");92 throw new Exception( 'Could not locate plugin post' ); 93 93 } 94 94 $stable_tag = get_post_meta( $plugin_post->ID, 'stable_tag', true ) ?? 'trunk'; … … 99 99 $plugin_slug, 100 100 $versions_to_build, 101 "{$plugin_slug}: Rebuild triggered by " . php_uname( 'n' ),101 "{$plugin_slug}: Rebuild triggered by " . php_uname( 'n' ), 102 102 $stable_tag 103 103 ); 104 104 } 105 105 106 echo "OK. Took " . round( microtime(1) - $start_time, 2 ). "s\n";107 } catch ( Exception $e ) {106 echo 'OK. Took ' . round( microtime( 1 ) - $start_time, 2 ) . "s\n"; 107 } catch ( Exception $e ) { 108 108 fwrite( STDERR, "{$plugin_slug}: Zip Rebuild failed: " . $e->getMessage() . "\n" ); 109 echo "Failed. Took " . round( microtime(1) - $start_time, 2 ). "s\n";110 exit( 1);109 echo 'Failed. Took ' . round( microtime( 1 ) - $start_time, 2 ) . "s\n"; 110 exit( 1 ); 111 111 }
Note: See TracChangeset
for help on using the changeset viewer.