Completed
Push — try/alt-xmlrpc ( 990d55...e08316 )
by
unknown
45:25 queued 29:11
created

class.jetpack-xmlrpc-fallback.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php 
2
3
/**
4
 * A bridge between WP's built-in REST and Jetpack's XMLRPC server
5
 */
6
class Jetpack_XMLRPC_Fallback {
7
	private $xmlrpc_server;
8
9
	function init() {
10
		register_rest_route( 'jetpack/v1', '/verify_registration', array(
11
			'methods' => 'POST',
12
			'callback' => array( $this, 'verify_registration' ),
13
		) );
14
15
		// fallback for anything not yet converted
16
		register_rest_route( 'jetpack/v1', '/xmlrpc', array(
17
			'methods' => 'POST',
18
			'callback' => array( $this, 'xmlrpc_fallback' ),
19
		) );
20
	}
21
22
	function verify_registration( $request ) {
23
		$this->load_xmlrpc();
24
		return $this->xmlrpc_server->verify_registration( array( $request['secret_1'], $request['state'] ) );
25
	}
26
27
	// allow invocation of Jetpack XMLRPC, and a handful of core XMLRPC methods, over REST
28
	// does NOT allow random XMLRPC requests
29
	function xmlrpc_fallback( $request ) {
30
		$this->load_xmlrpc();
31
		$methods = $this->xmlrpc->xmlrpc_methods();
0 ignored issues
show
$methods 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...
32
	}
33
34
	private function load_xmlrpc() {
35
		if ( ! $this->xmlrpc_server ) {
36
			require_once JETPACK__PLUGIN_DIR . 'class.jetpack-xmlrpc-server.php';
37
			$this->xmlrpc_server = new Jetpack_XMLRPC_Server();
38
		}
39
	}
40
}
41