Completed
Push — update/partner-provision-via-r... ( 9dc788...9e291f )
by
unknown
18:11 queued 05:03
created

Jetpack_XMLRPC_Server::features_enabled()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Just a sack of functions.  Not actually an IXR_Server
5
 */
6
class Jetpack_XMLRPC_Server {
7
	/**
8
	 * The current error object
9
	 */
10
	public $error = null;
11
12
	/**
13
	 * The current user
14
	 */
15
	public $user = null;
16
17
	/**
18
	 * Whitelist of the XML-RPC methods available to the Jetpack Server. If the
19
	 * user is not authenticated (->login()) then the methods are never added,
20
	 * so they will get a "does not exist" error.
21
	 */
22
	function xmlrpc_methods( $core_methods ) {
23
		$jetpack_methods = array(
24
			'jetpack.jsonAPI'      => array( $this, 'json_api' ),
25
			'jetpack.verifyAction' => array( $this, 'verify_action' ),
26
		);
27
28
		$this->user = $this->login();
29
30
		if ( $this->user ) {
31
			$jetpack_methods = array_merge( $jetpack_methods, array(
32
				'jetpack.testConnection'    => array( $this, 'test_connection' ),
33
				'jetpack.testAPIUserCode'   => array( $this, 'test_api_user_code' ),
34
				'jetpack.featuresAvailable' => array( $this, 'features_available' ),
35
				'jetpack.featuresEnabled'   => array( $this, 'features_enabled' ),
36
				'jetpack.disconnectBlog'    => array( $this, 'disconnect_blog' ),
37
				'jetpack.unlinkUser'        => array( $this, 'unlink_user' ),
38
				'jetpack.syncObject'        => array( $this, 'sync_object' ),
39
				'jetpack.idcUrlValidation'  => array( $this, 'validate_urls_for_idc_mitigation' ),
40
			) );
41
42
			if ( isset( $core_methods['metaWeblog.editPost'] ) ) {
43
				$jetpack_methods['metaWeblog.newMediaObject'] = $core_methods['metaWeblog.newMediaObject'];
44
				$jetpack_methods['jetpack.updateAttachmentParent'] = array( $this, 'update_attachment_parent' );
45
			}
46
47
			/**
48
			 * Filters the XML-RPC methods available to Jetpack for authenticated users.
49
			 *
50
			 * @since 1.1.0
51
			 *
52
			 * @param array $jetpack_methods XML-RPC methods available to the Jetpack Server.
53
			 * @param array $core_methods Available core XML-RPC methods.
54
			 * @param WP_User $user Information about a given WordPress user.
55
			 */
56
			$jetpack_methods = apply_filters( 'jetpack_xmlrpc_methods', $jetpack_methods, $core_methods, $this->user );
57
		}
58
59
		/**
60
		 * Filters the XML-RPC methods available to Jetpack for unauthenticated users.
61
		 *
62
		 * @since 3.0.0
63
		 *
64
		 * @param array $jetpack_methods XML-RPC methods available to the Jetpack Server.
65
		 * @param array $core_methods Available core XML-RPC methods.
66
		 */
67
		return apply_filters( 'jetpack_xmlrpc_unauthenticated_methods', $jetpack_methods, $core_methods );
68
	}
69
70
	/**
71
	 * Whitelist of the bootstrap XML-RPC methods
72
	 */
73
	function bootstrap_xmlrpc_methods() {
74
		return array(
75
			'jetpack.verifyRegistration' => array( $this, 'verify_registration' ),
76
			'jetpack.remoteAuthorize' => array( $this, 'remote_authorize' ),
77
			'jetpack.remoteProvision' => array( $this, 'remote_provision' ),
78
		);
79
	}
80
81
	function authorize_xmlrpc_methods() {
82
		return array(
83
			'jetpack.remoteAuthorize' => array( $this, 'remote_authorize' ),
84
			'jetpack.remoteProvision' => array( $this, 'remote_provision' ),
85
		);
86
	}
87
88
	function remote_authorize( $request ) {
89
		$user = get_user_by( 'id', $request['state'] );
90
		JetpackTracking::record_user_event( 'jpc_remote_authorize_begin', array(), $user );
91
92
		foreach( array( 'secret', 'state', 'redirect_uri', 'code' ) as $required ) {
93
			if ( ! isset( $request[ $required ] ) || empty( $request[ $required ] ) ) {
94
				return $this->error( new Jetpack_Error( 'missing_parameter', 'One or more parameters is missing from the request.', 400 ), 'jpc_remote_authorize_fail' );
95
			}
96
		}
97
98
		if ( ! $user ) {
99
			return $this->error( new Jetpack_Error( 'user_unknown', 'User not found.', 404 ), 'jpc_remote_authorize_fail' );
100
		}
101
102
		if ( Jetpack::is_active() && Jetpack::is_user_connected( $request['state'] ) ) {
103
			return $this->error( new Jetpack_Error( 'already_connected', 'User already connected.', 400 ), 'jpc_remote_authorize_fail' );
104
		}
105
106
		$verified = $this->verify_action( array( 'authorize', $request['secret'], $request['state'] ) );
107
108
		if ( is_a( $verified, 'IXR_Error' ) ) {
109
			return $this->error( $verified, 'jpc_remote_authorize_fail' );
110
		}
111
112
		wp_set_current_user( $request['state'] );
113
114
		$client_server = new Jetpack_Client_Server;
115
		$result = $client_server->authorize( $request );
116
117
		if ( is_wp_error( $result ) ) {
118
			return $this->error( $result, 'jpc_remote_authorize_fail' );
119
		}
120
121
		JetpackTracking::record_user_event( 'jpc_remote_authorize_success' );
122
123
		$response = array(
124
			'result' => $result,
125
		);
126
		return $response;
127
	}
128
129
	function remote_provision( $request ) {
130
		if ( ! isset( $request['nonce'] ) ) {
131
			return $this->error(
132
				new Jetpack_Error(
133
					'nonce_missing',
134
					esc_html__( 'The required "nonce" parameter is missing.', 'jetpack' ),
135
					400
136
				),
137
				'jpc_remote_provision_fail'
138
			);
139
		}
140
141
		$nonce = $request['nonce'];
0 ignored issues
show
Unused Code introduced by
$nonce is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
142
		unset( $request['nonce'] );
143
144
		// TODO: validate nonce here
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
145
146
		if ( ! isset( $request['local_username'] ) ) {
147
			return $this->error(
148
				new Jetpack_Error(
149
					'local_username_missing',
150
					'The required "local_username" parameter is missing.',
151
					400
152
				),
153
				'jpc_remote_provision_fail'
154
			);
155
		}
156
157
		$local_username = $request['local_username'];
158
159
		$user = get_user_by( 'login', $local_username );
160
161
		if ( ! $user ) {
162
			$user = get_user_by( 'email', $local_username );
163
		}
164
165
		if ( ! $user ) {
166
			return $this->error( new Jetpack_Error( 'user_unknown', 'User not found.', 404 ) );
167
		}
168
169
		require_once JETPACK__PLUGIN_DIR . '_inc/class.jetpack-provision.php';
170
171
		wp_set_current_user( $user->ID );
172
173
		// Filter allowed parameters.
174
		$allowed_provision_args = array( 'wpcom_user_id', 'wpcom_user_email', 'local_username', 'plan', 'force_register', 'force_connect', 'onboarding', 'partner_tracking_id' );
175
		$args = array_intersect_key(
176
			$request,
177
			array_flip( $allowed_provision_args )
178
		);
179
180
		$result = Jetpack_Provision::register_and_build_request_body( $args );
181
182
		if ( is_wp_error( $result ) ) {
183
			return $this->error( $result, 'jpc_remote_provision_fail' );
184
		}
185
186
		return $result;
187
	}
188
189
	private function tracks_record_error( $name, $error, $user = null ) {
190
		if ( is_wp_error( $error ) ) {
191
			JetpackTracking::record_user_event( $name, array(
192
				'error_code' => $error->get_error_code(),
193
				'error_message' => $error->get_error_message()
194
			), $user );
195
		} elseif( is_a( $error, 'IXR_Error' ) ) {
196
			JetpackTracking::record_user_event( $name, array(
197
				'error_code' => $error->code,
198
				'error_message' => $error->message
199
			), $user );
200
		}
201
202
		return $error;
203
	}
204
205
	/**
206
	* Verifies that Jetpack.WordPress.com received a registration request from this site
207
	*/
208
	function verify_registration( $data ) {
209
		// failure modes will be recorded in tracks in the verify_action method
210
		return $this->verify_action( array( 'register', $data[0], $data[1] ) );
211
	}
212
213
	/**
214
	 * @return WP_Error|string secret_2 on success, WP_Error( error_code => error_code, error_message => error description, error_data => status code ) on failure
215
	 *
216
	 * Possible error_codes:
217
	 *
218
	 * verify_secret_1_missing
219
	 * verify_secret_1_malformed
220
	 * verify_secrets_missing: verification secrets are not found in database
221
	 * verify_secrets_incomplete: verification secrets are only partially found in database
222
	 * verify_secrets_expired: verification secrets have expired
223
	 * verify_secrets_mismatch: stored secret_1 does not match secret_1 sent by Jetpack.WordPress.com
224
	 * state_missing: required parameter of state not found
225
	 * state_malformed: state is not a digit
226
	 * invalid_state: state in request does not match the stored state
227
	 *
228
	 * The 'authorize' and 'register' actions have additional error codes
229
	 *
230
	 * state_missing: a state ( user id ) was not supplied
231
	 * state_malformed: state is not the correct data type
232
	 * invalid_state: supplied state does not match the stored state
233
	 */
234
	function verify_action( $params ) {
235
		$action = $params[0];
236
		$verify_secret = $params[1];
237
		$state = isset( $params[2] ) ? $params[2] : '';
238
		$user = get_user_by( 'id', $state );
239
		JetpackTracking::record_user_event( 'jpc_verify_' . $action . '_begin', array(), $user );
240
		$tracks_failure_event_name = 'jpc_verify_' . $action . '_fail';
241
242
		if ( empty( $verify_secret ) ) {
243
			return $this->error( new Jetpack_Error( 'verify_secret_1_missing', sprintf( 'The required "%s" parameter is missing.', 'secret_1' ), 400 ), $tracks_failure_event_name, $user );
244
		} else if ( ! is_string( $verify_secret ) ) {
245
			return $this->error( new Jetpack_Error( 'verify_secret_1_malformed', sprintf( 'The required "%s" parameter is malformed.', 'secret_1' ), 400 ), $tracks_failure_event_name, $user );
246
		} else if ( empty( $state ) ) {
247
			return $this->error( new Jetpack_Error( 'state_missing', sprintf( 'The required "%s" parameter is missing.', 'state' ), 400 ), $tracks_failure_event_name, $user );
248
		} else if ( ! ctype_digit( $state ) ) {
249
			return $this->error( new Jetpack_Error( 'state_malformed', sprintf( 'The required "%s" parameter is malformed.', 'state' ), 400 ), $tracks_failure_event_name, $user );
250
		}
251
252
		$secrets = Jetpack::get_secrets( $action, $state );
253
254
		if ( ! $secrets ) {
255
			Jetpack::delete_secrets( $action, $state );
256
			return $this->error( new Jetpack_Error( 'verify_secrets_missing', 'Verification secrets not found', 400 ), $tracks_failure_event_name, $user );
257
		}
258
259
		if ( is_wp_error( $secrets ) ) {
260
			Jetpack::delete_secrets( $action, $state );
261
			return $this->error( new Jetpack_Error( $secrets->get_error_code(), $secrets->get_error_message(), 400 ), $tracks_failure_event_name, $user );
262
		}
263
264
		if ( empty( $secrets['secret_1'] ) || empty( $secrets['secret_2'] ) || empty( $secrets['exp'] ) ) {
265
			Jetpack::delete_secrets( $action, $state );
266
			return $this->error( new Jetpack_Error( 'verify_secrets_incomplete', 'Verification secrets are incomplete', 400 ), $tracks_failure_event_name, $user );
267
		}
268
269
		if ( ! hash_equals( $verify_secret, $secrets['secret_1'] ) ) {
270
			Jetpack::delete_secrets( $action, $state );
271
			return $this->error( new Jetpack_Error( 'verify_secrets_mismatch', 'Secret mismatch', 400 ), $tracks_failure_event_name, $user );
272
		}
273
274
		Jetpack::delete_secrets( $action, $state );
275
276
		JetpackTracking::record_user_event( 'jpc_verify_' . $action . '_success', array(), $user );
277
278
		return $secrets['secret_2'];
279
	}
280
281
	/**
282
	 * Wrapper for wp_authenticate( $username, $password );
283
	 *
284
	 * @return WP_User|bool
285
	 */
286
	function login() {
287
		Jetpack::init()->require_jetpack_authentication();
288
		$user = wp_authenticate( 'username', 'password' );
289
		if ( is_wp_error( $user ) ) {
290
			if ( 'authentication_failed' == $user->get_error_code() ) { // Generic error could mean most anything.
291
				$this->error = new Jetpack_Error( 'invalid_request', 'Invalid Request', 403 );
292
			} else {
293
				$this->error = $user;
294
			}
295
			return false;
296
		} else if ( !$user ) { // Shouldn't happen.
297
			$this->error = new Jetpack_Error( 'invalid_request', 'Invalid Request', 403 );
298
			return false;
299
		}
300
301
		return $user;
302
	}
303
304
	/**
305
	 * Returns the current error as an IXR_Error
306
	 *
307
	 * @return bool|IXR_Error
308
	 */
309
	function error( $error = null, $tracks_event_name = null, $user = null ) {
310
		// record using Tracks
311
		if ( null !== $tracks_event_name ) {
312
			$this->tracks_record_error( $tracks_event_name, $error, $user );
313
		}
314
315
		if ( !is_null( $error ) ) {
316
			$this->error = $error;
317
		}
318
319
		if ( is_wp_error( $this->error ) ) {
320
			$code = $this->error->get_error_data();
321
			if ( !$code ) {
322
				$code = -10520;
323
			}
324
			$message = sprintf( 'Jetpack: [%s] %s', $this->error->get_error_code(), $this->error->get_error_message() );
325
			return new IXR_Error( $code, $message );
326
		} else if ( is_a( $this->error, 'IXR_Error' ) ) {
327
			return $this->error;
328
		}
329
330
		return false;
331
	}
332
333
/* API Methods */
334
335
	/**
336
	 * Just authenticates with the given Jetpack credentials.
337
	 *
338
	 * @return string The current Jetpack version number
339
	 */
340
	function test_connection() {
341
		return JETPACK__VERSION;
342
	}
343
344
	function test_api_user_code( $args ) {
345
		$client_id = (int) $args[0];
346
		$user_id   = (int) $args[1];
347
		$nonce     = (string) $args[2];
348
		$verify    = (string) $args[3];
349
350
		if ( !$client_id || !$user_id || !strlen( $nonce ) || 32 !== strlen( $verify ) ) {
351
			return false;
352
		}
353
354
		$user = get_user_by( 'id', $user_id );
355
		if ( !$user || is_wp_error( $user ) ) {
356
			return false;
357
		}
358
359
		/* debugging
360
		error_log( "CLIENT: $client_id" );
361
		error_log( "USER:   $user_id" );
362
		error_log( "NONCE:  $nonce" );
363
		error_log( "VERIFY: $verify" );
364
		*/
365
366
		$jetpack_token = Jetpack_Data::get_access_token( $user_id );
0 ignored issues
show
Documentation introduced by
$user_id is of type integer, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
367
368
		$api_user_code = get_user_meta( $user_id, "jetpack_json_api_$client_id", true );
369
		if ( !$api_user_code ) {
370
			return false;
371
		}
372
373
		$hmac = hash_hmac( 'md5', json_encode( (object) array(
374
			'client_id' => (int) $client_id,
375
			'user_id'   => (int) $user_id,
376
			'nonce'     => (string) $nonce,
377
			'code'      => (string) $api_user_code,
378
		) ), $jetpack_token->secret );
379
380
		if ( ! hash_equals( $hmac, $verify ) ) {
381
			return false;
382
		}
383
384
		return $user_id;
385
	}
386
387
	/**
388
	* Disconnect this blog from the connected wordpress.com account
389
	* @return boolean
390
	*/
391
	function disconnect_blog() {
392
393
		// For tracking
394
		if ( ! empty( $this->user->ID ) ) {
395
			wp_set_current_user( $this->user->ID );
396
		}
397
398
		Jetpack::log( 'disconnect' );
399
		Jetpack::disconnect();
400
401
		return true;
402
	}
403
404
	/**
405
	 * Unlink a user from WordPress.com
406
	 *
407
	 * This will fail if called by the Master User.
408
	 */
409
	function unlink_user() {
410
		Jetpack::log( 'unlink' );
411
		return Jetpack::unlink_user();
412
	}
413
414
	/**
415
	 * Returns any object that is able to be synced
416
	 */
417
	function sync_object( $args ) {
418
		// e.g. posts, post, 5
419
		list( $module_name, $object_type, $id ) = $args;
420
		require_once dirname( __FILE__ ) . '/sync/class.jetpack-sync-modules.php';
421
		require_once dirname( __FILE__ ) . '/sync/class.jetpack-sync-sender.php';
422
423
		$sync_module = Jetpack_Sync_Modules::get_module( $module_name );
424
		$codec = Jetpack_Sync_Sender::get_instance()->get_codec();
425
426
		return $codec->encode( $sync_module->get_object_by_id( $object_type, $id ) );
427
	}
428
429
	/**
430
	 * Returns the home URL and site URL for the current site which can be used on the WPCOM side for
431
	 * IDC mitigation to decide whether sync should be allowed if the home and siteurl values differ between WPCOM
432
	 * and the remote Jetpack site.
433
	 *
434
	 * @return array
435
	 */
436
	function validate_urls_for_idc_mitigation() {
437
		require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-functions.php';
438
		return array(
439
			'home'    => Jetpack_Sync_Functions::home_url(),
440
			'siteurl' => Jetpack_Sync_Functions::site_url(),
441
		);
442
	}
443
444
	/**
445
	 * Returns what features are available. Uses the slug of the module files.
446
	 *
447
	 * @return array
448
	 */
449 View Code Duplication
	function features_available() {
450
		$raw_modules = Jetpack::get_available_modules();
451
		$modules = array();
452
		foreach ( $raw_modules as $module ) {
453
			$modules[] = Jetpack::get_module_slug( $module );
454
		}
455
456
		return $modules;
457
	}
458
459
	/**
460
	 * Returns what features are enabled. Uses the slug of the modules files.
461
	 *
462
	 * @return array
463
	 */
464 View Code Duplication
	function features_enabled() {
465
		$raw_modules = Jetpack::get_active_modules();
466
		$modules = array();
467
		foreach ( $raw_modules as $module ) {
468
			$modules[] = Jetpack::get_module_slug( $module );
469
		}
470
471
		return $modules;
472
	}
473
474
	function update_attachment_parent( $args ) {
475
		$attachment_id = (int) $args[0];
476
		$parent_id     = (int) $args[1];
477
478
		return wp_update_post( array(
479
			'ID'          => $attachment_id,
480
			'post_parent' => $parent_id,
481
		) );
482
	}
483
484
	function json_api( $args = array() ) {
485
		$json_api_args = $args[0];
486
		$verify_api_user_args = $args[1];
487
488
		$method       = (string) $json_api_args[0];
489
		$url          = (string) $json_api_args[1];
490
		$post_body    = is_null( $json_api_args[2] ) ? null : (string) $json_api_args[2];
491
		$user_details = (array) $json_api_args[4];
492
		$locale       = (string) $json_api_args[5];
493
494
		if ( !$verify_api_user_args ) {
495
			$user_id = 0;
496
		} elseif ( 'internal' === $verify_api_user_args[0] ) {
497
			$user_id = (int) $verify_api_user_args[1];
498
			if ( $user_id ) {
499
				$user = get_user_by( 'id', $user_id );
500
				if ( !$user || is_wp_error( $user ) ) {
501
					return false;
502
				}
503
			}
504
		} else {
505
			$user_id = call_user_func( array( $this, 'test_api_user_code' ), $verify_api_user_args );
506
			if ( !$user_id ) {
507
				return false;
508
			}
509
		}
510
511
		/* debugging
512
		error_log( "-- begin json api via jetpack debugging -- " );
513
		error_log( "METHOD: $method" );
514
		error_log( "URL: $url" );
515
		error_log( "POST BODY: $post_body" );
516
		error_log( "VERIFY_ARGS: " . print_r( $verify_api_user_args, 1 ) );
517
		error_log( "VERIFIED USER_ID: " . (int) $user_id );
518
		error_log( "-- end json api via jetpack debugging -- " );
519
		*/
520
521
		if ( 'en' !== $locale ) {
522
			// .org mo files are named slightly different from .com, and all we have is this the locale -- try to guess them.
523
			$new_locale = $locale;
524
			if ( strpos( $locale, '-' ) !== false ) {
525
				$locale_pieces = explode( '-', $locale );
526
				$new_locale = $locale_pieces[0];
527
				$new_locale .= ( ! empty( $locale_pieces[1] ) ) ? '_' . strtoupper( $locale_pieces[1] ) : '';
528
			} else {
529
				// .com might pass 'fr' because thats what our language files are named as, where core seems
530
				// to do fr_FR - so try that if we don't think we can load the file.
531
				if ( ! file_exists( WP_LANG_DIR . '/' . $locale . '.mo' ) ) {
532
					$new_locale =  $locale . '_' . strtoupper( $locale );
533
				}
534
			}
535
536
			if ( file_exists( WP_LANG_DIR . '/' . $new_locale . '.mo' ) ) {
537
				unload_textdomain( 'default' );
538
				load_textdomain( 'default', WP_LANG_DIR . '/' . $new_locale . '.mo' );
539
			}
540
		}
541
542
		$old_user = wp_get_current_user();
543
		wp_set_current_user( $user_id );
544
545
		$token = Jetpack_Data::get_access_token( get_current_user_id() );
546
		if ( !$token || is_wp_error( $token ) ) {
547
			return false;
548
		}
549
550
		define( 'REST_API_REQUEST', true );
551
		define( 'WPCOM_JSON_API__BASE', 'public-api.wordpress.com/rest/v1' );
552
553
		// needed?
554
		require_once ABSPATH . 'wp-admin/includes/admin.php';
555
556
		require_once JETPACK__PLUGIN_DIR . 'class.json-api.php';
557
		$api = WPCOM_JSON_API::init( $method, $url, $post_body );
558
		$api->token_details['user'] = $user_details;
559
		require_once JETPACK__PLUGIN_DIR . 'class.json-api-endpoints.php';
560
561
		$display_errors = ini_set( 'display_errors', 0 );
562
		ob_start();
563
		$content_type = $api->serve( false );
0 ignored issues
show
Unused Code introduced by
$content_type is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
564
		$output = ob_get_clean();
565
		ini_set( 'display_errors', $display_errors );
566
567
		$nonce = wp_generate_password( 10, false );
568
		$hmac  = hash_hmac( 'md5', $nonce . $output, $token->secret );
569
570
		wp_set_current_user( isset( $old_user->ID ) ? $old_user->ID : 0 );
571
572
		return array(
573
			(string) $output,
574
			(string) $nonce,
575
			(string) $hmac,
576
		);
577
	}
578
}
579