@@ -56,7 +56,6 @@ function __construct( $plugin_file_path ) {
5656 add_action ( 'wp_ajax_wpmdb_finalize_migration ' , array ( $ this , 'ajax_finalize_migration ' ) );
5757 add_action ( 'wp_ajax_wpmdb_flush ' , array ( $ this , 'ajax_flush ' ) );
5858 add_action ( 'wp_ajax_nopriv_wpmdb_flush ' , array ( $ this , 'ajax_nopriv_flush ' , ) );
59- add_action ( 'wpmdb_initiate_migration ' , array ( $ this , 'log_migration_event ' ), 100 );
6059
6160 $ this ->accepted_fields = array (
6261 'action ' ,
@@ -3987,93 +3986,4 @@ function mixed_case_table_name_warning( $migration_type ) {
39873986 return wptexturize ( ob_get_clean () );
39883987 }
39893988
3990- function log_migration_event ( $ state_data ) {
3991- if ( true !== $ this ->settings ['allow_tracking ' ] ) {
3992- return false ;
3993- }
3994- // TODO refactor into separate class so we can build free without this code
3995- // TODO don't run while testing?
3996- $ api_url = apply_filters ( 'wpmdb_logging_endpoint_url ' , 'https://api2.deliciousbrains.com/event ' );
3997-
3998- $ log_data = array (
3999- 'local_timestamp ' => time (),
4000- 'licence_key ' => $ this ->get_licence_key (),
4001- 'cli ' => $ this ->doing_cli_migration ,
4002- 'setting-compatibility_plugin_installed ' => $ this ->filesystem ->file_exists ( $ this ->mu_plugin_dest ),
4003- );
4004-
4005- foreach ( $ this ->parse_migration_form_data ( $ state_data ['form_data ' ] ) as $ key => $ val ) {
4006- if ( 'connection_info ' === $ key ) {
4007- continue ;
4008- }
4009- $ log_data [ 'profile- ' . $ key ] = $ val ;
4010- }
4011-
4012- foreach ( $ this ->settings as $ key => $ val ) {
4013- if ( 'profiles ' === $ key || 'key ' === $ key ) {
4014- continue ;
4015- }
4016- $ log_data [ 'setting- ' . $ key ] = $ val ;
4017- }
4018-
4019- foreach ( $ GLOBALS ['wpmdb_meta ' ] as $ plugin => $ arr ) {
4020- $ log_data [ $ plugin . '-active ' ] = true ;
4021- $ log_data [ $ plugin . '-version ' ] = $ arr ['version ' ];
4022- }
4023-
4024- foreach ( $ state_data ['site_details ' ] as $ site => $ info ) {
4025- $ log_data [ $ site . '-site_url ' ] = $ info ['site_url ' ];
4026- $ log_data [ $ site . '-home_url ' ] = $ info ['home_url ' ];
4027- $ log_data [ $ site . '-prefix ' ] = $ info ['prefix ' ];
4028-
4029- $ log_data [ $ site . '-is_multisite ' ] = $ info ['is_multisite ' ];
4030-
4031- if ( isset ( $ info ['subsites ' ] ) && is_array ( $ info ['subsites ' ] ) ) {
4032- $ log_data [ $ site . '-subsite_count ' ] = count ( $ info ['subsites ' ] );
4033- }
4034-
4035- $ log_data [ $ site . '-is_subdomain_install ' ] = $ info ['is_subdomain_install ' ];
4036- }
4037-
4038- foreach ( $ log_data as $ key => $ val ) {
4039- if ( strstr ( $ key , 'count ' ) || is_array ( $ val ) ) {
4040- continue ;
4041- }
4042- if ( '1 ' === $ val ) {
4043- $ log_data [ $ key ] = true ;
4044- continue ;
4045- }
4046- if ( '0 ' === $ val ) {
4047- $ log_data [ $ key ] = false ;
4048- continue ;
4049- }
4050- if ( 'true ' === $ val ) {
4051- $ log_data [ $ key ] = true ;
4052- continue ;
4053- }
4054- if ( 'false ' === $ val ) {
4055- $ log_data [ $ key ] = false ;
4056- continue ;
4057- }
4058- }
4059-
4060- $ remote_post_args = array (
4061- 'blocking ' => false ,
4062- 'timeout ' => 60 ,
4063- 'method ' => 'POST ' ,
4064- 'headers ' => array ( 'Content-Type ' => 'application/json ' ),
4065- 'body ' => json_encode ( $ log_data ),
4066- );
4067- $ result = wp_remote_post ( $ api_url , $ remote_post_args );
4068-
4069- if ( is_wp_error ( $ result ) ) {
4070- if ( defined ( 'WP_DEBUG ' ) && WP_DEBUG ) {
4071- error_log ( 'Error logging migration event ' );
4072- error_log ( print_r ( $ result , 1 ) );
4073- }
4074- $ this ->log_error ( 'Error logging Migration event ' , $ result );
4075- }
4076-
4077- return true ;
4078- }
40793989}
0 commit comments