New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix contao:user:list
with empty database
#4074
Conversation
When executing 'contao-console contao:user:list' on an empty database we'd receive the following error otherwise: 'Return value of Contao\CoreBundle\Command\UserListCommand::getUsers() must be an instance of Contao\Model\Collection, null returned'
nice catch! I think we should use an array instead of returning a collection, then this problem would have happened in the first place. This also does not fix the problem when checking for admin only accounts, as that might still return |
I've refactored the code in d2d4236 - have you had something like this in mind?
right - also fixed in d2d4236 |
Why not allow private function getUsers(bool $onlyAdmins = false): ?Collection |
That's an alternative. In this case we'd need to change line 69 from
to something like
as well. Otherwise we get a the error |
contao:user:list
with empty database
contao:user:list
with empty databasecontao:user:list
with empty database
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AlexanderWillner and sorry for having to refactor this twice 😅
Thank you @AlexanderWillner. |
refactoring is fun ;) |
When executing
contao-console contao:user:list
on an empty database we'd receive the following error otherwise:Return value of Contao\CoreBundle\Command\UserListCommand::getUsers() must be an instance of Contao\Model\Collection, null returned
.With this change instead we receive a nice warning:
! [NOTE] No accounts found.