Issue #2479449 by sudiptadas19, smustgrave, akashkumar07, rithesh bk, rpayanm, pradhumanjain2311, tstoeckler, mrinalini9, tatisilva, larowlan, andypost, dawehner, xjm, yesct: contact_menu_local_tasks_alter() should check whether ['tabs'][0] is set

merge-requests/6248/head
quietone 2024-10-24 14:14:01 +13:00
parent 2319f33906
commit 833e599d18
No known key found for this signature in database
GPG Key ID: 43BFBBB26EA09FE1
2 changed files with 25 additions and 1 deletions

View File

@ -98,7 +98,7 @@ function contact_entity_extra_field_info() {
* email address configured.
*/
function contact_menu_local_tasks_alter(&$data, $route_name) {
if ($route_name == 'entity.user.canonical') {
if ($route_name == 'entity.user.canonical' && isset($data['tabs'][0])) {
foreach ($data['tabs'][0] as $href => $tab_data) {
if ($href == 'entity.user.contact_form') {
$link_params = $tab_data['#link']['url']->getRouteParameters();

View File

@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace Drupal\Tests\contact\Unit;
use Drupal\Tests\UnitTestCase;
/**
* @group contact
*/
class ContactTest extends UnitTestCase {
/**
* Test contact_menu_local_tasks_alter doesn't throw warnings.
*/
public function testLocalTasksAlter(): void {
require_once $this->root . '/core/modules/contact/contact.module';
$data = [];
\contact_menu_local_tasks_alter($data, 'entity.user.canonical');
$this->assertTrue(TRUE, 'No warning thrown');
}
}