[-] WS : Multiple fix on Web Services
This commit is contained in:
@@ -177,7 +177,7 @@ class Autoload
|
|||||||
$classes = array_merge($classes, $this->getClassesFromDir($path.$file.'/'));
|
$classes = array_merge($classes, $this->getClassesFromDir($path.$file.'/'));
|
||||||
else if (substr($file, -4) == '.php')
|
else if (substr($file, -4) == '.php')
|
||||||
{
|
{
|
||||||
$content = file_get_contents($this->root_dir.$path.$file);
|
$content = file_get_contents($this->root_dir.$path.$file);
|
||||||
$pattern = '#\W((abstract\s+)?class|interface)\s+(?P<classname>'.basename($file, '.php').'(Core)?)'
|
$pattern = '#\W((abstract\s+)?class|interface)\s+(?P<classname>'.basename($file, '.php').'(Core)?)'
|
||||||
.'(\s+extends\s+[a-z][a-z0-9_]*)?(\s+implements\s+[a-z][a-z0-9_]*(\s*,\s*[a-z][a-z0-9_]*)*)?\s*\{#i';
|
.'(\s+extends\s+[a-z][a-z0-9_]*)?(\s+implements\s+[a-z][a-z0-9_]*(\s*,\s*[a-z][a-z0-9_]*)*)?\s*\{#i';
|
||||||
if (preg_match($pattern, $content, $m))
|
if (preg_match($pattern, $content, $m))
|
||||||
|
|||||||
@@ -1037,7 +1037,10 @@ abstract class ObjectModelCore
|
|||||||
ON (main.`'.bqSQL($this->def['primary']).'` = `multi_shop_'.bqSQL($this->def['table']).'`.`'.bqSQL($this->def['primary']).'`)';
|
ON (main.`'.bqSQL($this->def['primary']).'` = `multi_shop_'.bqSQL($this->def['table']).'`.`'.bqSQL($this->def['primary']).'`)';
|
||||||
foreach ($vars['shopIDs'] as $id_shop)
|
foreach ($vars['shopIDs'] as $id_shop)
|
||||||
$or[] = ' `multi_shop_'.bqSQL($this->def['table']).'`.id_shop = '.(int)$id_shop.' ';
|
$or[] = ' `multi_shop_'.bqSQL($this->def['table']).'`.id_shop = '.(int)$id_shop.' ';
|
||||||
$sql_filter = ' AND ('.implode('OR', $or).') '.$sql_filter;
|
$prepend = '';
|
||||||
|
if (count($or))
|
||||||
|
$prepend = 'AND ('.implode('OR', $or).')';
|
||||||
|
$sql_filter = $prepend.$sql_filter;
|
||||||
$sql_join = $multi_shop_join.' '.$sql_join;
|
$sql_join = $multi_shop_join.' '.$sql_join;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1045,7 +1048,11 @@ abstract class ObjectModelCore
|
|||||||
$vars = get_class_vars($class_name);
|
$vars = get_class_vars($class_name);
|
||||||
foreach ($vars['shopIDs'] as $id_shop)
|
foreach ($vars['shopIDs'] as $id_shop)
|
||||||
$or[] = ' main.id_shop = '.(int)$id_shop.' ';
|
$or[] = ' main.id_shop = '.(int)$id_shop.' ';
|
||||||
$sql_filter = ' AND ('.implode('OR', $or).') '.$sql_filter;
|
|
||||||
|
$prepend = '';
|
||||||
|
if (count($or))
|
||||||
|
$prepend = 'AND ('.implode('OR', $or).')';
|
||||||
|
$sql_filter = $prepend.' '.$sql_filter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$query = '
|
$query = '
|
||||||
@@ -1054,7 +1061,6 @@ abstract class ObjectModelCore
|
|||||||
WHERE 1 '.$sql_filter.'
|
WHERE 1 '.$sql_filter.'
|
||||||
'.($sql_sort != '' ? $sql_sort : '').'
|
'.($sql_sort != '' ? $sql_sort : '').'
|
||||||
'.($sql_limit != '' ? $sql_limit : '');
|
'.($sql_limit != '' ? $sql_limit : '');
|
||||||
|
|
||||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -596,7 +596,10 @@ abstract class DbCore
|
|||||||
|
|
||||||
$errno = $this->getNumberError();
|
$errno = $this->getNumberError();
|
||||||
if ($webservice_call && $errno)
|
if ($webservice_call && $errno)
|
||||||
WebserviceRequest::getInstance()->setError(500, '[SQL Error] '.$this->getMsgError().'. Query was : '.$sql, 97);
|
{
|
||||||
|
$dbg = debug_backtrace();
|
||||||
|
WebserviceRequest::getInstance()->setError(500, '[SQL Error] '.$this->getMsgError().'. From '.(isset($dbg[3]['class']) ? $dbg[3]['class'] : '').'->'.$dbg[3]['function'].'() Query was : '.$sql, 97);
|
||||||
|
}
|
||||||
else if (_PS_DEBUG_SQL_ && $errno && !defined('PS_INSTALLATION_IN_PROGRESS'))
|
else if (_PS_DEBUG_SQL_ && $errno && !defined('PS_INSTALLATION_IN_PROGRESS'))
|
||||||
{
|
{
|
||||||
if ($sql)
|
if ($sql)
|
||||||
|
|||||||
@@ -188,6 +188,7 @@ class WebserviceOutputBuilderCore
|
|||||||
{
|
{
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatusInt()
|
public function getStatusInt()
|
||||||
{
|
{
|
||||||
return $this->statusInt;
|
return $this->statusInt;
|
||||||
@@ -283,7 +284,7 @@ class WebserviceOutputBuilderCore
|
|||||||
if (is_null($this->wsResource))
|
if (is_null($this->wsResource))
|
||||||
throw new WebserviceException ('You must set web service resource for get the resources list.', array(82, 500));
|
throw new WebserviceException ('You must set web service resource for get the resources list.', array(82, 500));
|
||||||
$output = '';
|
$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);
|
$output .= $this->objectRender->renderNodeHeader('api', array(), $more_attr);
|
||||||
foreach ($this->wsResource as $resourceName => $resource)
|
foreach ($this->wsResource as $resourceName => $resource)
|
||||||
{
|
{
|
||||||
@@ -675,7 +676,7 @@ class WebserviceOutputBuilderCore
|
|||||||
|
|
||||||
if (!is_null($this->schemaToDisplay))
|
if (!is_null($this->schemaToDisplay))
|
||||||
$field['synopsis_details'] = $this->getSynopsisDetails($field);
|
$field['synopsis_details'] = $this->getSynopsisDetails($field);
|
||||||
|
$field['is_association'] = true;
|
||||||
$output .= $this->setIndent($depth-1).$this->objectRender->renderField($field);
|
$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));
|
$this->virtualFields[$entity_name][] = array('parameters' => $parameters, 'object' => $object, 'method' => $method, 'type' => gettype($object));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVirtualFields()
|
public function getVirtualFields()
|
||||||
{
|
{
|
||||||
return $this->virtualFields;
|
return $this->virtualFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addVirtualFields($entity_name, $entity_object)
|
public function addVirtualFields($entity_name, $entity_object)
|
||||||
{
|
{
|
||||||
$arr_return = array();
|
$arr_return = array();
|
||||||
|
|||||||
@@ -392,6 +392,10 @@ class WebserviceRequestCore
|
|||||||
$this->_startTime = microtime(true);
|
$this->_startTime = microtime(true);
|
||||||
$this->objects = array();
|
$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...
|
// Two global vars, for compatibility with the PS core...
|
||||||
global $webservice_call, $display_errors;
|
global $webservice_call, $display_errors;
|
||||||
$webservice_call = true;
|
$webservice_call = true;
|
||||||
@@ -401,9 +405,7 @@ class WebserviceRequestCore
|
|||||||
// set the output object which manage the content and header structure and informations
|
// set the output object which manage the content and header structure and informations
|
||||||
$this->objOutput = new WebserviceOutputBuilder($this->wsUrl);
|
$this->objOutput = new WebserviceOutputBuilder($this->wsUrl);
|
||||||
|
|
||||||
// Error handler
|
|
||||||
set_error_handler(array($this, 'webserviceErrorHandler'));
|
|
||||||
ini_set('html_errors', 'off');
|
|
||||||
|
|
||||||
$this->_key = trim($key);
|
$this->_key = trim($key);
|
||||||
|
|
||||||
@@ -545,7 +547,10 @@ class WebserviceRequestCore
|
|||||||
public function setError($status, $label, $code)
|
public function setError($status, $label, $code)
|
||||||
{
|
{
|
||||||
global $display_errors;
|
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.';
|
$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)
|
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;
|
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)
|
switch($errno)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user