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

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

    XMLWordPrintable

    Details

    • Testing Instructions:
      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
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_29_STABLE, MOODLE_30_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-52608-master

      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

            Assignee:
            moodle.com moodle.com
            Reporter:
            dkuzevanov Dmitriy Kuzevanov
            Peer reviewer:
            John Okely
            Integrator:
            Andrew Nicols
            Tester:
            Rajesh Taneja
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              14/Mar/16