Making WordPress.org

Changeset 3046


Ignore:
Timestamp:
04/29/2016 09:38:10 AM (8 years ago)
Author:
ocean90
Message:

Translate, Plugin Directory: Make Slack notification more verbose in case of errors.

See #1636.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-plugin-directory/inc/sync/class-translation-sync.php

    r3028 r3046  
    5353        $time = date( 'r' );
    5454        $message = "_Time: {$time}_\nTranslation sync from {$sub_project} to {$sub_project_counterpart} in process...\n";
     55        $updates = 0;
    5556        foreach ( $translation_sets as $translation_set ) {
    5657            if ( 0 == $translation_set->current_count() ) {
     
    6061            // Sync translations in a separate process.
    6162            $cmd = WPORGTRANSLATE_WPCLI . ' wporg-translate sync-plugin-translations ' . escapeshellarg( $args['gp_project'] ) . ' ' . escapeshellarg( $translation_set->locale ) . ' --set=' . escapeshellarg( $translation_set->slug );
    62             $output = shell_exec( $cmd );
    63             if ( 'No translations available.' !== $output ) {
    64                 $message .= "\t" . $output;
    65             }
    66         }
     63            $output = '';
     64            $return_var = 0;
     65            exec( $cmd, $output, $return_var );
     66            if ( $return_var ) {
     67                $message .= "\tFailure: " . implode( "\n\t", $output ) . "\n";
     68            } else {
     69                $message .= "\t" . implode( "\n\t", $output ) . "\n";
     70            }
     71            $updates += 1;
     72        }
     73
     74        if ( ! $updates ) {
     75            $message .= "\tNo translations are available to sync.\n";
     76        }
     77
    6778        $message .= 'Translation sync was successfully processed.';
    6879
Note: See TracChangeset for help on using the changeset viewer.