Fix Uncaught TypeError: Cannot access offset of type string on string in PHP8 in sendWebHook method.
							parent
							
								
									04a4d959fd
								
							
						
					
					
						commit
						3ee7a7380d
					
				| 
						 | 
				
			
			@ -13,3 +13,4 @@ __MACOSX/
 | 
			
		|||
.buildpath
 | 
			
		||||
.settings/
 | 
			
		||||
/.vscode
 | 
			
		||||
/.vs
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1087,7 +1087,7 @@ namespace {
 | 
			
		|||
         * Send Webhook
 | 
			
		||||
         *
 | 
			
		||||
         * @return bool|string
 | 
			
		||||
         * @var array $replacements an array of the replacements
 | 
			
		||||
         * @var array $replacements should be an array of key value as strings where key is the placeholder name to replace in json template with the value
 | 
			
		||||
         *
 | 
			
		||||
         */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1096,8 +1096,13 @@ namespace {
 | 
			
		|||
            $error = "";
 | 
			
		||||
            $success = 1;
 | 
			
		||||
 | 
			
		||||
            $jsonMessage = $this->json;
 | 
			
		||||
 | 
			
		||||
            $replacements['#message'] = $this->stripTagsFromMessage($replacements['#message']);
 | 
			
		||||
            $jsonMessage = strtr($this->json, $replacements);
 | 
			
		||||
 | 
			
		||||
           foreach($replacements as $key => $val) {
 | 
			
		||||
                 $jsonMessage = str_replace($key, $val, $jsonMessage);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $curl = curl_init($this->url);
 | 
			
		||||
            curl_setopt($curl, CURLOPT_POST, 1);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -470,7 +470,7 @@ class ConfigController extends AbstractController
 | 
			
		|||
            $webhook = psm_build_webhook();
 | 
			
		||||
            $webhook->setUrl($user->webhook_url);
 | 
			
		||||
            $webhook->setJson($user->webhook_json);
 | 
			
		||||
            $message = (psm_get_lang('config', 'test_message'));
 | 
			
		||||
            $message = ['#message' => (psm_get_lang('config', 'test_message'))];
 | 
			
		||||
            $result = $webhook->sendWebhook($message);
 | 
			
		||||
            if ($result==1) {
 | 
			
		||||
                $this->addMessage(psm_get_lang('config', 'webhook_sent'), 'success');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue