Page MenuHomePhabricator

Search and Replace does not work when editing filters
Closed, ResolvedPublic

Description

  1. Open a filter (e.g. https://pt.wikipedia.org/wiki/Special:AbuseFilter/138)
  2. Press CTRL+F to open the search tool
  3. Fill in the find field with anything that is present in the filter e.g. "a"
  4. Fill in the replace field with e.g. "b"
  5. Replace all ocurrences
  6. Save the filter

Expected result
The changes are saved

Actual result
The changes are not saved, even though we can see the code was changed. If I open the JS console in Firefox, I see that $('#wpFilterRules').val() returns the old code instead of the updated version so the code which is highlighted is out of sync with the code in the textarea. I believe the extension should be using the module "jquery.textSelection" for interacting with the textarea.

Event Timeline

He7d3r created this task.Sep 3 2018, 12:34 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 3 2018, 12:34 PM
Daimona added a subscriber: Daimona.Sep 3 2018, 1:55 PM

This wouldn't be solved by jquery.textSelection. Instead, the problem is that we sync the Ace editor and the invisible input field (which is then submitted) using a keyup event on the Ace div. However, when using search&replace the keyup event isn't fired, and thus the content is not synced. I'll look into it, but can't say if this will be easy enough to solve.

Change 457457 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/AbuseFilter@master] Change events used with the Ace editor

https://gerrit.wikimedia.org/r/457457

Daimona claimed this task.Sep 3 2018, 2:07 PM

Aye, it was easy :-) BTW, many thanks for reporting! That's a great bug report and I also love to see that these minor AbuseFilter features are used, making it easier to write better software.

Change 457457 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@master] Change events used with the Ace editor

https://gerrit.wikimedia.org/r/457457

Daimona closed this task as Resolved.Sep 5 2018, 5:41 PM