Skip to content

Commit

Permalink
Switch telemetry library loading to plain require_once (#5891)
Browse files Browse the repository at this point in the history
Co-authored-by: Volodymyr Kolesnykov <[email protected]>
Co-authored-by: Rinat K <[email protected]>
  • Loading branch information
3 people authored Feb 6, 2025
1 parent de0cf38 commit a3b0777
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions 000-vip-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,32 +234,15 @@
require_once __DIR__ . '/vip-helpers/class-wpcomvip-restrictions.php';

// Load the Telemetry files
// TODO: switch to plain require_once like the above once the telemetry is fully deployed (all files are present)
$require_telemetry_files = [
__DIR__ . '/telemetry/class-telemetry-system.php',
__DIR__ . '/telemetry/class-tracks.php',
__DIR__ . '/telemetry/class-telemetry-client.php',
__DIR__ . '/telemetry/class-telemetry-event-queue.php',
__DIR__ . '/telemetry/class-telemetry-event.php',
__DIR__ . '/telemetry/tracks/class-tracks-event-dto.php',
__DIR__ . '/telemetry/tracks/class-tracks-event.php',
__DIR__ . '/telemetry/tracks/class-tracks-client.php',
__DIR__ . '/telemetry/tracks/tracks-utils.php',
];

// If there is a missing file, the loop will break and the telemetry files will not be loaded at all
do {
foreach ( $require_telemetry_files as $file ) {
if ( ! file_exists( $file ) ) {
break 2;
}
}
foreach ( $require_telemetry_files as $file ) {
require_once $file;
}
} while ( false );

unset( $require_telemetry_files );
require_once __DIR__ . '/telemetry/class-telemetry-system.php';
require_once __DIR__ . '/telemetry/class-tracks.php';
require_once __DIR__ . '/telemetry/class-telemetry-client.php';
require_once __DIR__ . '/telemetry/class-telemetry-event-queue.php';
require_once __DIR__ . '/telemetry/class-telemetry-event.php';
require_once __DIR__ . '/telemetry/tracks/class-tracks-event-dto.php';
require_once __DIR__ . '/telemetry/tracks/class-tracks-event.php';
require_once __DIR__ . '/telemetry/tracks/class-tracks-client.php';
require_once __DIR__ . '/telemetry/tracks/tracks-utils.php';

add_action( 'init', [ WPComVIP_Restrictions::class, 'instance' ] );

Expand Down

0 comments on commit a3b0777

Please sign in to comment.