Problem/Motivation
After clicking Replace and then Cancel on the confirmation page, the search form shows the matches under the heading "Content that was changed". Nothing was changed, but the heading tells the user that the replacement happened.
Steps to reproduce
1. Go to Content » Search and replace (/admin/content/scanner).
2. Enter text to search for and a replacement, and click Replace.
3. On the confirmation page, click Cancel.
4. The matches are listed under "Content that was changed", but no content was changed.
Proposed resolution
Only record the Replace operation once a replacement has actually run:
- In ScannerForm::submitForm(), don't store op when the Replace button is pressed. The results of the search that runs before the confirmation page then show as "Search results" if the user cancels.
- In ScannerConfirmForm::batchFinished(), store op as "Replace" when the replacement succeeds, so the results are still shown as "Content that was changed" afterwards.
- Remove the scanner_op line from ScannerConfirmForm::getCancelUrl(), so that building the form has no side effects.
Remaining tasks
- Merge request with the fix.
- Test coverage: after cancelling, the results are shown as "Search results"; after confirming, they are shown as "Content that was changed".
- Review.
User interface changes
After cancelling a replacement, the matches are shown under "Search results" instead of "Content that was changed".
API changes
None.
Data model changes
None.
Issue fork scanner-3625923
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 #3
john.oltman commentedMR passes the new test. I did run the test-only changes job and it failed, as expected.
Sorry this didn't make it in time for the new release but it isn't critical so next release is fine.
Comment #4
john.oltman commentedComment #5
smustgrave commented