Changeset 11299
- Timestamp:
- 10/27/2021 03:01:22 AM (5 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory
- Files:
-
- 2 edited
-
class-wporg-themes-upload.php (modified) (3 diffs)
-
lib/class-exec-with-logging.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-wporg-themes-upload.php
r11281 r11299 659 659 if ( $args['commit_to_svn'] ) { 660 660 $result = $this->add_to_svn(); 661 if ( ! $result ) {661 if ( ! $result || is_wp_error( $result ) ) { 662 662 return new WP_Error( 663 663 'failed_svn_commit', … … 666 666 __( 'There was an error adding your theme to SVN. Please try again, if this error persists report the error to %s.', 'wporg-themes' ), 667 667 '<a href="mailto:themes@wordpress.org">themes@wordpress.org</a>' 668 ) . 669 ( 670 is_wp_error( $result ) && $result->get_error_message( 'pre-commit-hook' ) ? 671 '<br><code>' . nl2br( esc_html( $result->get_error_message( 'pre-commit-hook' ) ) ) . '</code>' : 672 '' 668 673 ) 669 674 ); … … 1380 1385 $password = escapeshellarg( THEME_DROPBOX_PASSWORD ); 1381 1386 1382 $last_line = $this->exec_with_notify( self::SVN . " --non-interactive --username themedropbox --password {$password} --no-auto-props -m {$import_msg} import {$theme_path} {$svn_path}" ); 1387 $last_line = $this->exec_with_notify( self::SVN . " --non-interactive --username themedropbox --password {$password} --no-auto-props -m {$import_msg} import {$theme_path} {$svn_path}", $output, $return_var, $stderr ); 1388 1389 // Pass through any error output from the SVN error handler. 1390 if ( 1391 ! empty( $stderr ) && 1392 false !== stripos( $stderr[0], 'Commit blocked by pre-commit hook' ) && 1393 preg_match( '!([*]{12,})(.*?)\\1!s', implode( "\n", $stderr ) . "\n", $m ) 1394 ) { 1395 return new WP_Error( 'pre-commit-hook', trim( $m[0] ) ); 1396 } 1383 1397 1384 1398 if ( preg_match( '/Committed revision (\d+)\./i', $last_line, $m ) ) { -
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/lib/class-exec-with-logging.php
r11232 r11299 12 12 * Execute a shell process, same behaviour as `exec()` but with PHP Warnings/Notices generated on errors. 13 13 * 14 * @param string $command Command to execute. Escape it. 15 * @param array $output Array to append program output to. Passed by reference. 16 * @param int $return_var The commands return value. Passed by reference. 14 * @param string $command Command to execute. Escape it. 15 * @param array $output Array to append program output to. Passed by reference. 16 * @param int $return_var The commands return value. Passed by reference. 17 * @param array $error_output Array to append program output to. Passed by reference. 17 18 * 18 19 * @return false|string False on failure, last line of output on success, as per exec(). 19 20 */ 20 public static function exec( $command, &$output = null, &$return_var = null ) {21 public static function exec( $command, &$output = null, &$return_var = null, &$error_output = null ) { 21 22 $proc = proc_open( 22 23 $command, … … 39 40 $return_var = proc_close( $proc ); 40 41 42 // Redact any passwords that might be in a command and included in logged errors. 43 foreach ( [ 'command', 'stdout', 'stderr' ] as $field ) { 44 $$field = str_replace( [ THEME_TRACBOT_PASSWORD, THEME_DROPBOX_PASSWORD ], '[redacted]', $$field ); 45 } 46 41 47 // Append to $output, as `exec()` does. 42 48 if ( ! is_array( $output ) ) { 43 49 $output = []; 44 50 } 51 if ( ! is_array( $error_output ) ) { 52 $error_output = []; 53 } 45 54 if ( $stdout ) { 46 55 $output = array_merge( $output, explode( "\n", rtrim( $stdout, "\r\n" ) ) ); 47 56 } 48 49 // Redact any passwords that might be in a command and included in logged errors.50 $command = str_replace( [ THEME_TRACBOT_PASSWORD, THEME_DROPBOX_PASSWORD ], '[redacted]', $command );57 if ( $stderr ) { 58 $error_output = array_merge( $error_output, explode( "\n", rtrim( $stderr, "\r\n" ) ) ); 59 } 51 60 52 61 if ( $return_var > 0 ) {
Note: See TracChangeset
for help on using the changeset viewer.