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

require_course_login: incorrect variable assignment

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.9, 2.4.6, 2.5.2, 2.6
    • Fix Version/s: 2.4.9, 2.5.5, 2.6.2
    • Component/s: Libraries
    • Labels:
    • Testing Instructions:
      Hide

      this cannot be tested in unittest, so you neeed to create some hacky script and test it manually:

      <?php
       
      require 'config.php';
       
      // Following two should not redirect to login page.
      //require_course_login($SITE);
      //require_course_login($SITE->id);
       
      // The next two should redirect to login page.
       
      $course = $DB->get_record('course', array('id'=>2));
      //require_course_login($course);
      //require_course_login($course->id);
       
      var_dump($USER->id);
      

      Show
      this cannot be tested in unittest, so you neeed to create some hacky script and test it manually: <?php   require 'config.php';   // Following two should not redirect to login page. //require_course_login($SITE); //require_course_login($SITE->id);   // The next two should redirect to login page.   $course = $DB->get_record('course', array('id'=>2)); //require_course_login($course); //require_course_login($course->id);   var_dump($USER->id);
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      w04_MDL-43746_m27_courselogin
    • Story Points:
      2
    • Sprint:
      BACKEND Sprint 9

      Description

      In function require_course_login (/lib/moodlelib.php) $issite is never true if parameter $courseorid is not an object.

      $issite = (is_object($courseorid) and $courseorid->id == SITEID)
                or (!is_object($courseorid) and $courseorid == SITEID);

      is not working correctly because = has a higher precedence than and/or in PHP. It should be:

      $issite = (is_object($courseorid) && $courseorid->id == SITEID)
                || (!is_object($courseorid) && $courseorid == SITEID);

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Mar/14