Completed
Push — try/alt-xmlrpc ( e08316...b11532 )
by
unknown
64:36 queued 54:32
created

class.jetpack-xmlrpc-fallback.php (2 issues)

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
The property xmlrpc does not seem to exist. Did you mean xmlrpc_server?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
$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