Automattic\WooCommerce\Internal\Logging

RemoteLogger::sanitize_trace()privateWC 1.0

Sanitize the error trace to exclude sensitive data.

Метод класса: RemoteLogger{}

Хуков нет.

Возвращает

Строку. The sanitized trace.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->sanitize_trace( $trace ): string;
$trace(массив|строка) (обязательный)
The error trace.

Код RemoteLogger::sanitize_trace() WC 9.3.3

private function sanitize_trace( $trace ): string {
	if ( is_string( $trace ) ) {
		return $this->sanitize( $trace );
	}

	if ( ! is_array( $trace ) ) {
		return '';
	}

	$sanitized_trace = array_map(
		function ( $trace_item ) {
			if ( is_array( $trace_item ) && isset( $trace_item['file'] ) ) {
				$trace_item['file'] = $this->sanitize( $trace_item['file'] );
				return $trace_item;
			}

			return $this->sanitize( $trace_item );
		},
		$trace
	);

	$is_array_by_file = isset( $sanitized_trace[0]['file'] );
	if ( $is_array_by_file ) {
		return wc_print_r( $sanitized_trace, true );
	}

	return implode( "\n", $sanitized_trace );
}