MDL-12886 zend base class improvements, somebody forgot to update Zend framework, this should help with compativiltiy too
This commit is contained in:
+13
-19
@@ -61,10 +61,9 @@ function webservice_protocol_is_enabled($protocol) {
|
||||
interface webservice_server {
|
||||
/**
|
||||
* Process request from client.
|
||||
* @param bool $simple use simple authentication
|
||||
* @return void
|
||||
*/
|
||||
public function run($simple);
|
||||
public function run();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,8 +107,10 @@ abstract class webservice_zend_server implements webservice_server {
|
||||
|
||||
/**
|
||||
* Contructor
|
||||
* @param bool $simple use simple authentication
|
||||
*/
|
||||
public function __construct($zend_class) {
|
||||
public function __construct($simple, $zend_class) {
|
||||
$this->simple = $simple;
|
||||
$this->zend_class = $zend_class;
|
||||
}
|
||||
|
||||
@@ -118,9 +119,7 @@ abstract class webservice_zend_server implements webservice_server {
|
||||
* @param bool $simple use simple authentication
|
||||
* @return void
|
||||
*/
|
||||
public function run($simple) {
|
||||
$this->simple = $simple;
|
||||
|
||||
public function run() {
|
||||
// we will probably need a lot of memory in some functions
|
||||
@raise_memory_limit('128M');
|
||||
|
||||
@@ -143,9 +142,12 @@ abstract class webservice_zend_server implements webservice_server {
|
||||
// make a list of all functions user is allowed to excecute
|
||||
$this->init_service_class();
|
||||
|
||||
// start the server
|
||||
// tell server what functions are available
|
||||
$this->zend_server->setClass($this->service_class);
|
||||
|
||||
// execute and return response, this sends some headers too
|
||||
$response = $this->zend_server->handle();
|
||||
|
||||
/*
|
||||
$grrr = ob_get_clean();
|
||||
error_log($grrr);
|
||||
@@ -333,14 +335,7 @@ class '.$classname.' {
|
||||
* @return void
|
||||
*/
|
||||
protected function init_zend_server() {
|
||||
include "Zend/Loader.php";
|
||||
Zend_Loader::registerAutoload();
|
||||
//TODO: set up some server options and debugging too - maybe a new method
|
||||
//TODO: add some zend exeption handler too
|
||||
$this->zend_server = new $this->zend_class();
|
||||
|
||||
// TODO: solve debugging level somehow
|
||||
Zend_XmlRpc_Server_Fault::attachFaultException('moodle_exception');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -499,8 +494,10 @@ abstract class webservice_base_server implements webservice_server {
|
||||
|
||||
/**
|
||||
* Contructor
|
||||
* @param bool $simple use simple authentication
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct($simple) {
|
||||
$this->simple = $simple;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -528,12 +525,9 @@ abstract class webservice_base_server implements webservice_server {
|
||||
|
||||
/**
|
||||
* Process request from client.
|
||||
* @param bool $simple use simple authentication
|
||||
* @return void
|
||||
*/
|
||||
public function run($simple) {
|
||||
$this->simple = $simple;
|
||||
|
||||
public function run() {
|
||||
// we will probably need a lot of memory in some functions
|
||||
@raise_memory_limit('128M');
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ class webservice_rest_server extends webservice_base_server {
|
||||
/**
|
||||
* Contructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
public function __construct($simple) {
|
||||
parent::__construct($simple);
|
||||
$this->wsname = 'rest';
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ if (!webservice_protocol_is_enabled('rest')) {
|
||||
die;
|
||||
}
|
||||
|
||||
$server = new webservice_rest_server();
|
||||
$server->run(false);
|
||||
$server = new webservice_rest_server(false);
|
||||
$server->run();
|
||||
die;
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ if (!webservice_protocol_is_enabled('rest')) {
|
||||
die;
|
||||
}
|
||||
|
||||
$server = new webservice_rest_server();
|
||||
$server->run(true);
|
||||
$server = new webservice_rest_server(true);
|
||||
$server->run();
|
||||
die;
|
||||
|
||||
|
||||
|
||||
@@ -32,11 +32,23 @@ require_once("$CFG->dirroot/webservice/lib.php");
|
||||
class webservice_xmlrpc_server extends webservice_zend_server {
|
||||
/**
|
||||
* Contructor
|
||||
* @param bool $simple use simple authentication
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct('Zend_XmlRpc_Server');
|
||||
public function __construct($simple) {
|
||||
require_once 'Zend/XmlRpc/Server.php';
|
||||
parent::__construct($simple, 'Zend_XmlRpc_Server');
|
||||
$this->wsname = 'xmlrpc';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up zend serice class
|
||||
* @return void
|
||||
*/
|
||||
protected function init_zend_server() {
|
||||
parent::init_zend_server();
|
||||
// this exception indicates request failed
|
||||
Zend_XmlRpc_Server_Fault::attachFaultException('moodle_exception');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,8 +66,7 @@ class webservice_xmlrpc_test_client implements webservice_test_client_interface
|
||||
//zend expects 0 based array with numeric indexes
|
||||
$params = array_values($params);
|
||||
|
||||
include "Zend/Loader.php";
|
||||
Zend_Loader::registerAutoload();
|
||||
require_once 'Zend/XmlRpc/Client.php';
|
||||
$client = new Zend_XmlRpc_Client($serverurl);
|
||||
return $client->call($function, $params);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ if (!webservice_protocol_is_enabled('xmlrpc')) {
|
||||
die;
|
||||
}
|
||||
|
||||
$server = new webservice_xmlrpc_server();
|
||||
$server->run(false);
|
||||
$server = new webservice_xmlrpc_server(true);
|
||||
$server->run();
|
||||
die;
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ if (!webservice_protocol_is_enabled('xmlrpc')) {
|
||||
die;
|
||||
}
|
||||
|
||||
$server = new webservice_xmlrpc_server();
|
||||
$server->run(true);
|
||||
$server = new webservice_xmlrpc_server(true);
|
||||
$server->run();
|
||||
die;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user