diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 5f0f18c2ad293aa59f6f9b0871516ce0676610ed..007492e4cfbece64155ef4e7445d141778410daf 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -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(); diff --git a/core/modules/contact/tests/src/Unit/ContactTest.php b/core/modules/contact/tests/src/Unit/ContactTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b1abf037238fa3879d9b2748d6f9e65fa7c010be --- /dev/null +++ b/core/modules/contact/tests/src/Unit/ContactTest.php @@ -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'); + } + +}