[-] WS : Multiple fix on Web Services

This commit is contained in:
aKorczak
2012-08-31 09:41:22 +00:00
parent 0213db6885
commit 8bead1af23
5 changed files with 49 additions and 12 deletions
@@ -188,6 +188,7 @@ class WebserviceOutputBuilderCore
{
return $this->status;
}
public function getStatusInt()
{
return $this->statusInt;
@@ -283,7 +284,7 @@ class WebserviceOutputBuilderCore
if (is_null($this->wsResource))
throw new WebserviceException ('You must set web service resource for get the resources list.', array(82, 500));
$output = '';
$more_attr = array('shop_name' => Configuration::get('PS_SHOP_NAME'));
$more_attr = array('shop_name' => htmlentities(Configuration::get('PS_SHOP_NAME')));
$output .= $this->objectRender->renderNodeHeader('api', array(), $more_attr);
foreach ($this->wsResource as $resourceName => $resource)
{
@@ -675,7 +676,7 @@ class WebserviceOutputBuilderCore
if (!is_null($this->schemaToDisplay))
$field['synopsis_details'] = $this->getSynopsisDetails($field);
$field['is_association'] = true;
$output .= $this->setIndent($depth-1).$this->objectRender->renderField($field);
}
}
@@ -755,10 +756,12 @@ class WebserviceOutputBuilderCore
$this->virtualFields[$entity_name][] = array('parameters' => $parameters, 'object' => $object, 'method' => $method, 'type' => gettype($object));
}
public function getVirtualFields()
{
return $this->virtualFields;
}
public function addVirtualFields($entity_name, $entity_object)
{
$arr_return = array();
+30 -5
View File
@@ -392,6 +392,10 @@ class WebserviceRequestCore
$this->_startTime = microtime(true);
$this->objects = array();
// Error handler
set_error_handler(array($this, 'webserviceErrorHandler'));
ini_set('html_errors', 'off');
// Two global vars, for compatibility with the PS core...
global $webservice_call, $display_errors;
$webservice_call = true;
@@ -401,9 +405,7 @@ class WebserviceRequestCore
// set the output object which manage the content and header structure and informations
$this->objOutput = new WebserviceOutputBuilder($this->wsUrl);
// Error handler
set_error_handler(array($this, 'webserviceErrorHandler'));
ini_set('html_errors', 'off');
$this->_key = trim($key);
@@ -545,7 +547,10 @@ class WebserviceRequestCore
public function setError($status, $label, $code)
{
global $display_errors;
$this->objOutput->setStatus($status);
if (!isset($display_errors))
$display_errors = strtolower(ini_get('display_errors')) != 'off';
if (isset($this->objOutput))
$this->objOutput->setStatus($status);
$this->errors[] = $display_errors ? array($code, $label) : 'Internal error. To see this error please display the PHP errors.';
}
@@ -603,8 +608,28 @@ class WebserviceRequestCore
*/
public function webserviceErrorHandler($errno, $errstr, $errfile, $errline)
{
if (!(error_reporting() & $errno))
echo 'Error Handler WebserviceRequest';
$display_errors = strtolower(ini_get('display_errors')) != 'off';
if (!(error_reporting() & $errno) || $display_errors)
return;
$errortype = array (
E_ERROR => 'Error',
E_WARNING => 'Warning',
E_PARSE => 'Parse',
E_NOTICE => 'Notice',
E_CORE_ERROR => 'Core Error',
E_CORE_WARNING => 'Core Warning',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning',
E_USER_ERROR => 'Error',
E_USER_WARNING => 'User warning',
E_USER_NOTICE => 'User notice',
E_STRICT => 'Runtime Notice',
E_RECOVERABLE_ERROR => 'Recoverable error'
);
$type = (isset($errortype[$errno]) ? $errortype[$errno] : 'Unknown error');
error_log('[PHP '.$type.' #'.$errno.'] '.$errstr.' ('.$errfile.', line '.$errline.')');
switch($errno)
{