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

get_all_user_name_fields() deprecated since Moodle 3.11 #539

Open
danowar2k opened this issue Feb 14, 2024 · 2 comments
Open

get_all_user_name_fields() deprecated since Moodle 3.11 #539

danowar2k opened this issue Feb 14, 2024 · 2 comments

Comments

@danowar2k
Copy link

Found in my logs:

Debugging: get_all_user_name_fields() is deprecated. Please use the \\core_user\\fields API instead in 
* line 3280 of /lib/deprecatedlib.php: call to debugging()
* line 582 of /mod/hvp/locallib.php: call to get_all_user_name_fields()
* line 664 of /mod/hvp/locallib.php: call to hvp_send_notification_messages()
* line ? of unknownfile: call to hvp_attempt_submitted_handler()
* line 155 of /lib/classes/event/manager.php: call to call_user_func()
* line 75 of /lib/classes/event/manager.php: call to core\\event\\manager::process_buffers()
* line 835 of /lib/classes/event/base.php: call to core\\event\\manager::dispatch()
* line 113 of /mod/hvp/classes/user_grades.php: call to core\\event\\base->trigger()
* line 167 of /mod/hvp/ajax.php: call to mod_hvp\\user_grades::handle_ajax()

@melanietreitinger
Copy link

Steps to reproduce:

  • Create a course and add an H5P activity.
  • Go to Grades.
  • Click on the three dots next to the H5P activity.
  • Click on "View H5P Results"

Error:

  • On the next page you will see "Loading data." but never any results.
  • Open the browser console and reload the page.
  • Go to the networking tab.
  • Click on the "mod/hvp/ajax.php?action=results" line.
  • View the error in the answer section.

Success:

  • The expected results are shown.

@davidherney
Copy link
Contributor

Hi...

I've made a patch while the official fix is ​​coming out. It's not the best solution, but it works around the bug for now.

diff --git a/classes/results.php b/classes/results.php
index c958a4d..26e8b5e 100644
--- a/classes/results.php
+++ b/classes/results.php
@@ -295,8 +295,8 @@ class results {
         static $ordered;

         if (empty($ordered)) {
-            $available = \get_all_user_name_fields();
-            $displayname = \fullname((object)$available);
+            $available = [];
+            $displayname = '';
             if (empty($displayname)) {
                 $ordered = array("{$prefix}firstname", "{$prefix}lastname");
             } else {
diff --git a/locallib.php b/locallib.php
index 874d1ae..ffce223 100644
--- a/locallib.php
+++ b/locallib.php
@@ -579,7 +579,6 @@ function hvp_send_notification_messages($course, $hvp, $attempt, $context, $cm)
     // Check for notifications required.
     $notifyfields = 'u.id, u.username, u.idnumber, u.email, u.emailstop, u.lang,
             u.timezone, u.mailformat, u.maildisplay, u.auth, u.suspended, u.deleted, ';
-    $notifyfields .= get_all_user_name_fields(true, 'u');
     $groups       = groups_get_all_groups($course->id, $submitter->id, $cm->groupingid);
     if (is_array($groups) && count($groups) > 0) {
         $groups = array_keys($groups);

I hope it helps to give an idea or as a temporary solution.

Saludos

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

3 participants