moodleou / moodle-mod_oublog

Alternative blog module for Moodle 2 (including course blogs)
31 stars 27 forks source link

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

Open babington-andy opened 3 years ago

babington-andy commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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.