diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php
index 1c70b00d95b4ca88588737f67577d13bcb717514..27aa6c5fb3c16f90a06e152fbb9682d0124fcb99 100644
--- a/core/modules/node/node.api.php
+++ b/core/modules/node/node.api.php
@@ -383,7 +383,7 @@ function hook_node_grants_alter(&$grants, $account, $op) {
   if ($op != 'view' && !empty($restricted)) {
     // Now check the roles for this account against the restrictions.
     foreach ($restricted as $role_id) {
-      if (isset($user->roles[$role_id])) {
+      if (isset($account->roles[$role_id])) {
         $grants = array();
       }
     }