• Bug report

    Plugin version: 1.4.7

    Description: This message is outputted when I add a single product to my cart on the product page.

    Error:

    PHP Notice: Undefined index: function in /var/www/html/wordpress/wp-content/plugins/activecampaign-for-woocommerce/includes/class-activecampaign-for-woocommerce-logger.php on line 261

    The function in the file:

    /**
      * Replaces the trace array with a clean version that only contains specific details.
      *
      * @param array $trace The stack trace.
      *
      * @return array The replacement stack trace.
      */
    public function clean_trace( $trace ) {
      $result = [];
    
      // Only retrieve class, function, and line for the first 3 trace results
      if ( isset( $trace[0]['class'] ) ) {
        $result[0]['class'] = $trace[0]['class'];
      }
      if ( isset( $trace[0]['function'] ) ) {
        $result[0]['function'] .= $trace[0]['function']; // <<<<<<<<<<<<<<<<<<<<<<
      }
    
      if ( isset( $trace[0]['line'] ) ) {
        $result[0]['line'] = $trace[0]['line'];
      }
    
      if ( isset( $trace[1]['class'] ) ) {
        $result[1]['class'] = $trace[1]['class'];
      }
    
      if ( isset( $trace[1]['function'] ) ) {
        $result[1]['function'] = $trace[1]['function'];
      }
    
      if ( isset( $trace[1]['line'] ) ) {
        $result[1]['line'] = $trace[1]['line'];
      }
    
      if ( isset( $trace[2]['class'] ) ) {
        $result[2]['class'] = $trace[2]['class'];
      }
    
      if ( isset( $trace[2]['function'] ) ) {
        $result[2]['function'] = $trace[2]['function'];
      }
    
      if ( isset( $trace[2]['line'] ) ) {
        $result[2]['line'] = $trace[2]['line'];
      }
    
      return $result;
    }

    The specified line should be changed to:

    $result[0]['function'] = $trace[0]['function'];

  • The topic ‘Bug report: PHP Notice for an undefined index in logger’ is closed to new replies.