← All changes
|
_inc/lib/debugger/class-jetpack-debug-data.php
+29
-16
12.0.3
→
16.3-a.1
View file →
| @@ -7,10 +7,12 @@ | ||
| 7 | 7 | |
| 8 | 8 | use Automattic\Jetpack\Connection\Tokens; |
| 9 | 9 | use Automattic\Jetpack\Connection\Urls; |
| 10 | 10 | use Automattic\Jetpack\Constants; |
| 11 | +use Automattic\Jetpack\Current_Plan as Jetpack_Plan; | |
| 11 | 12 | use Automattic\Jetpack\Identity_Crisis; |
| 12 | 13 | use Automattic\Jetpack\Redirect; |
| 14 | +use Automattic\Jetpack\Status; | |
| 13 | 15 | use Automattic\Jetpack\Sync\Modules; |
| 14 | 16 | use Automattic\Jetpack\Sync\Sender; |
| 15 | 17 | |
| 16 | 18 | /** |
| @@ -135,43 +137,53 @@ | ||
| 135 | 137 | public static function debug_data() { |
| 136 | 138 | $debug_info = array(); |
| 137 | 139 | |
| 138 | 140 | /* Add various important Jetpack options */ |
| 139 | - $debug_info['site_id'] = array( | |
| 141 | + $debug_info['site_id'] = array( | |
| 140 | 142 | 'label' => 'Jetpack Site ID', |
| 141 | 143 | 'value' => Jetpack_Options::get_option( 'id' ), |
| 142 | 144 | 'private' => false, |
| 143 | 145 | ); |
| 144 | - $debug_info['ssl_cert'] = array( | |
| 146 | + $debug_info['ssl_cert'] = array( | |
| 145 | 147 | 'label' => 'Jetpack SSL Verfication Bypass', |
| 146 | 148 | 'value' => ( Jetpack_Options::get_option( 'fallback_no_verify_ssl_certs' ) ) ? 'Yes' : 'No', |
| 147 | 149 | 'private' => false, |
| 148 | 150 | ); |
| 149 | - $debug_info['time_diff'] = array( | |
| 151 | + $debug_info['time_diff'] = array( | |
| 150 | 152 | 'label' => "Offset between Jetpack server's time and this server's time.", |
| 151 | 153 | 'value' => Jetpack_Options::get_option( 'time_diff' ), |
| 152 | 154 | 'private' => false, |
| 153 | 155 | ); |
| 154 | - $debug_info['version_option'] = array( | |
| 156 | + $debug_info['version_option'] = array( | |
| 155 | 157 | 'label' => 'Current Jetpack Version Option', |
| 156 | 158 | 'value' => Jetpack_Options::get_option( 'version' ), |
| 157 | 159 | 'private' => false, |
| 158 | 160 | ); |
| 159 | - $debug_info['old_version'] = array( | |
| 161 | + $debug_info['old_version'] = array( | |
| 160 | 162 | 'label' => 'Previous Jetpack Version', |
| 161 | 163 | 'value' => Jetpack_Options::get_option( 'old_version' ), |
| 162 | 164 | 'private' => false, |
| 163 | 165 | ); |
| 164 | - $debug_info['public'] = array( | |
| 166 | + $debug_info['public'] = array( | |
| 165 | 167 | 'label' => 'Jetpack Site Public', |
| 166 | 168 | 'value' => ( Jetpack_Options::get_option( 'public' ) ) ? 'Public' : 'Private', |
| 167 | 169 | 'private' => false, |
| 168 | 170 | ); |
| 169 | - $debug_info['master_user'] = array( | |
| 171 | + $debug_info['master_user'] = array( | |
| 170 | 172 | 'label' => 'Jetpack Master User', |
| 171 | 173 | 'value' => self::human_readable_master_user(), // Only ID number and user name. |
| 172 | 174 | 'private' => false, |
| 173 | 175 | ); |
| 176 | + $debug_info['is_offline_mode'] = array( | |
| 177 | + 'label' => 'Jetpack Offline Mode', | |
| 178 | + 'value' => ( new Status() )->is_offline_mode() ? 'on' : 'off', | |
| 179 | + 'private' => false, | |
| 180 | + ); | |
| 181 | + $debug_info['is_offline_mode_constant'] = array( | |
| 182 | + 'label' => 'JETPACK_DEV_DEBUG Constant', | |
| 183 | + 'value' => ( defined( 'JETPACK_DEV_DEBUG' ) && JETPACK_DEV_DEBUG ) ? 'on' : 'off', | |
| 184 | + 'private' => false, | |
| 185 | + ); | |
| 174 | 186 | |
| 175 | 187 | /** |
| 176 | 188 | * Token information is private, but awareness if there one is set is helpful. |
| 177 | 189 | * |
| @@ -213,14 +225,14 @@ | ||
| 213 | 225 | 'private' => false, |
| 214 | 226 | ); |
| 215 | 227 | $debug_info['blog_token'] = array( |
| 216 | 228 | 'label' => 'Blog Public Key', |
| 217 | - 'value' => ( $blog_token ) ? $blog_key : 'Not set.', | |
| 229 | + 'value' => $blog_key ?? 'Not set.', | |
| 218 | 230 | 'private' => false, |
| 219 | 231 | ); |
| 220 | 232 | $debug_info['user_token'] = array( |
| 221 | 233 | 'label' => 'User Public Key', |
| 222 | - 'value' => ( $user_token ) ? $user_key : 'Not set.', | |
| 234 | + 'value' => $user_key ?? 'Not set.', | |
| 223 | 235 | 'private' => false, |
| 224 | 236 | ); |
| 225 | 237 | |
| 226 | 238 | /** Jetpack Environmental Information */ |
| @@ -272,14 +284,15 @@ | ||
| 272 | 284 | } |
| 273 | 285 | |
| 274 | 286 | $debug_info['protect_header'] = array( |
| 275 | 287 | 'label' => 'Trusted IP', |
| 276 | - 'value' => wp_json_encode( get_site_option( 'trusted_ip_header' ) ), | |
| 288 | + 'value' => wp_json_encode( get_site_option( 'trusted_ip_header' ), JSON_UNESCAPED_SLASHES ), | |
| 277 | 289 | 'private' => false, |
| 278 | 290 | ); |
| 279 | 291 | |
| 280 | 292 | /** Sync Debug Information */ |
| 281 | 293 | $sync_module = Modules::get_module( 'full-sync' ); |
| 294 | + '@phan-var \Automattic\Jetpack\Sync\Modules\Full_Sync_Immediately|\Automattic\Jetpack\Sync\Modules\Full_Sync $sync_module'; | |
| 282 | 295 | if ( $sync_module ) { |
| 283 | 296 | $sync_statuses = $sync_module->get_status(); |
| 284 | 297 | $human_readable_sync_status = array(); |
| 285 | 298 | foreach ( $sync_statuses as $sync_status => $sync_status_value ) { |
| @@ -288,9 +301,9 @@ | ||
| 288 | 301 | ? gmdate( 'r', $sync_status_value ) : $sync_status_value; |
| 289 | 302 | } |
| 290 | 303 | $debug_info['full_sync'] = array( |
| 291 | 304 | 'label' => 'Full Sync Status', |
| 292 | - 'value' => wp_json_encode( $human_readable_sync_status ), | |
| 305 | + 'value' => wp_json_encode( $human_readable_sync_status, JSON_UNESCAPED_SLASHES ), | |
| 293 | 306 | 'private' => false, |
| 294 | 307 | ); |
| 295 | 308 | } |
| 296 | 309 | |
| @@ -333,14 +346,14 @@ | ||
| 333 | 346 | ); |
| 334 | 347 | |
| 335 | 348 | $debug_info['idc_urls'] = array( |
| 336 | 349 | 'label' => 'IDC URLs', |
| 337 | - 'value' => wp_json_encode( $idc_urls ), | |
| 350 | + 'value' => wp_json_encode( $idc_urls, JSON_UNESCAPED_SLASHES ), | |
| 338 | 351 | 'private' => false, |
| 339 | 352 | ); |
| 340 | 353 | $debug_info['idc_error_option'] = array( |
| 341 | 354 | 'label' => 'IDC Error Option', |
| 342 | - 'value' => wp_json_encode( Jetpack_Options::get_option( 'sync_error_idc' ) ), | |
| 355 | + 'value' => wp_json_encode( Jetpack_Options::get_option( 'sync_error_idc' ), JSON_UNESCAPED_SLASHES ), | |
| 343 | 356 | 'private' => false, |
| 344 | 357 | ); |
| 345 | 358 | $debug_info['idc_optin'] = array( |
| 346 | 359 | 'label' => 'IDC Opt-in', |
| @@ -348,9 +361,9 @@ | ||
| 348 | 361 | 'private' => false, |
| 349 | 362 | ); |
| 350 | 363 | |
| 351 | 364 | // @todo -- Add testing results? |
| 352 | - $cxn_tests = new Jetpack_Cxn_Tests(); | |
| 365 | + $cxn_tests = new Automattic\Jetpack\Connection\Connection_Health_Tests(); | |
| 353 | 366 | $debug_info['cxn_tests'] = array( |
| 354 | 367 | 'label' => 'Connection Tests', |
| 355 | 368 | 'value' => '', |
| 356 | 369 | 'private' => false, |
| @@ -357,9 +370,9 @@ | ||
| 357 | 370 | ); |
| 358 | 371 | if ( $cxn_tests->pass() ) { |
| 359 | 372 | $debug_info['cxn_tests']['value'] = 'All Pass.'; |
| 360 | 373 | } else { |
| 361 | - $debug_info['cxn_tests']['value'] = wp_json_encode( $cxn_tests->list_fails() ); | |
| 374 | + $debug_info['cxn_tests']['value'] = wp_json_encode( $cxn_tests->list_fails(), JSON_UNESCAPED_SLASHES ); | |
| 362 | 375 | } |
| 363 | 376 | |
| 364 | 377 | return $debug_info; |
| 365 | 378 | } |
| @@ -377,9 +390,9 @@ | ||
| 377 | 390 | } |
| 378 | 391 | |
| 379 | 392 | $user = new WP_User( $master_user ); |
| 380 | 393 | |
| 381 | - if ( ! $user ) { | |
| 394 | + if ( ! $user->exists() ) { | |
| 382 | 395 | return __( 'Master user no longer exists. Please disconnect and reconnect Jetpack.', 'jetpack' ); |
| 383 | 396 | } |
| 384 | 397 | |
| 385 | 398 | return self::human_readable_user( $user ); |