Page MenuHomePhabricator

`NewsletterDb::addSubscription` and `NewsletterDb::removeSubscription` update subscribers count incorrectly
Closed, DuplicatePublic


While working on adding unit test for getNewsletterSubscribersCount in T183808, I noticed that subscribers count is updated incorrectly in NewsletterDb::addSubscription and NewsletterDb::removeSubscription.

addSubscription supports adding multiple subscribers at once (param $userIds is an array of users IDs to add as subscribers). So it iterates over $userIds and adds rows to nl_subscriptions table.

After adding subscriptions, this function updates nl_newsletter table with updated subscriber count. Here is the problem: it increases number of subscribers by 1 even if there were more than 1 user in $userIds.

The same problem is with removeSubscription.

If I am right about this, then it should be fixed. Otherwise there should be a comment explaining this behaviour in those functions.

Event Timeline

Restricted Application added subscribers: TerraCodes, Aklapper. · View Herald TranscriptJan 2 2018, 11:48 AM

I will provide a patch for this

Change 401495 had a related patch set uploaded (by Phantom42; owner: Phantom42):
[mediawiki/extensions/Newsletter@master] Fix incorrect subscriber count updates