Automattic\WooCommerce\Internal\CLI\Migrator\Core
MigratorTracker::on_session_completed
Handle migration session completion.
Method of the class: MigratorTracker{}
No Hooks.
Returns
null. Nothing (null).
Usage
$MigratorTracker = new MigratorTracker(); $MigratorTracker->on_session_completed( $platform, $final_stats ): void;
- $platform(string) (required)
- Platform identifier.
- $final_stats(array) (required)
- Final migration statistics.
MigratorTracker::on_session_completed() MigratorTracker::on session completed code WC 10.7.0
public function on_session_completed( string $platform, array $final_stats ): void {
if ( empty( $this->current_session ) ) {
// Log warning for debugging - session completed without active session.
if ( function_exists( 'wc_get_logger' ) ) {
wc_get_logger()->warning(
'Migration session completed event fired without active session.',
array( 'source' => 'migrator_tracker' )
);
}
return;
}
// Use consistent time() calls to avoid any timezone issues.
$completion_time = time();
$this->current_session['total_time'] = $completion_time - $this->current_session['started_at'];
$this->current_session['completed_at'] = $completion_time;
$this->current_session['products_total'] = $final_stats['total_found'] ?? $this->current_session['products_attempted'];
$this->save_session_data();
$this->current_session = array();
}