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

replace hard-coded numbers with defined values in mod/forum/lib.php

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.1
    • Fix Version/s: 2.5
    • Component/s: Forum
    • Labels:
    • Testing Instructions:
      Hide
      1. Set $CFG->maxeditingtime to 0 in your config.php file.
      2. Set $CFG->forum_enabletimedposts to 1 in your config.php file.
      3. Create a course with two students enrolled.
      4. Create a forum as an admin.
      5. Add a discussion.
      6. Log in as one of the users and write a post to the discussion.
      7. Log in as another user and respond to this post.
      8. Run the cron and ensure an email is sent to the first user telling them about the response to their post.

      Repeat the steps 2-8, except this time set $CFG->forum_enabletimedposts to 0.

      Show
      Set $CFG->maxeditingtime to 0 in your config.php file. Set $CFG->forum_enabletimedposts to 1 in your config.php file. Create a course with two students enrolled. Create a forum as an admin. Add a discussion. Log in as one of the users and write a post to the discussion. Log in as another user and respond to this post. Run the cron and ensure an email is sent to the first user telling them about the response to their post. Repeat the steps 2-8, except this time set $CFG->forum_enabletimedposts to 0.
    • Affected Branches:
      MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE
    • Pull Master Branch:
      MDL-37953_master

      Description

      forum_posts.mailed is set to 0, 1, and 2. These numbers can only be understood if you find the code context where they are set.

      This patch replaces those hard-coded numbers with define()d words: https://github.com/moquist/moodle/commit/0f8fdb3a73d5bd82894c80898c6757f0bd575692

      Since this is really just a change to improve code maintenance and debugging, there's probably no need to apply it to prior versions.

      [EDIT: I updated the commit URL above because I read too fast and misunderstood what 1 and 2 meant on my first time through the code! I contend that this helps emphasize the importance of using words instead of numbers to convey non-numeric meaning...]

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/May/13