Page MenuHomePhabricator

PHP warning with exactly one avatar uploaded
Closed, ResolvedPublic

Description

On the mediawiki.org description, this is written:

It should also be noted that if only one user has uploaded an avatar and no other user has done so, using <randomuserswithavatars> causes a PHP warning about invalid arguments for foreach in the main extension file and no avatars are displayed. For example, if 2 or more users have uploaded an avatar, then this tag will work properly.

I'm just wondering, why not just fix the bug? All you'd have to do is cast to an array on line 55, like so:
$random_keys = (array)array_rand( $files, $count );

Event Timeline

Change 319879 had a related patch set uploaded (by Jack Phoenix):
Ensure that the thing we want to be an array...is actually an array

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

Change 319879 merged by Jack Phoenix:
Ensure that the thing we want to be an array...is actually an array

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

ashley claimed this task.

The extension info page was written a long time ago. Thanks for the suggestion, I've implemented & merged it. :)