After upgrading to PHP 5.2.9 I had an issue with the sugar SOAP interface when submitting a query within a soap request.
When I made the following request to get all related contacts from an account with a where clause I got a error response within the nusoap that the SQL query was not correct. Issue was that the quotes ' where filter out (replaced by spaces).
I made the following request (from Joomla):
The issue was in the Query, in the example the search_filter:PHP Code:$cache = new nusoap_wsdlcache( JPATH_BASE . DS . 'cache', 86400);
$url = $this->portal_config->sugarhost . '/soap.php?wsdl';
$wsdl = $cache->get( $url);
if(is_null($wsdl)) {
$wsdl = new wsdl($url, '', '', '', '', 5);
$cache->put($wsdl);
}
// Pick up the sugar session id;
$sugar_session_id = $session->get('session_id', null, 'SUGAR' );
$client = new nusoap_client( $wsdl, 'wsdl' );
$client->debugLevel = 0;
if ( $sugar_session_id == null ) {
$auth_array = array( 'user_auth' => array (
'user_name' => $this->portal_config->sugar_username,
'password' => md5($this->portal_config->sugar_password),
)
);
$login_results = $client->call('login',$auth_array);
$sugar_session_id = $login_results['id'];
// Save the session id of Sugar;
$session->set("session_id", $sugar_session_id, 'SUGAR' );
}
$set_rel_params = array(
'session' => $sugar_session_id,
'set_relationship_value'=> $sugar_relation
);
$return_fields = array( 'id', 'first_name', 'last_name', 'email1' );
$accounts_id = JRequest::getvar( 'id' , '0' );
$search_filter = " account_id = '" . $accounts_id . "'";
$client->use_curl = true;
$record_list = $client->call( 'get_entry_list', array( $sugar_session_id, 'Contacts', $search_filter , 'last_name' , 0, $return_fields, 10));
When this request was made to sugarcrm the XML request arrived correctly and the quote was correctly replaced into ' entity with the XML request. Normally this &apos is then replaced in the XML response with a single quote ' but since php 5.2.9. this was no longer the case.PHP Code:$search_filter = " account_id = '" . $accounts_id . "'";
Solution that I've added is to adjust the nusoap class within sugar:
/include/nusoap/nusoap.php
Goto the function service (arround line 3259) and place the following line into it:
Have checked and tested it and it solves my issue.PHP Code:function service($data){
global $HTTP_SERVER_VARS;
$data = ereg_replace("'","'",$data);
Richard
Platform used: centos 5.2 / PHP 5.2.9


LinkBack URL
About LinkBacks



Reply With Quote


Bookmarks