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

Saving optional date/time custom field on user profile fails if in custom field settings date range starts later then unix time start (1970)

XMLWordPrintable

    • MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_28_STABLE, MOODLE_30_STABLE
    • MOODLE_30_STABLE, MOODLE_31_STABLE
    • MDL-43887-master
    • Hide

      As admin:

      1. Browse to "Site administration" > "Users" > "User profile fields"
      2. From the "Create a new profile field" dropdown, select "date/time"
      3. Set the following:
        • Short name: datetime1
        • Name: "datetime1"
        • Start year: 1971
      4. Browse to a user's profile
      5. Verify the datetime1 field is not visible
      6. Edit the user's profile with the "Edit profile" link at the top right of the "User details" panel
      7. Don't change anything, just press "Update profile"
      8. Go back to the same user's profile - verify you still do not see the datetime1 field
      9. Edit the profile again, this time expand all the sections and find the datetime1 field, enable it, and set some date (remember it)
      10. Save the profile
      11. Check the user's profile and verify it is set to the date you just selected (nb There is a pre-existing problem with moodle that stops you from setting the date to 1 January 1970 if your timezone is UTC)
      12. Edit the profile again, disable the datetime1 field
      13. Save
      14. Check the profile and verify the field is no longer visible
      15. Edit the profile, verify the datetime field is disabled
      16. Repeat the above with a new datetime field, but this time set the min year to something less than 1970
      Show
      As admin: Browse to "Site administration" > "Users" > "User profile fields" From the "Create a new profile field" dropdown, select "date/time" Set the following: Short name: datetime1 Name: "datetime1" Start year: 1971 Browse to a user's profile Verify the datetime1 field is not visible Edit the user's profile with the "Edit profile" link at the top right of the "User details" panel Don't change anything, just press "Update profile" Go back to the same user's profile - verify you still do not see the datetime1 field Edit the profile again, this time expand all the sections and find the datetime1 field, enable it, and set some date (remember it) Save the profile Check the user's profile and verify it is set to the date you just selected ( nb There is a pre-existing problem with moodle that stops you from setting the date to 1 January 1970 if your timezone is UTC) Edit the profile again, disable the datetime1 field Save Check the profile and verify the field is no longer visible Edit the profile, verify the datetime field is disabled Repeat the above with a new datetime field, but this time set the min year to something less than 1970
    • 3.2 Sprint 1

      Noticed on Moodle 2.5.2+ that when you create custom field with date range where year minimum value is greater then unixtime start year (1970) and you make it optional it is enabled all the time, even if you on edit user profile page uncheck enable checkbox and press update profile.

      This happens as date is bounded in /user/profile/field/datetime/field.class.php
      with range start and end date (function edit_save_data_preprocess). So the date becomes not 0 anymore.

      To reproduce problem:

      1. In user profile create a new custom field - date/time
      2. Use the values...
        • Is this field required? No
        • Start year 1971
      3. Go to a user's profile editing page.
      4. Check that your created custom field is disabled.
      5. Click update profile.
      6. Check the date field on the user's profile page
      7. Edit the user's profile again and check the date field

      Expected result: The date is not set and remains disabled.

      Actual result: The date is set to 1 Jan 1971 and is enabled. There is no way to disable the date.

            cameron1729 cameron1729
            avegys Andrius
            Frédéric Massart Frédéric Massart
            David Monllaó David Monllaó
            Marina Glancy Marina Glancy
            Votes:
            11 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated:
              Resolved:

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