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

Notice: Undefined index: month in C:\xampplite\htdocs\moodle\lib\form\dateselector.php

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.9.7
    • Fix Version/s: None
    • Component/s: Administration
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE

      Description

      Site administratoration - Users - Accounts - Browse list of users

      When we search a user by setting on any condition in filter form, we will get a notice message as following;

      Notice: Undefined index: month in C:\xampplite\htdocs\moodle\lib\form\dateselector.php

      The cause of this notice is inconsistency of values between prepared values for pull-down menu and initial setting value (= current date).

      Prepared values of array is "1, 2, 3, 4, 5, 6, ..., 12".(strings),
      initial setting value of month (=$currentdata['mon']) base on following code in function onQuickFormEvent() of lib/form/dateselector.php is "03," (=March, string(2))
      $currentdate = usergetdate($value);

      We can solve this problem by changing only one statement as follows.

      $requestvalue=$value;
      if ($value == 0)

      { $value = time(); }

      if (!is_array($value)) {
      // $currentdate = usergetdate($value);
      $currentdate = usergetdate($value, "%B");
      $value = array(
      'day' => $currentdate['mday'],
      'month' => $currentdate['mon'],
      'year' => $currentdate['year']);
      // If optional, default to off, unless a date was provided
      if($this->_options['optional'])

      { $value['off'] = ($requestvalue == 0) ? true : false; }

      $currentdate['mon'] will be changed "03"(string(2)) to 3(int) by adding argument "%B".
      Since the prepared list of month are generated in function _createElements() as follows;
      function _createElements()
      {
      $this->_elements = array();
      for ($i=1; $i<=31; $i++)

      { $days[$i] = $i; }

      for ($i=1; $i<=12; $i++)

      { $months[$i] = userdate(gmmktime(12,0,0,$i,15,2000), "%B"); }

      for ($i=$this->_options['startyear']; $i<=$this->_options['stopyear']; $i++)

      { $years[$i] = $i; }

      by using function userdate() with "%B" argument.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              danmarsden Dan Marsden
              Reporter:
              shirai Tatsuya Shirai
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              8 Vote for this issue
              Watchers:
              11 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: