- Issue created by @ducviethaboo
I updated salesforce module to version 5.1.2 and got the following issue.
Add a shortcut link whose link is the salesforce template link (/{entity}/{entity_id}/salesforce).
When accessing the home page, the entire website shortcuts are rendered and the access function is called for each URL, the shortcut with salesforce template link will be checked for access through the function MappedObjectController::access(). Here is checking the current router to authenticate access for the entity attached to the router, however my home page does not contain the entity type in the param, and this variable is returning null, so the forearch loop will throw a warning.
Warning: Drupal\salesforce_mapping_ui\Controller\MappedObjectController->access() foreach() argument must be of type array|object, null given (/app/web/modules/contrib/salesforce/modules/salesforce_mapping_ui/src/Controller/MappedObjectController.php の 49 )
MappedObjectController::access() line 48:
$param = null;
$parameter_info = $this->route->getRouteObject()->getOption('parameters');
foreach ($parameter_info as $name => $options) {
if (isset($options['type']) && str_starts_with($options['type'], 'entity:')) {
$param = $this->route->getParameter($name);
continue 1;
}
}
Where the access function is called, file shortcut.module function shortcut_renderable_links() (line 215)
foreach ($shortcut_set->getShortcuts() as $shortcut) {
$shortcut = \Drupal::service('entity.repository')->getTranslationFromContext($shortcut);
$url = $shortcut->getUrl();
if ($url->access()) {
$links[$shortcut->id()] = [
'type' => 'link',
'title' => $shortcut->label(),
'url' => $shortcut->getUrl(),
];
$cache_tags = Cache::mergeTags($cache_tags, $shortcut->getCacheTags());
}
}
Step 1: Add shortcut for path with salesforce template
Step 2: Access any path that displays shortcut links
Will need to change the way to get the router or check the value of the variable before entering the loop.
Active
5.1
salesforce_mapping_ui.module