Opened on 08/12/2018 at 08:13:09 AM

Closed on 10/02/2018 at 05:19:51 PM

Last modified on 02/21/2019 at 10:54:12 AM

#6856 closed change (fixed)

Remove FilterStorage.moveSubscription

Reported by: mjethani Assignee: jsonesen
Priority: P3 Milestone:
Module: Core Keywords:
Cc: greiner, sebastian, kzar, hfiguiere, jsonesen, sergz, Anton, arthur Blocked By:
Blocking: #7000 Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Unknown Verified working: yes
Review URL(s):

https://codereview.adblockplus.org/29886685

Description (last modified by mjethani)

Background

It seems that the FilterStorage.moveSubscription method is not used at all anywhere in the browser extension, but because of it we must maintain a separate FilterStorage.subscriptions array just so the subscriptions can be ordered. If this functionality is not being used from any of the clients of Adblock Plus core, it should be removed. This would allow us to get rid of FilterStorage.subscriptions and just work with FilterStorage.knownSubscriptions (less book-keeping).

What to change

In lib/filterStorage.js:

  • Remove the FilterStorage.subscriptions array and use the values of the FilterStorage.knownSubscriptions ordered map instead
  • Add a new FilterStorage.subscriptions() generator function that yields the values in the FilterStorage.knownSubscriptions ordered map
  • Add a new FilterStorage.subscriptionCount property (getter function) that returns the size of the FilterStorage.knownSubscriptions ordered map

Everywhere else:

  • Replace all usage of the FilterStorage.subscriptions array with the new FilterStorage.subscriptions() function and the new FilterStorage.subscriptionCount property

Finally, remove FilterStorage.moveSubscription from lib/filterStorage.js and all tests; also stop listening for the subscription.moved event in lib/filterListener.js.

Integration notes

After change set 3c14ad288359 the subscriptions property of FilterStorage has been replaced by a generator method (yields Subscription objects of knownSubscriptions) and adds a subscriptionCount property.

In adblockpluschrome there would have to be changes in lib/hitLogger.js, lib/indexedDBBackup.js, and lib/subscriptionInit.js.

In adblockplusui the changes would be in messageResponder.js, and possibly elsewhere.

Note that the subscriptions property still exists, it is just a generator function now, which means code like FilterStorage.subscriptions.length != 0 will still work silently but it will still be a bug.

Hints for testers

This change touches every part of the FilterStorage module, so it should tested thoroughly.

Try this:

  1. Subscribe to a filter list. Expected: Filters from the list should work.
  2. Disable the filter list. Expected: Filters from the list should no longer work.
  3. Re-enable the filter list. Expected: Filters from the list should work again.
  4. Unsubscribe from (delete) the filter list. Expected: Filters from the list should no longer work.
  5. Re-subscribe to the same filter list. Expected: Filters from the list should work again.
  6. Disable the filter list. Expected: Filters from the list should no longer work.
  7. Unsubscribe from (delete) the filter list. Expected: Filters from the list should still no longer work.
  8. Re-subscribe to the same filter list. Expected: Filters from the list should work again, i.e. the list should not be disabled by default (in other words, it should not remember its last enabled/disabled state).

Through all of the steps above, any other filters from any other list subscribed to and enabled should always work.

Look for any errors/exceptions in the background page console.

Attachments (0)

Change History (29)

comment:1 Changed on 08/12/2018 at 08:15:16 AM by mjethani

  • Cc sergz Anton added

comment:2 Changed on 08/12/2018 at 08:16:27 AM by mjethani

@greiner @sebastian @sergz @Anton is it OK to remove this functionality from core?

comment:3 Changed on 09/02/2018 at 05:06:30 PM by jsonesen

  • Owner set to jsonesen

Is this something I can start on?

Last edited on 09/02/2018 at 05:06:58 PM by jsonesen

comment:4 Changed on 09/03/2018 at 10:50:42 AM by mjethani

@jsonesen I think we'll need feedback from @sebastian and @greiner before deciding to remove this function. Some features are planned for the future that may need this functionality.

comment:5 Changed on 09/03/2018 at 11:54:11 AM by greiner

We don't use this functionality in the UI at the moment. While it might come in handy to allow users to manually order filter groups in the future, I'm sure we'd be able to find a different approach to accomplish this. Therefore I'd be fine with removing FilterStorage.moveSubscription().

comment:6 Changed on 09/12/2018 at 08:36:43 AM by mjethani

  • Ready set

comment:7 Changed on 09/12/2018 at 08:43:44 AM by mjethani

It looks like there's no objection to removing this method and the related data structure, in which case we'll go ahead and remove it.

comment:8 Changed on 09/12/2018 at 08:50:15 AM by mjethani

  • Description modified (diff)

comment:9 Changed on 09/12/2018 at 08:52:01 AM by mjethani

  • Description modified (diff)

comment:10 Changed on 09/12/2018 at 10:08:23 PM by sebastian

It seems if we remove FilterStorage.moveSubscription(), we should also stop listening for subscription.moved in lib/filterListener.js (and elsewhere, in case we do).

comment:11 Changed on 09/13/2018 at 12:39:34 PM by mjethani

  • Description modified (diff)

comment:12 Changed on 09/17/2018 at 08:52:26 PM by jsonesen

It seems that the INIParser in lib/iniParser/js also has a list of subscriptions similar to FilterStorage. Should this and all of its uses be removed? or Replaced? I ask since FilterStorage uses it to load stored subscriptions.

Last edited on 09/17/2018 at 08:53:52 PM by jsonesen

comment:13 Changed on 09/18/2018 at 12:46:09 PM by mjethani

