Skip to content
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

Exception when calling core_user\fields::get_sql() with null as fouth argument #119

Open
babington-andy opened this issue Jul 5, 2021 · 6 comments

Comments

@babington-andy
Copy link

Since upgrading to Moodle 3.11 (currently on version 2021051700.06), when accessing an oublog activity the following exception is thrown...

Exception - Argument 3 passed to core_user\fields::get_sql() must be of the type string, null given, called in [dirroot]/lib/outputcomponents.php on line 261.

This is being caused by the oublog_stats_output_participation function in locallib.php on line 4623 (in the current version)
$fields = explode(',', user_picture::fields('', null, '', null));.

The user_picture::fields static method is deprecated in favour of \core_user\fields::for_userpic();

@jason-platts
Copy link
Member

Thanks for reporting this. We are not on 3.11 yet so it may be a while till a fix for this is released...

@babington-andy
Copy link
Author

Hi @jason-platts I've fixed the issue locally by changing...

$fields = explode(',', user_picture::fields('', null, '', null));
...to...
$fields = \core_user\fields::for_userpic();

alternatively $fields = explode(',', user_picture::fields('', null, '', '')); would work too, but would not be as future proof.

@drobayo
Copy link

drobayo commented Oct 31, 2021

Maybe this can work
/lib/outputcomponents.php
oublog_stats_output_participation() Function

$userfields = \core_user\fields::for_userpic();
$userfieldssql = $userfields->get_sql('', false, '', '', false)->selects;
// Strip spaces.
$userfieldssql = preg_replace('/\s+/', '', $userfieldssql);

$fields = explode(',', $userfieldssql);

@jstilwell
Copy link

Hello,

We're experiencing this same bug on an upgrade to Moodle 3.11. Is there a timeframe on when it might be patched in an official release? I see that a couple of nice devs have relayed some potential fixes, but I'm unable to edit our code directly, so am reliant on fixed official releases.

@jason-platts
Copy link
Member

Sorry about that, we have pushed the latest code for 3.11 here but haven't yet setup a release in the plugin database... I'll do that today.

@jstilwell
Copy link

Sorry about that, we have pushed the latest code for 3.11 here but haven't yet setup a release in the plugin database... I'll do that today.

No need to apologize! Thank you for supporting FOSS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants