danmarsden / moodle-mod_dialogue

Dialogue Module for Moodle
27 stars 35 forks source link

user_picture::fields() for Moodle 3.10 and older #99

Closed Polirecyliente closed 2 years ago

Polirecyliente commented 2 years ago

Good day, I'm not really sure if this is a valid issue, so please feel free to summarily close if it is not relevant.

The commit c210704146eea920189ec9fd00980b45762eebff fixed the deprecation of user_picture::fields() from Moodle 3.11, but the fix was made in such a way, that it would fail on Moodle 3.10 or older, does it not?

For example $requiredfields = user_picture::fields('u'); was replaced by:

$requiredfields = \core_user\fields::for_userpic()
          ->get_sql('u', false, '', '', false)
          ->selects;

This is correct, but it would fail for users of Moodle 3.10 or older, because the function \core_user\fields::for_userpic() does not exist in those versions, or was it backported?

I've seen other plugins do it like:

if ($CFG->version < 2021050700) {
    $requiredfields = user_picture::fields('u');
} else {
    $requiredfields = \core_user\fields::for_userpic()
          ->get_sql('u', false, '', '', false)
          ->selects;
}

As a way to provide the older function for older versions of Moodle.

Thanks for your attention.

danmarsden commented 2 years ago

That method introduces technical debt. I use a branching method (like moodle core) please see the readme for supported versions and the correct branch in github to use. https://github.com/danmarsden/moodle-mod_dialogue#branches

Thanks.