Warning: Undefined array key [n] in Drupal\diff\Controller\PluginRevisionController->buildRevisionsNavigation() (line 266 of /code/web/modules/contrib/diff/src/Controller/PluginRevisionController.php)

Created on 15 August 2025, 1 day ago

Problem/Motivation

Observed error:

Type 	php
Date 	Tuesday, July 29, 2025 - 16:09
Location 	.../node/29468/revisions/view/82907/82906/split_fields
Referrer 	.../node/29468/edit?destination=/admin/dashboard/content
Message 	Warning: Undefined array key 231634 in Drupal\diff\Controller\PluginRevisionController->buildRevisionsNavigation() (line 266 of /code/web/modules/contrib/diff/src/Controller/PluginRevisionController.php)

#0 /code/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real(2, 'Undefined array...', '/code/web/modul...', 266)
#1 /code/web/modules/contrib/diff/src/Controller/PluginRevisionController.php(266): _drupal_error_handler(2, 'Undefined array...', '/code/web/modul...', 266)
#2 /code/web/modules/contrib/diff/src/Controller/PluginRevisionController.php(167): Drupal\diff\Controller\PluginRevisionController->buildRevisionsNavigation(Object(Drupal\node\Entity\Node), Array, '82907', '82906', 'split_fields')
#3 /code/web/modules/contrib/diff/src/Controller/NodeRevisionController.php(58): Drupal\diff\Controller\PluginRevisionController->compareEntityRevisions(Object(Drupal\Core\Routing\CurrentRouteMatch), Object(Drupal\node\Entity\Node), Object(Drupal\node\Entity\Node), 'split_fields')
#4 [internal function]: Drupal\diff\Controller\NodeRevisionController->compareNodeRevisions(Object(Drupal\node\Entity\Node), Object(Drupal\node\Entity\Node), Object(Drupal\node\Entity\Node), 'split_fields')
#5 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#6 /code/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#7 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#8 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#9 /code/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#10 /code/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#11 /code/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#12 /code/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /code/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /code/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /code/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /code/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /code/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /code/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /code/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /code/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#21 {main}

Code in question

264      $i = 0;
265      // Find the previous revision.
266      while ($left_revision_id > $revision_ids[$i]) {
267        $i += 1;
268      }

Evaluation

The $i starts at 0 and increments. When it reaches value that doesn't correlate with a key in $revision_ids[], it isn't breaking the while loop. This results in incremental errors that fill watchdog successively. Mine got up to 272039 before finally stopping, but not before it filled my Watchdog and rolled over.

Steps to reproduce

The user was on .../node/29468/revisions/view/82907/82906/split_fields but I cannot identify how this happened because the logs have rolled over.

Proposed resolution

Is it possible that testing first will help? E.g,

while ($i < count($revision_ids) && $left_revision_id > $revision_ids[$i]) {
--or--
while (array_key_exists($i, $revision_ids) && $left_revision_id > $revision_ids[$i])

πŸ› Bug report
Status

Active

Version

1.8

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States karenann

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024