From ab3287298830b559f38cf8e9b3a3ec75f79c92dd Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 18 Oct 2022 16:52:27 -0600 Subject: [PATCH] Infolog: Avoid JS error 'Uncaught TypeError: Cannot read properties of undefined (reading 'getWidgetById')' caused by sending invalid pl_id Fixed by not sending invalid pl_id which triggered fix_bad_value() --- infolog/inc/class.infolog_so.inc.php | 5 +++++ infolog/inc/class.infolog_ui.inc.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/infolog/inc/class.infolog_so.inc.php b/infolog/inc/class.infolog_so.inc.php index b242305170..0ba3c37515 100644 --- a/infolog/inc/class.infolog_so.inc.php +++ b/infolog/inc/class.infolog_so.inc.php @@ -578,6 +578,11 @@ class infolog_so $to_write[$key] = $this->data[$key] = $val; // update internal data } } + // If no price list use NULL not 0 + if($to_write['pl_id'] == '') + { + $to_write['pl_id'] = NULL; + } // writing no price as SQL NULL (required by postgres) if ($to_write['info_price'] === '') $to_write['info_price'] = NULL; diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index a8cc627a9b..0f0c9e1380 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -2222,6 +2222,11 @@ class infolog_ui { unset($content['info_cat']); } + // Don't send '0' if there is no price list + if($content['pl_id'] == '0') + { + unset($content['pl_id']); + } $content['duration_format'] = $this->duration_format; $content['hours_per_workday'] = $this->hours_per_workday; if ($this->prefs['show_id']) $content['info_number'] = $info_id;