Jon, if you're referring to the subscriptions property of the INIParser class, let's leave it as an array. Adding an item to an array is O(1) and we really need it there. The duplicates get filtered out when we populate the local knownSubscriptions object in importData.

Last edited on 09/18/2018 at 12:46:39 PM by mjethani

comment:14 Changed on 09/20/2018 at 07:34:38 PM by jsonesen

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:15 follow-ups: Changed on 10/01/2018 at 11:06:08 AM by mjethani

  • Cc arthur added

This change is in review, and it occurred to me that one of the implications of this change is that a patterns.ini containing multiple entries for a subscription will only be read as having a single entry. The only thing that this may have any implications for is the UI, because even with multiple entries, each entry would have all the filters for the subscription (so two entries A, B, C and D, E, F would be merged into the same Subscription object A, B, C, D, E, F), which means this already had no implications for ad blocking.

Because of #6858, we will still end up with multiple SpecialSubscription objects serialized and deserialized, but each one has a unique URL so they are not the same subscription.

So again, the only implications are for UI.

Question to Thomas, Arthur, Sebastian:

  • Does the UI support, or has plans to support, adding the same subscription more than once? (I don't see why, but still asking)
  • Did the UI ever explicitly support (not just because it just worked that way) adding the same subscription more than once?
  • Does the UI do any explicit check to avoid adding the same subscription more than once?


This is a different question than whether subscriptions should be movable within the list of subscriptions.

The definition of "same subscription" here is two subscriptions with the same URL.

Last edited on 10/01/2018 at 11:08:02 AM by mjethani

comment:16 in reply to: ↑ 15 Changed on 10/01/2018 at 01:49:05 PM by mjethani

Replying to mjethani:

  • Does the UI support, or has plans to support, adding the same subscription more than once? (I don't see why, but still asking)

So I looked at the current behavior, it seems you can try to add the same subscription again but "nothing happens". Suggestion for UI: at least when a subscription is added, the item in the list could perhaps be highlighted briefly (something like a yellow fade).

  • Did the UI ever explicitly support (not just because it just worked that way) adding the same subscription more than once?

This is not so important actually.

  • Does the UI do any explicit check to avoid adding the same subscription more than once?

The answer appears to be no.

So the change here is only going to affect how an existing patterns.ini is going to be read, which also probably includes a change in how it will be displayed in the UI (duplicate entries will not appear now).

It's for the best. I'll just make a note in the issue description about this.

comment:17 in reply to: ↑ 15 ; follow-up: Changed on 10/02/2018 at 02:50:38 PM by greiner

Replying to mjethani:

  • Does the UI support, or has plans to support, adding the same subscription more than once? (I don't see why, but still asking)

I can't think of a reason why either. We use the URL as a unique identifier for subscriptions since the communication between the extension and the UI is serialized. Therefore having a second subscription that uses the same URL will essentially lead to undefined behavior.

  • Did the UI ever explicitly support (not just because it just worked that way) adding the same subscription more than once?

Not that I'm aware of. Presumably only Wladimir would know.

  • Does the UI do any explicit check to avoid adding the same subscription more than once?

No. If the UI gets made aware of another subscription with the same URL as one that it already encountered, it will treat it as both being the same.

So I looked at the current behavior, it seems you can try to add the same subscription again but "nothing happens". Suggestion for UI: at least when a subscription is added, the item in the list could perhaps be highlighted briefly (something like a ​yellow fade).

Feel free to create a ticket to suggest that because more detailed information on why it would be useful and how you'd expect it to behave would be helpful.

comment:18 in reply to: ↑ 17 Changed on 10/02/2018 at 02:59:50 PM by mjethani

Replying to greiner:

Replying to mjethani:
[...]

Thanks for the clarifications.

So I looked at the current behavior, it seems you can try to add the same subscription again but "nothing happens". Suggestion for UI: at least when a subscription is added, the item in the list could perhaps be highlighted briefly (something like a ​yellow fade).

Feel free to create a ticket to suggest that because more detailed information on why it would be useful and how you'd expect it to behave would be helpful.

Sure, let me go ahead and finally create that GitLab account I've been meaning to :)

comment:19 Changed on 10/02/2018 at 05:12:10 PM by abpbot

A commit referencing this issue has landed:
Issue 6856 - Remove FilterStorage.moveSubscription

comment:20 Changed on 10/02/2018 at 05:17:00 PM by mjethani

  • Blocking 7000 added

comment:21 Changed on 10/02/2018 at 05:19:51 PM by jsonesen

  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:22 Changed on 10/02/2018 at 05:25:53 PM by mjethani

Jon, could you please add an "Integration notes" section in the description (you can see #6916 for reference)? We need to go through both adblockpluschrome and adblockplusui and point out any changes they might need to make.

comment:23 Changed on 10/02/2018 at 05:39:44 PM by jsonesen

  • Description modified (diff)

comment:24 Changed on 10/02/2018 at 06:42:39 PM by mjethani

  • Description modified (diff)

comment:25 Changed on 10/02/2018 at 06:51:42 PM by mjethani

  • Description modified (diff)

comment:26 Changed on 10/02/2018 at 07:00:05 PM by mjethani

  • Description modified (diff)

comment:27 Changed on 10/08/2018 at 06:07:09 PM by greiner

For reference, I've created #7027 for UI-related changes.

comment:28 Changed on 02/07/2019 at 03:23:28 AM by abpbot

A commit referencing this issue has landed:
Issue 6856 - Remove FilterStorage.moveSubscription

comment:29 Changed on 02/21/2019 at 10:54:12 AM by ukacar

  • Verified working set

Add Comment

Modify Ticket

Change Properties
Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from jsonesen.
 
Note: See TracTickets for help on using tickets.