diff --git a/src/Controller/Component/ContactUsComponent.php b/src/Controller/Component/ContactUsComponent.php index bba2c6a..890a907 100644 --- a/src/Controller/Component/ContactUsComponent.php +++ b/src/Controller/Component/ContactUsComponent.php @@ -62,7 +62,7 @@ class ContactUsComponent extends Component { * @return \Cake\Datasource\EntityInterface|\CakeContactUs\Model\Entity\ContactUsFormSubmission */ public function newContactUsForm() { - if ($this->getConfig('requireCaptcha')) { + if ($this->getConfig('requireCaptcha') && PHP_SAPI !== 'cli') { $this->ContactUsFormSubmissions->addBehavior('Captcha.Captcha'); } @@ -78,8 +78,7 @@ class ContactUsComponent extends Component { if (!isset($postData)) { $postData = $this->getController()->getRequest()->getData(); } - $postData['client_ip'] = array_key_exists('client_ip', $postData) && $postData['client_ip'] ? - $postData['client_ip'] : + $postData['client_ip'] = $postData['client_ip'] ?? ($this->getConfig('clientIpHeader') ? $this->getController()->getRequest()->getHeaderLine($this->getConfig('clientIpHeader')) : $this->getController()->getRequest()->clientIp() @@ -90,7 +89,6 @@ class ContactUsComponent extends Component { 'contactUsFormSubmission' => $contactUsFormSubmission, ], $this->getController()); $result = $event->getResult(); - if ($result instanceof EntityInterface) { $postData = $result->toArray(); $contactUsFormSubmission = $this->ContactUsFormSubmissions->patchEntity($contactUsFormSubmission, $postData);