From a00919940fca4d32b711cbb47c31df4a99814832 Mon Sep 17 00:00:00 2001 From: Rich Lott / Artful Robot Date: Thu, 27 Jul 2023 16:26:33 +0100 Subject: [PATCH] standalone: prevent civi adding duplicate breadcrumbs (e.g. scheduled jobs) --- CRM/Utils/System/Standalone.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/CRM/Utils/System/Standalone.php b/CRM/Utils/System/Standalone.php index febf546bc7..584e9d7bc7 100644 --- a/CRM/Utils/System/Standalone.php +++ b/CRM/Utils/System/Standalone.php @@ -109,9 +109,21 @@ class CRM_Utils_System_Standalone extends CRM_Utils_System_Base { */ public function appendBreadCrumb($breadcrumbs) { $crumbs = \Civi::$statics[__CLASS__]['breadcrumb'] ?? []; - $crumbs = array_merge($crumbs, $breadcrumbs); + + foreach ($breadcrumbs as $crumb) { + $duplicate = FALSE; + foreach ($crumbs as $existingCrumb) { + if ($existingCrumb['url'] === $crumb['url']) { + $duplicate = TRUE; + break; + } + } + if (!$duplicate) { + $crumbs[] = $crumb; + } + } \Civi::$statics[__CLASS__]['breadcrumb'] = $crumbs; - CRM_Core_Smarty::singleton()->assign('breadcrumb', \Civi::$statics[__CLASS__]['breadcrumb']); + CRM_Core_Smarty::singleton()->assign('breadcrumb', $crumbs); } /** -- 2.25.1