Moodle
  1. Moodle
  2. MDL-29097

Module updated/created event is called too early

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.4, 2.2.1, 2.3
    • Fix Version/s: None
    • Component/s: Events API
    • Testing Instructions:
      Hide

      Create an activity module. Check no errors or warnings are generated.

      Edit an activity module's settings. Check no errors or warnings are generated.

      Moodle core doesn't actually consume the events it generates so the event generation cannot really be tested without writing additional code (http://docs.moodle.org/dev/Events_API).

      Show
      Create an activity module. Check no errors or warnings are generated. Edit an activity module's settings. Check no errors or warnings are generated. Moodle core doesn't actually consume the events it generates so the event generation cannot really be tested without writing additional code ( http://docs.moodle.org/dev/Events_API ).
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull Master Branch:
      MDL-29097_mod_update_create
    • Rank:
      18621

      Description

      The event is basically called before some grade stuff and before the course cache has been rebuilt. To avoid having to do some trickery or rebuilding the course cache twice, just move the event triggers lower in the code. At the very least, this is now less code

        Activity

        Hide
        Michael de Raadt added a comment -

        Thanks for providing a solution to that.

        Show
        Michael de Raadt added a comment - Thanks for providing a solution to that.
        Hide
        Andrew Davis added a comment -

        Thanks for that Mark. I've created a branch containing a slightly modified version of your patch.

        Show
        Andrew Davis added a comment - Thanks for that Mark. I've created a branch containing a slightly modified version of your patch.
        Hide
        Andrew Davis added a comment -

        Added testing instructions.

        Show
        Andrew Davis added a comment - Added testing instructions.
        Hide
        Sam Hemelryk added a comment -

        Looks good thanks Andrew, backport and up for integration.

        Only thing I noted is that you don't need to initialise $eventname as an empty string. I don't think we will ever add another if...else to that branch though so not an essential to remove it.

        Cheers
        Sam

        Show
        Sam Hemelryk added a comment - Looks good thanks Andrew, backport and up for integration. Only thing I noted is that you don't need to initialise $eventname as an empty string. I don't think we will ever add another if...else to that branch though so not an essential to remove it. Cheers Sam
        Hide
        Andrew Davis added a comment -

        Created the various branches.

        Initializing variables outside of if else structures is a habit from C+. In C+ a variable defined within an if goes out of scope when you leave the if. Variables defined inside an if and used outside of it still look wrong to me.

        Show
        Andrew Davis added a comment - Created the various branches. Initializing variables outside of if else structures is a habit from C+ . In C + a variable defined within an if goes out of scope when you leave the if. Variables defined inside an if and used outside of it still look wrong to me.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

        TIA and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
        Hide
        Aparup Banerjee added a comment -

        ok, changes look good, this is in integration now.

        Show
        Aparup Banerjee added a comment - ok, changes look good, this is in integration now.
        Hide
        Jason Fowler added a comment -

        All good

        Show
        Jason Fowler added a comment - All good
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Many thanks for your collaboration, this code has been integrated upstream and it's available in all the repositories.

        Closing, ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Many thanks for your collaboration, this code has been integrated upstream and it's available in all the repositories. Closing, ciao

          People

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

            Dates

            • Created:
              Updated:
              Resolved: