Problem/Motivation
`PluginRevisionController::buildRevisionsNavigation()` accesses `$revision_ids[$i - 1]` on line 249 without checking that `$i > 0`. When `$i` stays at `0` (because the right revision ID is absent from the language-filtered revision list — a valid scenario for translatable nodes with `und`-language revisions), the access resolves to `$revision_ids[-1]`, which is undefined:
```
Warning: Undefined array key -1 in Drupal\diff\Controller\PluginRevisionController->buildRevisionsNavigation() (line 249 of modules/contrib/diff/src/Controller/PluginRevisionController.php).
```
The equivalent "previous change" block is correctly guarded by `if ($i !== 0)` on line 233; the "next change" block on line 249 is not.
Steps to reproduce
1. Have a translatable node with `und`-language revisions
2. Visit the split_fields diff page (e.g. `/en/node/{nid}/revisions/view/{left_vid}/{right_vid}/split_fields`)
3. Observe the PHP warning in the logs
Proposed resolution
Replace the access to `$revision_ids[$i - 1]` with a direct comparison against `$right_revision_id`, which is always available and semantically equivalent. When `$i > 0`, `$revision_ids[$i - 1]` equals `$right_revision_id` (the while loop guarantees this). When `$i === 0`, the original code crashes; the fix correctly uses the always-available variable.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | diff-undefined-array-key-3630570-2.patch | 779 bytes | adhariwal |
Issue fork diff-3630570
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
adhariwal commentedComment #3
acbramley commentedCan you please update the IS with the default template (it looks like markdown was used) and post the changes as an MR. Patches are not accepted.
Comment #4
acbramley commentedComment #6
acbramley commentedI couldn't reproduce this with language filtering but was able to derive a test with the query alter that hits the same warning. Are you able to provide steps to reproduce using different languages?