Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-52608

Better php coding style in function fullname() in /lib/moodlelib.php

    XMLWordPrintable

Details

    • MOODLE_30_STABLE
    • MOODLE_29_STABLE, MOODLE_30_STABLE
    • MDL-52608-master
    • Hide
      1. Check nightly server, make sure that all behats pass
      2. In php5 and php7, make sure no debugging messages display while doing the following:
        1. Create a course and enrol a student
        2. View the participants list
        3. View the student's profile
        4. Create an assignment
        5. View the grading screen
      Show
      Check nightly server, make sure that all behats pass In php5 and php7, make sure no debugging messages display while doing the following: Create a course and enrol a student View the participants list View the student's profile Create an assignment View the grading screen

    Description

      There is code in /lib/moodlelib.php:3263:

      // Get all of the name fields.
          $allnames = get_all_user_name_fields();
          if ($CFG->debugdeveloper) {
              foreach ($allnames as $allname) {
                  if (!array_key_exists($allname, $user)) {
                      // If all the user name fields are not set in the user object, then notify the programmer that it needs to be fixed.
                      debugging('You need to update your sql to include additional name fields in the user object.', DEBUG_DEVELOPER);
                      // Message has been sent, no point in sending the message multiple times.
                      break;
                  }
              }
          }
      

      Problem is in the line 3267:

      if (!array_key_exists($allname, $user)) {

      $user is stdClass, line can be changed to:

      if (!object_property_exists($user, $allname)) {

      Attachments

        Activity

          People

            moodle.com Moodle HQ
            dkuzevanov Dmitriy Kuzevanov
            John Okely John Okely
            Andrew Lyons Andrew Lyons
            Rajesh Taneja Rajesh Taneja
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              14/Mar/16