Skip to content

Commit

Permalink
Don't send fields that are marked private!
Browse files Browse the repository at this point in the history
  • Loading branch information
Camwyn committed Nov 7, 2023
1 parent ea745d4 commit e61e4a5
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/Telemetry/Data_Providers/Debug_Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public function get_data(): array {
if ( ! class_exists( 'WP_Debug_Data' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-debug-data.php';
}
$info = WP_Debug_Data::debug_data();

$info = $this->clean_private_data( WP_Debug_Data::debug_data() );

$active_plugins = get_option( 'active_plugins' );
$plugins = get_plugins();
Expand All @@ -51,4 +52,28 @@ public function get_data(): array {

return $info;
}

/**
* Some data in Site Health is marked as private.
* This ensures we don't pass that on to the servers.
*
* @since TBD
*
* @param array<string,mixed> $data Raw Site Health data
*
* @return array<string,mixed> Filtered Site Health data
*/
function clean_private_data( $data ): array {
foreach( $data as &$details) {
// remove private info.
$details['fields'] = array_filter(
$details['fields'],
function( $field ) {
return empty( $field['private'] );
}
);
}

return $data;
}
}

0 comments on commit e61e4a5

Please sign in to comment.