From 0ea3971ac151fdfc73c127fa75c872d198d80264 Mon Sep 17 00:00:00 2001 From: Brandon Shipley Date: Tue, 15 Sep 2026 19:18:15 -0700 Subject: [PATCH 1/2] remove logging in component on getErrors() --- src/Controller/Component/ContactUsComponent.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/Controller/Component/ContactUsComponent.php b/src/Controller/Component/ContactUsComponent.php index 0470a53..bba2c6a 100644 --- a/src/Controller/Component/ContactUsComponent.php +++ b/src/Controller/Component/ContactUsComponent.php @@ -8,7 +8,6 @@ use Cake\Core\Configure; use Cake\Datasource\EntityInterface; use Cake\Http\Response; use Cake\I18n\DateTime; -use Cake\Log\Log; use Cake\ORM\Table; use Cake\ORM\TableRegistry; use CakeContactUs\CakeContactUsPlugin; @@ -55,7 +54,6 @@ class ContactUsComponent extends Component { $this->setConfig('requireEmail', Configure::readOrFail('ContactUs.fields.email')); $this->setConfig('requireCaptcha', $requireCaptcha); if ($requireCaptcha) { -// $this->_registry->load('Captcha.Captcha'); $this->getController()->viewBuilder()->addHelpers(['Captcha.Captcha']); } } @@ -96,10 +94,6 @@ class ContactUsComponent extends Component { if ($result instanceof EntityInterface) { $postData = $result->toArray(); $contactUsFormSubmission = $this->ContactUsFormSubmissions->patchEntity($contactUsFormSubmission, $postData); - if ($contactUsFormSubmission->getErrors()) { - Log::debug(print_r('$contactUsFormSubmission->getErrors()', true)); - Log::debug(print_r($contactUsFormSubmission->getErrors(), true)); - } $contactUsFormSubmissionSaved = $this->ContactUsFormSubmissions->save($contactUsFormSubmission); if ($contactUsFormSubmissionSaved) { return $this->_afterFormSaved($contactUsFormSubmissionSaved); @@ -115,11 +109,6 @@ class ContactUsComponent extends Component { } $contactUsFormSubmission = $this->ContactUsFormSubmissions->patchEntity($contactUsFormSubmission, $postData); - if ($contactUsFormSubmission->getErrors()) { - Log::debug(print_r('$contactUsFormSubmission->getErrors()', true)); - Log::debug(print_r($contactUsFormSubmission->getErrors(), true)); - } - $contactUsFormSubmissionSaved = $this->ContactUsFormSubmissions->save($contactUsFormSubmission); if ($contactUsFormSubmissionSaved) { From 49772771d036efe5dd9be60ad4f1d13dd7234b8f Mon Sep 17 00:00:00 2001 From: Brandon Shipley Date: Tue, 15 Sep 2026 22:03:00 -0700 Subject: [PATCH 2/2] 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);