Problem/Motivation
From what I can tell, and I could be wrong, the condition for the string field type has a condition thats checked too early to allow multiple string fields on the same node to have their field content replaced in one run
Steps to reproduce
1. Fresh D10.2.4
2. Latest version of Scanner
3. Enable the Scanner module
4. Add 2/3 plain text, short fields to the basic page content type
5. Configure Scanner to use the new fields, all other settings leave as standard
6. Add a new basic page
7. Add the same text for all 3 of the fields added in step 4
8. Run a Scanner search for the string in step 7
9. Replace with something else
Expected: All 3 fields will be updated with the new string
Actual: Only the first field is updated
Proposed resolution
Move the condition that checks for a new vid to a similar position where it fires for text_long (etc)
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork scanner-3441892
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
aaron.ferris commentedComment #4
aaron.ferris commentedComment #5
aaron.ferris commentedComment #6
damienmckennaThank you for opening the bug report and providing the merge request, I'll try to review it soon.
As a reminder, please update the "Assigned" field to "Unassigned" when you're finished, that way others know you're finished and they can take over.
Comment #7
anybodyComment #8
smustgrave commentedNeeds a reroll for 2.0.x
Comment #9
smustgrave commentedIs eligible to be backported to 8.x-1.x so can do a 2nd MR.
Comment #11
aaron.ferris commentedAdded a reroll of this for 2.0.x that seems to resolve this for me.
Comment #12
aaron.ferris commentedComment #13
smustgrave commentedCan we add some test coverage?
Also does this need to be expanded to Paragraphs too?
Comment #14
damienmckennaTest coverage is definitely needed.
I think we should stick with nodes for this issue, and open a separate one if the change is also needed for paragraphs.
Comment #15
damienmckennaLet's include this in 2.0.0.
Comment #16
damienmckennaThis should have been fixed in #3462717: Node logic only processes first value, looses other values in multi-value text fields, can you please test it with your scenario and let me know if the problem persists? Thank you.
Comment #17
grask0 commentedHello,
I tested the latest DEV version of the module and got the following results.
I have a node with a title field and a field_code field (plain text). Both fields contain the exact same text.
When I search for the text, it only finds one match, which is in the field_code field.
When I try to replace the text, only the field_code field gets updated. The title field remains unchanged.
Comment #18
damienmckennaLet's expand (and correct?) the test coverage, then see what needs fixing.
Comment #20
grask0 commentedComment #21
o_timoshchuk commentedComment #22
o_timoshchuk commentedThe merge request #89 fixed the problem.
I added three plain text fields to the Basic Page content type and created two nodes where the fields have identical values.
All field values were successfully searched, and their values were replaced as expected.
Comment #23
damienmckennaThank you @grask0 for working through that and fixing the bugs!
A small request: Please expand the test coverage to cover multiple values on the same field, and multiple entities with the same value in the same field name.
Comment #24
grask0 commentedComment #25
smustgrave commentedSorry multiple MRs can those that aren't for review be closed please
Comment #27
grask0 commentedHello @smustgrave,
#27 MR is related to the 8.x-1.x branch
#89 MR is related to the 2.0.x branch.
According to your comment https://www.drupal.org/project/scanner/issues/3441892#comment-15912794, 2 merge requests were prepared for both versions.
I'm not sure about #27 because I worked on #89 (which can be merged).
Thanks.
Comment #29
smustgrave commentedFair, that was 2 years ago so think we don't have to worry about the 8.x-1.x branch anymore. Hopefully once we make 2.0.0 we can drop support.
Comment #30
smustgrave commentedFinally reviewed, the tests need to be updated to not use $this->entityStorage as that has been dropped due to new phpstan rules that discourage storing the storage object.
Comment #32
smustgrave commentedFixed up.