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

require_course_login: incorrect variable assignment

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.9, 2.4.6, 2.5.2, 2.6
    • 2.4.9, 2.5.5, 2.6.2
    • Libraries
    • MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • w04_MDL-43746_m27_courselogin
    • 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);
    • 2
    • 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

              skodak Petr Skoda
              mgauk Martin Gauk
              Frédéric Massart Frédéric Massart
              Sam Hemelryk Sam Hemelryk
              Mark Nelson Mark Nelson
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                10/Mar/14