From 2b702070e3f88f7d580278f117c484281ab8b214 Mon Sep 17 00:00:00 2001 From: gchi25 Date: Fri, 8 Nov 2024 14:17:50 -0500 Subject: [PATCH 1/2] PXBF-1770-ajax-http-error: fix ajax http error --- .../src/Controller/LifeEventController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php b/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php index 637c03c84..6651db665 100644 --- a/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php +++ b/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php @@ -226,9 +226,11 @@ public function getData($id) { if (empty($life_event_form_node)) { $result = []; $json = json_encode($result, JSON_PRETTY_PRINT); - print_r("

JSON Data

");
-      print_r($json);
-      print_r("
"); + if ($this->displayData) { + print_r("

JSON Data

");
+        print_r($json);
+        print_r("
"); + } return $result; } From 89936e25c7d261a99a701542cc862c0ba036cdbf Mon Sep 17 00:00:00 2001 From: gchi25 Date: Fri, 8 Nov 2024 14:42:52 -0500 Subject: [PATCH 2/2] PXBF-1770-ajax-http-error: handle node empty --- usagov_benefit_finder/src/Traits/BenefitFinderTrait.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usagov_benefit_finder/src/Traits/BenefitFinderTrait.php b/usagov_benefit_finder/src/Traits/BenefitFinderTrait.php index c7c66b942..b509b47e2 100644 --- a/usagov_benefit_finder/src/Traits/BenefitFinderTrait.php +++ b/usagov_benefit_finder/src/Traits/BenefitFinderTrait.php @@ -161,6 +161,10 @@ public function getLifeEventForm($nid, $mode) { public function getNode($nid, $mode) { $node = Node::load($nid); + if (!$node) { + return NULL; + } + if ($node->hasField('moderation_state')) { $moderation_state = $node->get('moderation_state')->value; if ($moderation_state == 'archived') {