Scanner finds older paragraphs from node revisions

Created on 18 May 2024, about 1 month ago

Problem/Motivation

Noticing a behaviour that leads to confusion for end users of this module.

The module, when configured for paragraphs, will locate old paragraphs that exist in older revisions of content. This leads to replacements that actually don't exist on the original node anymore.

Steps to reproduce

1. Drupal 10.2.6
2. Latest version of Scanner
3. Latest version of paragraphs
4. Create a new paragraph, single text field
5. Configure scanner to use this paragraph and the single text field
6. Add a new content type
7. Add an ERR field that can reference the new paragraph
8 Add a new node, populate the new paragraph text field
9. Save
10. Create a new revision of this node
11. Remove the original paragraph
12. Add a new paragraph
13. Add a string value
14. Save
15. Search for the string that exists in the first paragraph
16. The old paragraph surfaces in search
17. Replace the value

The old paragraph that existed in the first revision is updated with the new string, but the revision isn't used anywhere.

This is confusing, because if I search for the replacement string again it'll surface in search, but the node that exists in the search results has no reference to the found string, in any of its revisions.

Before replace

MariaDB [db]> select * from paragraphs_item_revision;
+----+-------------+----------+------------------+
| id | revision_id | langcode | revision_default |
+----+-------------+----------+------------------+
|  1 |           1 | en       |                1 |
|  2 |           2 | en       |                1 |
+----+-------------+----------+------------------+
2 rows in set (0.001 sec)

After replace

MariaDB [db]> select * from paragraphs_item_revision;
+----+-------------+----------+------------------+
| id | revision_id | langcode | revision_default |
+----+-------------+----------+------------------+
|  1 |           1 | en       |                1 |
|  2 |           2 | en       |                1 |
|  1 |           3 | en       |                1 | <--- new revision created by scanner
+----+-------------+----------+------------------+
3 rows in set (0.002 sec)

The node (before and after) - note no reference to the new paragraph revision

MariaDB [db]> select * from node_revision__field_components;
+-----------+---------+-----------+-------------+----------+-------+----------------------------+-------------------------------------+
| bundle    | deleted | entity_id | revision_id | langcode | delta | field_components_target_id | field_components_target_revision_id |
+-----------+---------+-----------+-------------+----------+-------+----------------------------+-------------------------------------+
| paragraph |       0 |         3 |           7 | en       |     0 |                          1 |                                   1 |
| paragraph |       0 |         3 |           8 | en       |     0 |                          2 |                                   2 |
+-----------+---------+-----------+-------------+----------+-------+----------------------------+-------------------------------------+

Proposed resolution

We could add an option to only search for 'live' paragraphs, but is there an argument this behaviour should ever locate old paragraphs on old revisions given the functionality of the module only creates a new paragraph revision and doesn't update the 'parent' (node) in any way.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom aaron.ferris

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

Comments & Activities

Production build 0.69.0 2024