When visiting the page of a node revision (e.g. node/13/revisions/15/view) I am getting the error "The website encountered an unexpected error. Please try again later". Looking at dblog i can see the following error:

Error: Call to a member function id() on string in bootstrap_mint_preprocess_html() (line 15 of C:\UniServerZ\www\efka\themes\bootstrap_mint\bootstrap_mint.theme)

When using another theme (e.g. Bartik) there is no problem.

It seems that when visiting the revision page, the $node variable is a string and has the value of node id. I suppose that the problem has to do with the following value assignment in line 14 of bootstrap_mint.theme:

if ($node = \Drupal::request()->attributes->get('node')) {

Comments

plessas created an issue. See original summary.

Binu Varghese’s picture

@plessas,

Replace below code (line -14 in bootstrap_mint.theme file):

if ($node = \Drupal::request()->attributes->get('node')) {
$variables['attributes']['class'][] = 'page-node-' . $node->id();
}

with:

if (\Drupal::routeMatch()->getRouteName() == 'entity.node.canonical') {
$node = \Drupal::routeMatch()->getParameter('node');
$variables['attributes']['class'][] = 'page-nid-' . $node->id();
}

Shall incorporate in the next release.

Binu Varghese’s picture

Status: Active » Fixed
Binu Varghese’s picture

Status: Fixed » Closed (fixed)
plessas’s picture

Thank you for the reply. However, I am still getting the blank page with the error and I can see the following in the logs:

Error: Call to a member function getTitle() on string in bootstrap_mint_preprocess_breadcrumb() (line 190 of bootstrap_mint.theme)

Binu Varghese’s picture

so.. apply the same logic there as well..

plessas’s picture

You are right.

function bootstrap_mint_preprocess_breadcrumb(&$variables) {
  if ((\Drupal::routeMatch()->getRouteName() == 'entity.node.canonical') && $variables['breadcrumb']) {
    $node = \Drupal::routeMatch()->getParameter('node');
    $variables['breadcrumb'][] = array(
      'text' => $node->getTitle(),
    );
    // Cache context based on url.
    $variables['#cache']['contexts'][] = 'url';
  }
}

It's OK now.

drupalfan2’s picture

Thank you, this line
if (\Drupal::routeMatch()->getRouteName() == 'entity.node.canonical') {
helped me to solve my problem, too.

gourav.yadav’s picture

Thanks !

themaurice’s picture

Thanks

if (\Drupal::routeMatch()->getRouteName() == 'entity.node.canonical') {

work for me too.