Mapping a contact gives invalid argument supplied.
Overview
Please describe your problem or bug in detail.
If you have already posted on https://civicrm.stackexchange.com or https://chat.civicrm.org, please include the link to that conversation.
Reproduction steps
- Click on Contact -> View.
- Click on Map by the postal address
- You get
Warning: Invalid argument supplied for foreach() in CRM_Utils_System_Drupal8->appendBreadCrumb() (line 193 of <Drupal root>/vendor/civicrm/civicrm-core/CRM/Utils/System/Drupal8.php)
Current behaviour
Before seeing the map you get
Warning: Invalid argument supplied for foreach() in CRM_Utils_System_Drupal8->appendBreadCrumb() (line 193 of /vendor/civicrm/civicrm-core/CRM/Utils/System/Drupal8.php)```
Expected behaviour
You should just see the map.
Environment information
- Browser: Edge, but irrelevant
- CiviCRM: 5.33.1
- PHP: 7.4/ but probably irrrelevant
- CMS: Drupal 9.1.2 but the issue may occur elsewhere.
- Database: MySQL 8.0 but probably irrelevant.
- Web Server: IIS 10 but probably irrelevant.
Comments
Anything else you would like the reviewer to note.
Line 170 of <CiviCRM core>/CRM/Contact/Form/Task/Map.php
reads
CRM_Utils_System::appendBreadCrumb($bcTitle, $redirect);
However, the function in <CiviCRM core>/CRM/Utils/System/Drupal8.php
say reads:
public function appendBreadCrumb($breadcrumbs) {
In other words, it is expecting a single parameter, no two, and that is an array.
The error can be cured by replacing the offending line with:
// CRM_Utils_System::appendBreadCrumb only takes one argument, an array
// of breadcrumbs, not two.
$breadcrumbs[0]['title'] = $bcTitle;
$breadcrumbs[0]['url'] = $redirect;
CRM_Utils_System::appendBreadCrumb($breadcrumbs);
In other words passing a breadcrumb array. Whilst I have only mentioned Drupal8.php, the other files have the same call interface, I believe.
The issue can be reproduced under https://d9-master.demo.civicrm.org/civicrm/contact/map?reset=1&cid=186&lid=1 which is running 5.35.1 alpha if you enable Google mapping.
Warning: Invalid argument supplied for foreach() in CRM_Utils_System_Drupal8->appendBreadCrumb() (line 193 of /srv/buildkit/build/d9-master/vendor/civicrm/civicrm-core/CRM/Utils/System/Drupal8.php).
CRM_Utils_System_Drupal8->appendBreadCrumb('Contact', '/civicrm/contact/view?reset=1&cid=186') (Line: 60)
CRM_Utils_System::__callStatic('appendBreadCrumb', Array) (Line: 171)
CRM_Contact_Form_Task_Map::createMapXML(Array, 1, Object, 1, 'Contact') (Line: 92)
CRM_Contact_Form_Task_Map->preProcess() (Line: 608)
...