From 49772771d036efe5dd9be60ad4f1d13dd7234b8f Mon Sep 17 00:00:00 2001 From: Brandon Shipley Date: Tue, 15 Sep 2026 22:03:00 -0700 Subject: [PATCH] dont add in unit tests - so controllers which use the component can be tested easier --- src/Controller/Component/ContactUsComponent.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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);