Changeset 5444 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n/class-code-import.php
- Timestamp:
- 04/30/2017 04:00:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n/class-code-import.php
r5198 r5444 2 2 namespace WordPressdotorg\Plugin_Directory\CLI\I18N; 3 3 4 use Exception; 4 5 use WordPressdotorg\Plugin_Directory\Readme\Parser; 6 use WordPressdotorg\Plugin_Directory\Tools\Filesystem; 5 7 use WordPressdotorg\Plugin_Directory\Tools\SVN; 6 use WordPressdotorg\Plugin_Directory\Tools\Filesystem;7 use Exception;8 8 use WP_Error; 9 9 … … 14 14 */ 15 15 class Code_Import extends I18n_Import { 16 const PLUGIN_SVN_BASE = 'https://plugins.svn.wordpress.org';17 18 /**19 * Slug of the plugin.20 *21 * @var string22 */23 private $plugin;24 25 /**26 * Constructor.27 *28 * @param string $plugin The plugin slug.29 */30 public function __construct( $plugin ) {31 $this->plugin = $plugin;32 }33 16 34 17 /** … … 40 23 */ 41 24 public function import_from_tag( $tag ) { 42 $ plugin_url = self::PLUGIN_SVN_BASE . "/{$this->plugin}/{$tag}";25 $svn_url = $this->get_plugin_svn_url( $tag ); 43 26 44 $files = SVN::ls( $ plugin_url );27 $files = SVN::ls( $svn_url ); 45 28 if ( ! $files ) { 46 29 throw new Exception( "Plugin has no files in {$tag}." ); … … 50 33 $export_directory = $tmp_directory . '/export'; 51 34 52 $res = SVN::export( $ plugin_url, $export_directory, [ 'ignore-externals' ] );35 $res = SVN::export( $svn_url, $export_directory, [ 'ignore-externals' ] ); 53 36 if ( ! $res['result'] ) { 54 37 throw new Exception( 'Plugin export failed.' ); … … 57 40 $valid = $this->is_plugin_valid( $export_directory ); 58 41 if ( is_wp_error( $valid ) ) { 59 throw new Exception( 'Plugin is not compatible with language packs .');42 throw new Exception( 'Plugin is not compatible with language packs: ' . $valid->get_error_message() ); 60 43 } 61 44 … … 67 50 $makepot = new \MakePOT; 68 51 69 if ( !$makepot->wp_plugin( $export_directory, $pot_file, $this->plugin ) || ! file_exists( $pot_file ) ) {52 if ( $makepot->wp_plugin( $export_directory, $pot_file, $this->plugin ) || ! file_exists( $pot_file ) ) { 70 53 throw new Exception( "POT file couldn't be created." ); 71 54 } … … 94 77 */ 95 78 private function is_plugin_valid( $export_directory ) { 96 $error = new WP_Error();97 79 $readme = new Parser( $this->find_readme_file( $export_directory ) ); 98 80 99 81 // Whether plugin files should be checked for valid text domains. 100 82 if ( empty( $readme->requires ) || version_compare( $readme->requires, '4.6', '<' ) ) { 83 $error = new WP_Error(); 101 84 $esc_export_directory = escapeshellarg( $export_directory ); 102 85 … … 122 105 return $error; 123 106 } 124 125 107 } 126 108
Note: See TracChangeset
for help on using the changeset viewer.