From 45070f1322022a60658f70ab93e3af42880957ff Mon Sep 17 00:00:00 2001 From: ch Date: Wed, 19 Apr 2023 18:37:30 +0300 Subject: [PATCH 1/3] Fix PHP deprecation error in SDKException. --- src/com/zoho/crm/api/exception/SDKException.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/zoho/crm/api/exception/SDKException.php b/src/com/zoho/crm/api/exception/SDKException.php index b3731d1..4bc6bff 100755 --- a/src/com/zoho/crm/api/exception/SDKException.php +++ b/src/com/zoho/crm/api/exception/SDKException.php @@ -39,7 +39,7 @@ public function __construct($code, $message, $details=null, \Exception $cause=nu $this->_message = $cause->getMessage(); } - parent::__construct($message); + parent::__construct(is_null($message) ? "" : $message); } /** @@ -99,4 +99,4 @@ public function __toString() return $returnMsg; } -} \ No newline at end of file +} From 75f435e5a66a529a75e1e566a22fb9a7724d3db5 Mon Sep 17 00:00:00 2001 From: ch Date: Wed, 19 Apr 2023 18:41:22 +0300 Subject: [PATCH 2/3] Fix PHP deprecation error in SDKException. --- composer.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index a5002da..6e405e1 100755 --- a/composer.json +++ b/composer.json @@ -1,14 +1,19 @@ { - "name" : "zohocrm/php-sdk", + "name" : "templatemonster/zohocrm-php-sdk", "description" : "Zoho CRM API SDK for PHP", "type" : "sdk", - "homepage": "https://github.com/zoho/zohocrm-php-sdk", + "homepage": "https://github.com/Plasma-Platform/zohocrm-php-sdk", "authors" : [ { "name" : "Zoho CRM API Team", "email" : "support@zohocrm.com", "homepage" : "https://www.zoho.com/crm/help/customer-support.html", "role" : "Developer" + }, + { + "name" : "Pavlo Titkov", + "email" : "ch@templatemonster.me", + "role" : "Developer" } ], "require" : { From 3a6288aa914d1ee000a9ec794fd0fb4b1f7b131f Mon Sep 17 00:00:00 2001 From: ch Date: Wed, 19 Apr 2023 19:34:02 +0300 Subject: [PATCH 3/3] Fix PHP deprecation error for utf8_encode. --- composer.json | 4 +++- src/com/zoho/crm/api/Initializer.php | 2 +- src/com/zoho/crm/api/util/Converter.php | 2 +- .../zoho/crm/api/util/FormDataConverter.php | 20 +++++++++---------- .../zoho/crm/api/util/ModuleFieldsHandler.php | 2 +- src/com/zoho/crm/api/util/Utility.php | 2 +- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 6e405e1..0bf13c5 100755 --- a/composer.json +++ b/composer.json @@ -19,7 +19,9 @@ "require" : { "php" : ">=7.0", "ext-json" : "*", - "ext-curl" : "*" + "ext-curl" : "*", + "ext-curl" : "*", + "ext-mbstring": "*" }, "require-dev" : { "phpunit/phpunit" : ">=5.7" diff --git a/src/com/zoho/crm/api/Initializer.php b/src/com/zoho/crm/api/Initializer.php index a7a9535..cd2bedf 100755 --- a/src/com/zoho/crm/api/Initializer.php +++ b/src/com/zoho/crm/api/Initializer.php @@ -343,7 +343,7 @@ private function getEncodedKey($user, $environment) $key = explode("@", $userMail)[0] . $environment->getUrl(); - $input = unpack('C*', utf8_encode($key)); + $input = unpack('C*', mb_convert_encoding($key, 'UTF-8')); return base64_encode(implode(array_map("chr", $input))); } diff --git a/src/com/zoho/crm/api/util/Converter.php b/src/com/zoho/crm/api/util/Converter.php index 18f0012..1e4b939 100755 --- a/src/com/zoho/crm/api/util/Converter.php +++ b/src/com/zoho/crm/api/util/Converter.php @@ -274,7 +274,7 @@ public function getEncodedFileName() $fileName = explode("@",$fileName)[0] . Initializer::getInitializer()->getEnvironment()->getUrl(); - $input = unpack('C*', utf8_encode($fileName)); + $input = unpack('C*', mb_convert_encoding($fileName, 'UTF-8')); $str = base64_encode(implode(array_map("chr", $input))); diff --git a/src/com/zoho/crm/api/util/FormDataConverter.php b/src/com/zoho/crm/api/util/FormDataConverter.php index fe21376..35e9e8b 100644 --- a/src/com/zoho/crm/api/util/FormDataConverter.php +++ b/src/com/zoho/crm/api/util/FormDataConverter.php @@ -109,11 +109,11 @@ public function appendToRequest(&$requestBase, $requestObject) $date = new \DateTime(); - $data = utf8_encode($lineEnd); + $data = mb_convert_encoding($lineEnd, 'UTF-8'); $current_time_long = $date->getTimestamp(); - $boundaryStart = utf8_encode($hypen.(string)$current_time_long.$lineEnd); + $boundaryStart = mb_convert_encoding($hypen.(string)$current_time_long.$lineEnd, 'UTF-8'); for ($i = 0; $i < sizeof($keysDetail); $i++) { @@ -129,14 +129,14 @@ public function appendToRequest(&$requestBase, $requestObject) $contentDisp = "Content-Disposition: form-data; name=\"".$key."\";filename=\"".$fileName."\"".$lineEnd.$lineEnd; - $data = $data.utf8_encode($contentDisp); + $data = $data.mb_convert_encoding($contentDisp, 'UTF-8'); - $data = $data.$fileData.utf8_encode($lineEnd); + $data = $data.$fileData.mb_convert_encoding($lineEnd, 'UTF-8'); } } $boundaryend = $hypen . (string)$current_time_long . $hypen . $lineEnd . $lineEnd; - $data = $data . utf8_encode($boundaryend); + $data = $data . mb_convert_encoding($boundaryend, 'UTF-8'); $header = ['ENCTYPE: multipart/form-data','Content-Type:multipart/form-data;boundary=' . (string)$current_time_long]; @@ -160,19 +160,19 @@ public function appendToRequest(&$requestBase, $requestObject) $header = ['ENCTYPE: multipart/form-data','Content-Type:multipart/form-data;boundary='.(string)$current_time_long]; - $data = utf8_encode($lineEnd); + $data = mb_convert_encoding($lineEnd, 'UTF-8'); - $boundaryStart = utf8_encode($hypen.(string)$current_time_long.$lineEnd) ; + $boundaryStart = mb_convert_encoding($hypen.(string)$current_time_long.$lineEnd, 'UTF-8') ; $data = $data.$boundaryStart; - $data = $data.utf8_encode($contentDisp); + $data = $data.mb_convert_encoding($contentDisp, 'UTF-8'); - $data = $data.$fileData.utf8_encode($lineEnd); + $data = $data.$fileData.mb_convert_encoding($lineEnd, 'UTF-8'); $boundaryend = $hypen.(string)$current_time_long.$hypen.$lineEnd.$lineEnd; - $data = $data.utf8_encode($boundaryend); + $data = $data.mb_convert_encoding($boundaryend, 'UTF-8'); $requestBase[CURLOPT_HTTPHEADER] = $header; diff --git a/src/com/zoho/crm/api/util/ModuleFieldsHandler.php b/src/com/zoho/crm/api/util/ModuleFieldsHandler.php index 6e6ae5f..cce6093 100644 --- a/src/com/zoho/crm/api/util/ModuleFieldsHandler.php +++ b/src/com/zoho/crm/api/util/ModuleFieldsHandler.php @@ -29,7 +29,7 @@ private static function getFileName() $fileName = explode("@", $fileName)[0] . Initializer::getInitializer()->getEnvironment()->getUrl(); - $input = unpack('C*', utf8_encode($fileName)); + $input = unpack('C*', mb_convert_encoding($fileName, 'UTF-8')); return base64_encode(implode(array_map("chr", $input))); } diff --git a/src/com/zoho/crm/api/util/Utility.php b/src/com/zoho/crm/api/util/Utility.php index ae07436..e29502c 100755 --- a/src/com/zoho/crm/api/util/Utility.php +++ b/src/com/zoho/crm/api/util/Utility.php @@ -316,7 +316,7 @@ private static function getFileName() $fileName = explode("@", $fileName)[0] . Initializer::getInitializer()->getEnvironment()->getUrl(); - $input = unpack('C*', utf8_encode($fileName)); + $input = unpack('C*', mb_convert_encoding($fileName, 'UTF-8')); $str = base64_encode(implode(array_map("chr", $input)));