Making WordPress.org

Changeset 5367


Ignore:
Timestamp:
04/19/2017 06:08:50 PM (10 years ago)
Author:
coreymckrill
Message:

WordCamp: Log errors during planning checklist task provisioning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-mentors/includes/tasks-data.php

    r5366 r5367  
    1010
    1111use WordCamp\Mentors;
     12use WordCamp\Logger;
    1213
    1314/**
    … …  
    681682                );
    682683
    683                 $post_id = wp_insert_post( $args );
     684                $post_id = wp_insert_post( $args, true );
     685
     686                if ( is_wp_error( $post_id ) ) {
     687                        $results[] = $post_id;
     688                        continue;
     689                }
    684690
    685691                $results[] = wp_set_object_terms( $post_id, $data['cat'], Mentors\PREFIX . '_task_category' );
    686692        }
    687693
    688         if ( in_array( false, $results, true ) ||
    689              ! empty( array_filter( $results, function( $i ) { return $i instanceof \WP_Error; } ) ) ) {
     694        $errors = array_filter( $results, function( $i ) {
     695                return $i instanceof \WP_Error;
     696        } );
     697
     698        if ( in_array( false, $results, true ) || ! empty( $errors ) ) {
     699                foreach ( $errors as $error ) {
     700                        Logger\log( 'task_error', compact( $error->get_error_code(), $error->get_error_message() ) );
     701                }
     702
    690703                return 'reset-errors';
    691704        }
Note: See TracChangeset for help on using the changeset viewer.