Null Coalescing Operator usage is causing WSOD on users page

Created on 10 September 2024, 4 months ago
Updated 18 September 2024, 4 months ago

Problem/Motivation

It looks like the use of
https://git.drupalcode.org/project/miniorange_2fa/-/blame/5.0.x/src/Form...
" ->limit($this->config->get('mo_user_management_pages') ?? 5)"

is causing the query to return no values if mo_user_management_pages is blank.
This then causes a a fatal error on the subsequent fetchAll() call.

Steps to reproduce

In config set miniorange_2fa.settings.yml:mo_user_management_pages: ''
(I think this can be replicated by just deleting the value out of the input box and saving the form)

Proposed resolution

using ?->fetchAll() takes care of fatal error.

Would recommend that instead of using ?? you use ? empty(config...) instead. That way you test for the empty string if the value is set to ''.

I'd also recommend using query execute fetch all calls with ?-> to ensure you are not generating fatal errors.

🐛 Bug report
Status

Active

Version

5.1

Component

Code

Created by

🇳🇿New Zealand luke.stewart

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024