diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 4c14535..751b115 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -14,6 +14,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\taxonomy\Entity\Vocabulary; +use Symfony\Component\Routing\Exception\RouteNotFoundException; /** * Implements hook_help(). @@ -740,7 +741,6 @@ function forum_system_info_alter(&$info, Extension $file, $type) { $factory = \Drupal::service('entity.query'); $nodes = $factory->get('node') ->condition('type', 'forum') - ->count() ->accessCheck(FALSE) ->range(0, 1) ->execute(); @@ -751,30 +751,38 @@ function forum_system_info_alter(&$info, Extension $file, $type) { $vid = \Drupal::config('forum.settings')->get('vocabulary'); $terms = $factory->get('taxonomy_term') ->condition('vid', $vid) - ->count() ->accessCheck(FALSE) ->range(0, 1) ->execute(); if (!empty($terms)) { $vocabulary = Vocabulary::load($vid); $info['required'] = TRUE; - if (!empty($info['explanation'])) { - if ($vocabulary->access('view')) { - $info['explanation'] = t('To uninstall Forum first delete all Forum content and %vocabulary terms.', [ - '%vocabulary' => $vocabulary->label(), - '!url' => $vocabulary->url('overview-form'), - ]); + try { + if (!empty($info['explanation'])) { + if ($vocabulary->access('view')) { + $info['explanation'] = t('To uninstall Forum first delete all Forum content and %vocabulary terms.', [ + '%vocabulary' => $vocabulary->label(), + '!url' => $vocabulary->url('overview-form'), + ]); + } + else { + $info['explanation'] = t('To uninstall Forum first delete all Forum content and %vocabulary terms.', [ + '%vocabulary' => $vocabulary->label() + ]); + } } else { - $info['explanation'] = t('To uninstall Forum first delete all Forum content and %vocabulary terms.', [ - '%vocabulary' => $vocabulary->label() + $info['explanation'] = t('To uninstall Forum first delete all %vocabulary terms.', [ + '%vocabulary' => $vocabulary->label(), + '!url' => $vocabulary->url('overview-form'), ]); } } - else { - $info['explanation'] = t('To uninstall Forum first delete all %vocabulary terms.', [ - '%vocabulary' => $vocabulary->label(), - '!url' => $vocabulary->url('overview-form'), + catch (RouteNotFoundException $e) { + // Route rebuilding might not have occurred before this hook is fired. + // Just use an explanation without a link for the time being. + $info['explanation'] = t('To uninstall Forum first delete all Forum content and %vocabulary terms.', [ + '%vocabulary' => $vocabulary->label() ]); } }