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

require_course_login: incorrect variable assignment

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 2.4.9, 2.5.5, 2.6.2
    • 2.3.9, 2.4.6, 2.5.2, 2.6
    • 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

      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);

            skodak Petr Skoda
            mgauk Martin Gauk
            Frédéric Massart Frédéric Massart
            Sam Hemelryk Sam Hemelryk
            Mark Nelson Mark Nelson
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.