@@ -73,6 +73,13 @@ public function __construct(?ConfigurationInterface $configuration = null, ?Logg
7373
7474 $ this ->json_mapper = new \JsonMapper ();
7575
76+ // Adjust settings for JsonMapper v5.0 BC
77+ if (property_exists ($ this ->json_mapper , 'bStrictNullTypesInArrays ' )) {
78+ $ this ->json_mapper ->bStrictNullTypesInArrays = false ; // if you want to allow nulls in arrays
79+ }
80+ $ this ->json_mapper ->bStrictNullTypes = false ; // if you want to allow nulls
81+ $ this ->json_mapper ->bStrictObjectTypeChecking = false ; // if you want to disable strict type checking
82+
7683 // Fix "\JiraRestApi\JsonMapperHelper::class" syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$'
7784 $ this ->json_mapper ->undefinedPropertyHandler = [new \JiraRestApi \JsonMapperHelper (), 'setUndefinedProperty ' ];
7885
@@ -198,31 +205,7 @@ public function exec(string $context, array|string|null $post_data = null, ?stri
198205 $ this ->log ->info ("Curl $ custom_request: $ url JsonData= " .json_encode ($ post_data , JSON_UNESCAPED_UNICODE ));
199206 }
200207
201- curl_reset ($ this ->curl );
202- $ ch = $ this ->curl ;
203- curl_setopt ($ ch , CURLOPT_CONNECTTIMEOUT , $ this ->configuration ->getTimeout ());
204- curl_setopt ($ ch , CURLOPT_TIMEOUT , $ this ->configuration ->getTimeout ());
205- curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
206- curl_setopt ($ ch , CURLOPT_URL , $ url );
207-
208- // post_data
209- if (!is_null ($ post_data )) {
210- // PUT REQUEST
211- if (!is_null ($ custom_request ) && $ custom_request == 'PUT ' ) {
212- curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , 'PUT ' );
213- curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ post_data );
214- }
215- if (!is_null ($ custom_request ) && $ custom_request == 'DELETE ' ) {
216- curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , 'DELETE ' );
217- } else {
218- curl_setopt ($ ch , CURLOPT_POST , true );
219- curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ post_data );
220- }
221- } else {
222- if (!is_null ($ custom_request ) && $ custom_request == 'DELETE ' ) {
223- curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , 'DELETE ' );
224- }
225- }
208+ $ ch = $ this ->prepareCurlRequest ($ url , $ post_data , $ custom_request );
226209
227210 // save HTTP Headers
228211 $ curl_http_headers = [
@@ -621,6 +604,37 @@ private function proxyConfigCurlHandle(\CurlHandle $ch): void
621604 }
622605 }
623606
607+ private function prepareCurlRequest (string $ url , array |string |null $ post_data = null , ?string $ custom_request = null )
608+ {
609+ curl_reset ($ this ->curl );
610+ $ ch = $ this ->curl ;
611+ curl_setopt ($ ch , CURLOPT_CONNECTTIMEOUT , $ this ->configuration ->getTimeout ());
612+ curl_setopt ($ ch , CURLOPT_TIMEOUT , $ this ->configuration ->getTimeout ());
613+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
614+ curl_setopt ($ ch , CURLOPT_URL , $ url );
615+
616+ // post_data
617+ if (!is_null ($ post_data )) {
618+ // PUT REQUEST
619+ if (!is_null ($ custom_request ) && $ custom_request == 'PUT ' ) {
620+ curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , 'PUT ' );
621+ curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ post_data );
622+ }
623+ if (!is_null ($ custom_request ) && $ custom_request == 'DELETE ' ) {
624+ curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , 'DELETE ' );
625+ } else {
626+ curl_setopt ($ ch , CURLOPT_POST , true );
627+ curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ post_data );
628+ }
629+ } else {
630+ if (!is_null ($ custom_request ) && $ custom_request == 'DELETE ' ) {
631+ curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , 'DELETE ' );
632+ }
633+ }
634+
635+ return $ ch ;
636+ }
637+
624638 /**
625639 * setting REST API url to V2.
626640 *
0 commit comments