From c19a53a0537f65057f45d340b251e02e1cfe86a3 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Fri, 15 Sep 2023 07:53:53 +0100
Subject: [PATCH] Issue #315302 by mstrelan, tacituseu, PaulMagrath, coltrane,
 yched, DamienMcKenna, quietone: Node Access Rebuild never finishes (infinite
 loop)

---
 core/modules/node/node.module | 5 +++--
 core/phpstan-baseline.neon    | 5 -----
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index f47dbb754094..0e2fa13b4fb8 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -1185,10 +1185,11 @@ function _node_access_rebuild_batch_operation(&$context) {
     ->execute();
   $node_storage->resetCache($nids);
   $nodes = Node::loadMultiple($nids);
-  foreach ($nodes as $nid => $node) {
+  foreach ($nids as $nid) {
     // To preserve database integrity, only write grants if the node
     // loads successfully.
-    if (!empty($node)) {
+    if (!empty($nodes[$nid])) {
+      $node = $nodes[$nid];
       /** @var \Drupal\node\NodeAccessControlHandlerInterface $access_control_handler */
       $access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler('node');
       $grants = $access_control_handler->acquireGrants($node);
diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index 52d14bd6a5e1..5c016348642c 100644
--- a/core/phpstan-baseline.neon
+++ b/core/phpstan-baseline.neon
@@ -1842,11 +1842,6 @@ parameters:
 			count: 1
 			path: modules/node/node.module
 
-		-
-			message: "#^Variable \\$node in empty\\(\\) always exists and is not falsy\\.$#"
-			count: 1
-			path: modules/node/node.module
-
 		-
 			message: "#^Method Drupal\\\\node\\\\ConfigTranslation\\\\NodeTypeMapper\\:\\:setEntity\\(\\) should return bool but return statement is missing\\.$#"
 			count: 1
-- 
GitLab