Changeset 11229
- Timestamp:
- 09/14/2021 06:09:50 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-wporg-themes-upload.php
r11182 r11229 201 201 202 202 /** 203 * Process a theme update, from files that are already in SVN. 204 * 205 * @param string $slug The theme slug to process. Must exist. 206 * @param string $version The theme version to process. Must exist. 207 * @param int $changeset The SVN revision if known. Optional. 208 * @param string $author The SVN author if known. Optional. 209 * @return true|WP_Error See ::import() for error conditions. 210 */ 211 public function process_update_from_svn( $slug, $version, $changeset = 0, $author = '' ) { 212 $this->reset_properties(); 213 214 $this->theme_slug = $slug; 215 216 // Check out from SVN. 217 $this->create_tmp_dirs( $slug . '.' . $version ); 218 $esc_svn = escapeshellarg( "https://themes.svn.wordpress.org/{$slug}/{$version}/" ); 219 $this->exec_with_notify( 220 self::SVN . " export {$esc_svn} {$this->theme_dir} --force", // force as we've created the directory already. 221 $output, 222 $return_var 223 ); 224 if ( $return_var ) { 225 return new WP_Error( 226 'svn_error', 227 implode( "\n", $output ) 228 ); 229 } 230 231 // Fetch data from SVN if not known. 232 if ( ! $changeset ) { 233 $changeset = (int) trim( $this->exec_with_notify( self::SVN . " info --show-item=last-changed-revision {$esc_svn}" ) ); 234 } 235 if ( ! $author ) { 236 $author = trim( $this->exec_with_notify( self::SVN . " info --show-item=last-changed-author {$esc_svn}" ) ); 237 } 238 239 // Get the revision. 240 $this->trac_changeset = $changeset; 241 242 // Get the author. 243 if ( $author && 'themedropbox' !== $author ) { 244 $this->author = get_user_by( 'login', $author ); 245 } 246 247 // The version should be set live as it's from SVN. 248 $this->version_status = 'live'; 249 250 return $this->import( array( // return true | WP_Error 251 // Since this version is already in SVN, we shouldn't try to import it again. 252 'commit_to_svn' => false, 253 ) ); 254 } 255 256 /** 203 257 * Processes a theme ZIP upload. 204 258 * … … 218 272 } 219 273 220 $this->create_tmp_dirs( $file_upload['name'] );274 $this->create_tmp_dirs( $file_upload['name'], true ); 221 275 $this->unzip_package( $file_upload ); 222 276 … … 658 712 * Creates a temporary directory, and the theme dir within it. 659 713 */ 660 public function create_tmp_dirs( $base_name ) {714 public function create_tmp_dirs( $base_name, $create_svn_tmp = false ) { 661 715 // Create a temporary directory if it doesn't exist yet. 662 716 $tmp = self::TMP; … … 679 733 $base_name = $this->get_sanitized_zip_name( $base_name ); 680 734 $this->theme_dir = "{$this->tmp_dir}/{$base_name}"; 681 $this->tmp_svn_dir = "{$this->tmp_dir}/ svn";735 $this->tmp_svn_dir = "{$this->tmp_dir}/"; // Set it to something, just in case. 682 736 mkdir( $this->theme_dir ); 683 mkdir( $this->tmp_svn_dir );684 737 chmod( $this->theme_dir, 0777 ); 685 chmod( $this->tmp_svn_dir, 0777 ); 738 if ( $create_svn_tmp ) { 739 $this->tmp_svn_dir = "{$this->tmp_dir}/svn"; 740 mkdir( $this->tmp_svn_dir ); 741 chmod( $this->tmp_svn_dir, 0777 ); 742 } 686 743 687 744 // Make sure we clean up after ourselves. … … 1377 1434 ); 1378 1435 1379 1380 1436 $email_content = sprintf( 1381 1437 /* translators: 1: theme version, 2: theme name, 3: Trac ticket URL */
Note: See TracChangeset
for help on using the changeset viewer.