From 7010414814c09d090067f739378b136e6790eac8 Mon Sep 17 00:00:00 2001 From: prasad <prasad@vtiger.com> Date: Fri, 17 May 2024 00:17:10 +0530 Subject: [PATCH] E_ALL - fixes for Webservice --- data/CRMEntity.php | 7 +++++-- data/VTEntityDelta.php | 5 ++++- include/Webservices/Create.php | 4 ++-- include/Webservices/DataTransform.php | 4 ++-- include/Webservices/EntityMeta.php | 3 ++- include/Webservices/LineItem/VtigerLineItemMeta.php | 4 ++-- include/Webservices/OperationManager.php | 10 +++++----- include/Webservices/Update.php | 4 ++-- include/Webservices/Utils.php | 5 +++-- include/Webservices/VtigerActorOperation.php | 8 +++++--- include/Webservices/VtigerCRMObject.php | 2 +- include/Webservices/WebserviceEntityOperation.php | 4 ++-- include/events/VTEntityData.inc | 2 +- 13 files changed, 36 insertions(+), 26 deletions(-) diff --git a/data/CRMEntity.php b/data/CRMEntity.php index 469dae8ed..70feb2784 100644 --- a/data/CRMEntity.php +++ b/data/CRMEntity.php @@ -299,7 +299,7 @@ class CRMEntity { $this->column_fields['label'] = $label; if ($this->mode == 'edit') { - $description_val = from_html($this->column_fields['description'], ($insertion_mode == 'edit') ? true : false); + $description_val = from_html($this->column_fields['description'], ($this->mode == 'edit') ? true : false); $tabid = getTabid($module); $modified_date_var = $adb->formatDate($date_var, true); @@ -745,8 +745,11 @@ class CRMEntity { $update = array(); $update_params = array(); foreach($changedFields as $field) { + if (!array_key_exists($field, $updateFieldNameColumnNameMap)) { + continue; + } $fieldColumn = $updateFieldNameColumnNameMap[$field]; - if(@array_key_exists($fieldColumn, $updateFieldValues)) { + if(array_key_exists($fieldColumn, $updateFieldValues)) { array_push($update, $fieldColumn.'=?'); array_push($update_params, $updateFieldValues[$fieldColumn]); } diff --git a/data/VTEntityDelta.php b/data/VTEntityDelta.php index cada93fde..18610ff23 100644 --- a/data/VTEntityDelta.php +++ b/data/VTEntityDelta.php @@ -112,6 +112,9 @@ class VTEntityDelta extends VTEventHandler { if(empty(self::$oldEntity[$moduleName][$recordId])) { return false; } + if (!array_key_exists($fieldName, self::$entityDelta[$moduleName][$recordId])) { + return false; + } $fieldDelta = self::$entityDelta[$moduleName][$recordId][$fieldName]; if(is_array($fieldDelta)) { $fieldDelta = array_map('decode_html', $fieldDelta); @@ -124,4 +127,4 @@ class VTEntityDelta extends VTEventHandler { } } -?> \ No newline at end of file +?> diff --git a/include/Webservices/Create.php b/include/Webservices/Create.php index 369180dc6..7f5ae9b3e 100644 --- a/include/Webservices/Create.php +++ b/include/Webservices/Create.php @@ -64,7 +64,7 @@ function vtws_create($elementType, $element, $user) { throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to access reference type is denied" . $referenceObject->getEntityName()); } - } else if ($element[$fieldName] !== NULL) { + } else if (array_key_exists($fieldName, $element) && $element[$fieldName] !== NULL) { unset($element[$fieldName]); } } @@ -88,4 +88,4 @@ function vtws_create($elementType, $element, $user) { return null; } } -?> \ No newline at end of file +?> diff --git a/include/Webservices/DataTransform.php b/include/Webservices/DataTransform.php index 26460990f..32263fa92 100644 --- a/include/Webservices/DataTransform.php +++ b/include/Webservices/DataTransform.php @@ -103,7 +103,7 @@ } $references = $meta->getReferenceFieldDetails(); foreach($references as $field=>$typeList){ - if(strpos($row[$field],'x')!==false){ + if(isset($row[$field]) && strpos($row[$field],'x')!==false){ $row[$field] = vtws_getIdComponents($row[$field]); $row[$field] = $row[$field][1]; } @@ -130,7 +130,7 @@ } } } - if($row["id"]){ + if(isset($row["id"]) && $row["id"]){ unset($row["id"]); } if(isset($row[$meta->getObectIndexColumn()])){ diff --git a/include/Webservices/EntityMeta.php b/include/Webservices/EntityMeta.php index 831eb69b5..f44905466 100644 --- a/include/Webservices/EntityMeta.php +++ b/include/Webservices/EntityMeta.php @@ -8,6 +8,7 @@ * All Rights Reserved. *************************************************************************************/ +#[\AllowDynamicProperties] abstract class EntityMeta{ public static $RETRIEVE = "DetailView"; @@ -276,4 +277,4 @@ abstract class EntityMeta{ abstract public function getName($webserviceId); abstract public function isModuleEntity(); } -?> \ No newline at end of file +?> diff --git a/include/Webservices/LineItem/VtigerLineItemMeta.php b/include/Webservices/LineItem/VtigerLineItemMeta.php index 60cda71ca..efc67cd4a 100644 --- a/include/Webservices/LineItem/VtigerLineItemMeta.php +++ b/include/Webservices/LineItem/VtigerLineItemMeta.php @@ -92,7 +92,7 @@ class VtigerLineItemMeta extends VtigerCRMActorMeta { if(in_array($fieldName,$mandatoryFieldList)){ $typeOfData = $fieldType.'~M'; }else if(($dbField->not_null == 1 && $fieldName != 'incrementondel' - && $dbField->primary_key != 1) || $dbField->unique_key == 1){ + && $dbField->primary_key != 1) || (property_exists($dbField, 'unique_key') && $dbField->unique_key == 1)) { $typeOfData = $fieldType.'~M'; }else{ $typeOfData = $fieldType.'~O'; @@ -105,4 +105,4 @@ class VtigerLineItemMeta extends VtigerCRMActorMeta { } } -?> \ No newline at end of file +?> diff --git a/include/Webservices/OperationManager.php b/include/Webservices/OperationManager.php index 949ab248a..d381b48eb 100644 --- a/include/Webservices/OperationManager.php +++ b/include/Webservices/OperationManager.php @@ -9,7 +9,7 @@ *************************************************************************************/ function setBuiltIn($json){ - $json->useBuiltinEncoderDecoder = true; + Zend_Json::$useBuiltinEncoderDecoder = true; } class OperationManager{ @@ -132,10 +132,10 @@ } function handleType($type,$value){ - $result; - $value = stripslashes($value); + $result = null; + $value = $value ? stripslashes($value) : ""; $type = strtolower($type); - if($this->inParamProcess[$type]){ + if(isset($this->inParamProcess[$type]) && $this->inParamProcess[$type]){ $result = call_user_func($this->inParamProcess[$type],$value); }else{ $result = $value; @@ -210,4 +210,4 @@ } -?> \ No newline at end of file +?> diff --git a/include/Webservices/Update.php b/include/Webservices/Update.php index ce008d80a..76d8b8592 100644 --- a/include/Webservices/Update.php +++ b/include/Webservices/Update.php @@ -71,7 +71,7 @@ throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to access reference type is denied ".$referenceObject->getEntityName()); } - }else if($element[$fieldName] !== NULL){ + }else if(array_key_exists($fieldName, $element) && $element[$fieldName] !== NULL){ unset($element[$fieldName]); } } @@ -93,4 +93,4 @@ return $entity; } -?> \ No newline at end of file +?> diff --git a/include/Webservices/Utils.php b/include/Webservices/Utils.php index 2b0a1f529..08f3ecbb6 100644 --- a/include/Webservices/Utils.php +++ b/include/Webservices/Utils.php @@ -139,9 +139,10 @@ function getEmailFieldId($meta, $entityId){ function vtws_getParameter($parameterArray, $paramName,$default=null){ if (!get_magic_quotes_gpc()) { - if(is_array($parameterArray[$paramName])) { + $param = null; + if(isset($parameterArray[$paramName]) && is_array($parameterArray[$paramName])) { $param = array_map('addslashes', $parameterArray[$paramName]); - } else { + } else if (isset($parameterArray[$paramName]) && $parameterArray[$paramName]) { $param = addslashes($parameterArray[$paramName]); } } else { diff --git a/include/Webservices/VtigerActorOperation.php b/include/Webservices/VtigerActorOperation.php index 6b26288df..eea1a69f0 100644 --- a/include/Webservices/VtigerActorOperation.php +++ b/include/Webservices/VtigerActorOperation.php @@ -263,7 +263,7 @@ class VtigerActorOperation extends WebserviceEntityOperation { foreach ($moduleFields as $fieldName=>$webserviceField) { array_push($fields,$this->getDescribeFieldArray($webserviceField)); } - $label = ($app_strings[$this->meta->getObectIndexColumn()])? $app_strings[$this->meta->getObectIndexColumn()]: + $label = isset($app_strings[$this->meta->getObectIndexColumn()])? $app_strings[$this->meta->getObectIndexColumn()]: $this->meta->getObectIndexColumn(); $this->moduleFields = $fields; } @@ -276,7 +276,9 @@ class VtigerActorOperation extends WebserviceEntityOperation { if(isset($app_strings[$fieldLabel])){ $fieldLabel = $app_strings[$fieldLabel]; } - if(strcasecmp($webserviceField->getFieldName(),$this->meta->getObectIndexColumn()) === 0){ + $fieldName = $webserviceField->getFieldName(); + $fieldColumn = $this->meta->getObectIndexColumn(); + if($fieldColumn && strcasecmp($fieldName, $fieldColumn) === 0){ return $this->getIdField($fieldLabel); } @@ -334,4 +336,4 @@ class VtigerActorOperation extends WebserviceEntityOperation { } } -?> \ No newline at end of file +?> diff --git a/include/Webservices/VtigerCRMObject.php b/include/Webservices/VtigerCRMObject.php index 45f472ca0..e759f429d 100644 --- a/include/Webservices/VtigerCRMObject.php +++ b/include/Webservices/VtigerCRMObject.php @@ -185,7 +185,7 @@ class VtigerCRMObject{ global $adb; $error = false; $adb->startTransaction(); - DeleteEntity($this->getTabName(), $this->getTabName(), $this->instance, $id,$returnid); + DeleteEntity($this->getTabName(), $this->getTabName(), $this->instance, $id,""); $error = $adb->hasFailedTransaction(); $adb->completeTransaction(); return !$error; diff --git a/include/Webservices/WebserviceEntityOperation.php b/include/Webservices/WebserviceEntityOperation.php index 876d2d45d..89f9f6a3a 100644 --- a/include/Webservices/WebserviceEntityOperation.php +++ b/include/Webservices/WebserviceEntityOperation.php @@ -83,7 +83,7 @@ abstract class WebserviceEntityOperation{ break; case 'multipicklist': case 'picklist': $typeDetails["picklistValues"] = $webserviceField->getPicklistDetails($webserviceField); - $typeDetails['defaultValue'] = $typeDetails["picklistValues"][0]['value']; + $typeDetails['defaultValue'] = !empty($typeDetails["picklistValues"]) ? $typeDetails["picklistValues"][0]['value'] : null; break; case 'file': $maxUploadSize = 0; $maxUploadSize = ini_get('upload_max_filesize'); @@ -131,4 +131,4 @@ abstract class WebserviceEntityOperation{ } -?> \ No newline at end of file +?> diff --git a/include/events/VTEntityData.inc b/include/events/VTEntityData.inc index 8a87e4e0f..d53c8f31a 100644 --- a/include/events/VTEntityData.inc +++ b/include/events/VTEntityData.inc @@ -112,7 +112,7 @@ class VTEntityData{ * @return The entity id. */ function getId(){ - return $this->focus->id; + return property_exists($this->focus, "id") ? $this->focus->id : null; } /** -- GitLab