Changeset 4520
- Timestamp:
- 12/13/2016 09:44:54 AM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 4 added
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r4484 r4520 43 43 44 44 // Cron tasks. 45 add_action( 'admin_init', array( $this, 'register_cron_tasks' ) ); 46 add_action( 'plugin_directory_meta_sync', array( __NAMESPACE__ . '\Jobs\Meta_Sync', 'cron_trigger' ) ); 45 new Jobs\Manager(); 47 46 48 47 // oEmbed whitlisting. … … 466 465 require_once( __DIR__ . '/libs/site-search/jetpack-search.php' ); 467 466 \Jetpack_Search::instance(); 468 }469 470 }471 472 /**473 * Queue all of our cron tasks.474 */475 function register_cron_tasks() {476 if ( ! wp_next_scheduled ( 'plugin_directory_meta_sync' ) ) {477 wp_schedule_event( time(), 'hourly', 'plugin_directory_meta_sync' );478 467 } 479 468 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php
r4505 r4520 160 160 // Update all readme meta 161 161 foreach ( $this->readme_fields as $readme_field ) { 162 $value = ( 'tested' == $readme_field ) ? $tested : $readme-> field;162 $value = ( 'tested' == $readme_field ) ? $tested : $readme->$readme_field; 163 163 update_post_meta( $plugin->ID, $readme_field, wp_slash( $value ) ); 164 164 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-svn-watcher.php
r4195 r4520 2 2 namespace WordPressdotorg\Plugin_Directory\CLI; 3 3 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 4 use WordPressdotorg\Plugin_Directory\Jobs; 4 5 use WordPressdotorg\Plugin_Directory\Tools\SVN; 5 6 use Exception; … … 14 15 const SVN_URL = 'https://plugins.svn.wordpress.org/'; 15 16 const PHP = '/usr/local/bin/php'; 16 const PROCESS_I18N = true;17 18 public function __construct() {19 $this->watch();20 }21 17 22 18 /** … … 24 20 */ 25 21 public function watch() { 26 $svn_rev_option_name = 'svn_rev_ ' . php_uname( 'n' );22 $svn_rev_option_name = 'svn_rev_last_processed'; 27 23 28 24 $last_rev_processed = $this->get_option( $svn_rev_option_name ); … … 37 33 } 38 34 39 if ( $last_rev_processed == $head_rev ) {35 if ( $last_rev_processed >= $head_rev ) { 40 36 // Nothing to do! 41 37 return; 42 38 } 39 40 // We don't want to re-process the last rev processed, so bump past it 41 $last_rev_processed++; 43 42 44 43 echo "Processing changes from $last_rev_processed to $head_rev..\n"; … … 51 50 } 52 51 53 $esc_plugin_slug = escapeshellarg( $plugin_slug ); 54 $esc_changed_tags = escapeshellarg( implode( ',', $plugin_data['tags_touched'] ) ); 55 $esc_revision = escapeshellarg( $plugin_data['revision'] ); 52 Jobs\Plugin_Import::queue( $plugin_slug, $plugin_data ); 56 53 57 $cmd = self::PHP . ' ' . dirname( __DIR__ ) . "/bin/import-plugin.php --plugin {$esc_plugin_slug} --changed-tags {$esc_changed_tags} --revision {$esc_revision}"; 58 59 echo "\$$cmd\n"; 60 echo shell_exec( $cmd ) . "\n"; 61 62 if ( self::PROCESS_I18N && 'nothing-much' === $plugin_slug ) { 63 $plugin = Plugin_Directory::get_plugin_post( $plugin_slug ); 64 $stable_tag = $plugin->stable_tag; 65 66 $i18n_processes = []; 67 if ( in_array( 'trunk', $plugin_data['tags_touched'] ) ) { 68 if ( $plugin_data['code_touched'] ) { 69 $i18n_processes[] = 'trunk|code'; 70 } 71 if ( $plugin_data['readme_touched'] ) { 72 $i18n_processes[] = 'trunk|readme'; 73 } 74 } 75 if ( in_array( $stable_tag, $plugin_data['tags_touched'] ) ) { 76 if ( $plugin_data['code_touched'] ) { 77 $i18n_processes[] = "{$stable_tag}|code"; 78 } 79 if ( $plugin_data['readme_touched'] ) { 80 $i18n_processes[] = "{$stable_tag}|readme"; 81 } 82 } 83 84 $this->process_i18n_for_plugin( $plugin_slug, $i18n_processes ); 85 } 86 87 $this->update_option( $svn_rev_option_name, $plugin_data['revision'] ); 54 $this->update_option( $svn_rev_option_name, min( $plugin_data['revisions'] ) ); 88 55 } 89 56 90 57 // Update it to HEAD again. We do this as $plugin_data['revision'] may be set to PREVHEAD in the event the latest 2 (or more) commits are to a single plugin. 91 58 $this->update_option( $svn_rev_option_name, $head_rev ); 92 }93 94 /**95 * Processes i18n import tasks.96 *97 * @param string $plugin_slug98 * @param array $i18n_processes99 */100 protected function process_i18n_for_plugin( $plugin_slug, $i18n_processes ) {101 foreach ( $i18n_processes as $process ) {102 list( $tag, $type ) = explode( '|', $process );103 104 $esc_plugin_slug = escapeshellarg( $plugin_slug );105 $esc_tag = escapeshellarg( $tag );106 $esc_type = escapeshellarg( $type );107 108 $cmd = self::PHP . ' ' . dirname( __DIR__ ) . "/bin/import-plugin-to-glotpress.php --plugin {$esc_plugin_slug} --tag {$esc_tag} --type {$esc_type}";109 110 echo "\n\$$cmd\n";111 echo shell_exec( $cmd ) . "\n";112 }113 59 } 114 60 … … 123 69 124 70 $logs = SVN::log( self::SVN_URL, array( $rev, $head_rev ) ); 125 if ( $logs['error '] ) {126 throw new Exception( "Could not fetch plugins.svn logs: " . implode( ', ', $logs['error '] ) );71 if ( $logs['errors'] ) { 72 throw new Exception( "Could not fetch plugins.svn logs: " . implode( ', ', $logs['errors'] ) ); 127 73 } 128 74 129 // If no changes (either no log entries, or HEAD was the same as $rev)130 if ( ! count( $logs['log'] ) || ( 1 == count( $logs['log'] ) && $rev == array_keys( $logs['log'] )[0] )) {75 // nothing new to report 76 if ( ! $logs['log'] ) { 131 77 return array(); 132 78 } … … 144 90 'code_touched' => false, 145 91 'assets_touched' => false, 146 'revision ' => PHP_INT_MAX,92 'revisions' => array(), 147 93 ); 148 94 } … … 150 96 151 97 // Keep track of the lowest revision number we've seen for this plugin 152 $plugin['revision '] = min( $plugin['revision'], $log['revision'] );98 $plugin['revisions'][] = $log['revision']; 153 99 foreach ( $log['paths'] as $path ) { 154 100 $path_parts = explode('/', trim( $path, '/' ) ); … … 183 129 // Sort plugins by minimum revision, it should already be in this order, but double check. 184 130 uasort( $plugins, function( $a, $b ) { 185 if ( $a['revision'] == $b['revision']) {131 if ( min( $a['revisions'] ) == min( $b['revisions'] ) ) { 186 132 return 0; 187 133 } 188 134 189 return ( $a['revision'] < $b['revision']) ? -1 : 1;135 return ( min( $a['revisions'] ) < min( $b['revisions'] ) ) ? -1 : 1; 190 136 } ); 191 137 … … 207 153 208 154 /** 209 * An implementation of `get_option() ~which doesn't utilise the cache.155 * An implementation of `get_option()` which doesn't utilise the cache. 210 156 * As this is a long-running script, we don't want to hit an alloptions race condition bug. 211 157 *
Note: See TracChangeset
for help on using the changeset viewer.