diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index b0b6838..5d4c26b 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -13,12 +13,12 @@ * Implements hook_help(). */ function contact_help($route_name, RouteMatchInterface $route_match) { - $menu_page = \Drupal::moduleHandler()->moduleExists('menu_ui') ? \Drupal::url('entity.menu.collection') : '#'; - $block_page = \Drupal::moduleHandler()->moduleExists('block') ? \Drupal::url('block.admin_display') : '#'; - $contact_page = \Drupal::url('entity.contact_form.collection'); switch ($route_name) { case 'help.page.contact': + $menu_page = \Drupal::moduleHandler()->moduleExists('menu_ui') ? \Drupal::url('entity.menu.collection') : '#'; + $block_page = \Drupal::moduleHandler()->moduleExists('block') ? \Drupal::url('block.admin_display') : '#'; + $contact_page = \Drupal::url('entity.contact_form.collection'); $output = ''; $output .= '

' . t('About') . '

'; $output .= '

' . t('The Contact module allows visitors to contact registered users on your site, using the personal contact form, and also allows you to set up site-wide contact forms. For more information, see the online documentation for the Contact module.', array('!contact' => 'https://www.drupal.org/documentation/modules/contact')) . '

'; @@ -36,6 +36,8 @@ function contact_help($route_name, RouteMatchInterface $route_match) { return $output; case 'entity.contact_form.collection': + $menu_page = \Drupal::moduleHandler()->moduleExists('menu_ui') ? \Drupal::url('entity.menu.collection') : '#'; + $block_page = \Drupal::moduleHandler()->moduleExists('block') ? \Drupal::url('block.admin_display') : '#'; $output = ''; $output .= '

' . t('The Personal contact form is the form for site visitors to contact registered users; the name and recipients of this form cannot be edited. Other forms listed here are your configured site-wide contact forms, which site visitors can use to send mail to a centralized email address or addresses. You can edit the name and recipients of site-wide forms by choosing the Edit operation. You can also configure the fields and display of both personal and site-wide forms.') . '

'; $output .= '

' . t('If you have configured a default site-wide contact form, a Contact menu link in the Footer menu will link to it. You can modify this link from the Menus page if you have the Menu UI module installed. You can also create links to other contact forms; the URL has format contact/machine_name_of_form.', array('!menu-settings' => $menu_page)) . '

'; diff --git a/core/modules/help/src/Tests/HelpEmptyPageTest.php b/core/modules/help/src/Tests/HelpEmptyPageTest.php new file mode 100644 index 0000000..6a4404e --- /dev/null +++ b/core/modules/help/src/Tests/HelpEmptyPageTest.php @@ -0,0 +1,65 @@ +installSchema('system', 'router'); + } + + /** + * {@inheritdoc} + */ + public function containerBuild(ContainerBuilder $container) { + parent::containerBuild($container); + + $container->set('url_generator', new SupernovaGenerator()); + } + + /** + * Ensures that no URL generator is called on a page without hook_help(). + */ + public function testEmptyHookHelp() { + $all_modules = system_rebuild_module_data(); + $all_modules = array_filter($all_modules, function ($module) { + // Filter contrib, hidden, already enabled modules and modules in the + // Testing package. + if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing') { + return FALSE; + } + return TRUE; + }); + + \Drupal::service('module_installer')->install(array_keys($all_modules)); + + $route = \Drupal::service('router.route_provider')->getRouteByName(''); + \Drupal::service('module_handler')->invokeAll('help', ['', new RouteMatch('', $route)]); + } + +} diff --git a/core/modules/help/tests/modules/help_test/help_test.info.yml b/core/modules/help/tests/modules/help_test/help_test.info.yml new file mode 100644 index 0000000..897ea6e --- /dev/null +++ b/core/modules/help/tests/modules/help_test/help_test.info.yml @@ -0,0 +1,5 @@ +name: help_test +type: module +core: 8.x +dependencies: + - help diff --git a/core/modules/help/tests/modules/help_test/src/SuperNovaGenerator.php b/core/modules/help/tests/modules/help_test/src/SuperNovaGenerator.php new file mode 100644 index 0000000..9b33f94 --- /dev/null +++ b/core/modules/help/tests/modules/help_test/src/SuperNovaGenerator.php @@ -0,0 +1,74 @@ +grantPermission($permission); + if ($role = Role::load($rid)) { + foreach ($permissions as $permission) { + $role->grantPermission($permission); + } + $role->save(); } - $role->save(); } /** diff --git a/core/modules/views/src/Plugin/views/display/Page.php b/core/modules/views/src/Plugin/views/display/Page.php index 27905b8..751b2fe 100644 --- a/core/modules/views/src/Plugin/views/display/Page.php +++ b/core/modules/views/src/Plugin/views/display/Page.php @@ -479,8 +479,7 @@ public function calculateDependencies() { $dependencies = parent::calculateDependencies(); $menu = $this->getOption('menu'); - if ($menu['type'] === 'normal') { - $menu_entity = $this->menuStorage->load($menu['menu_name']); + if ($menu['type'] === 'normal' && ($menu_entity = $this->menuStorage->load($menu['menu_name']))) { $dependencies[$menu_entity->getConfigDependencyKey()][] = $menu_entity->getConfigDependencyName(); }