Page MenuHomePhabricator

ApiQueryAllUsers with activeusers=1 includes users with 0 recent actions
Closed, ResolvedPublic

Description

Example: this API result has as many as 17 users with recentactions value given as 0.

I'm no PHP expert but looking at the code lines 253

			if ( $params['activeusers'] && $row->recentactions === 0 ) {
				// activeusers cache was out of date
				continue;
			}

and 279:

				$data['recentactions'] = (int)$row->recentactions;

Line 253 should probably have been

			if ( $params['activeusers'] && (int)$row->recentactions === 0 ) {

(integer type cast is missing).

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
daniel triaged this task as Medium priority.Aug 26 2020, 9:52 AM
daniel subscribed.

Thanks for the bug report, this analysis looks right at a glance.

So the fix is trivial. But it would be good to have a regression test.

Change 694554 had a related patch set uploaded (by Dmitriy.sky; author: Dmitriy.sky):

[mediawiki/core@master] Cast user recentactions param type to integer for ApiQueryAllUsers with activeusers=1.

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

Change 694554 merged by jenkins-bot:

[mediawiki/core@master] Cast user recentactions param type to integer for ApiQueryAllUsers with activeusers=1.

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