Moodle
  1. Moodle
  2. MDL-28580

perform safety check on the third argument to upgrade_main_savepoint()

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.4, 2.1.1, 2.2
    • Fix Version/s: 2.0.5, 2.1.2
    • Component/s: Administration
    • Labels:
    • Rank:
      18260

      Description

      We use two upgrade functions to track versions. upgrade_main_savepoint() and upgrade_mod_savepoint(). Mixing them up causes bad things to happen as the mod version may be ahead of the moodle core version.

      The third param to upgrade_main_savepoint() is a boolean. The third param to upgrade_mod_savepoint() is a string (component name).

      We could add a check to upgrade_main_savepoint() that tests if the 3rd param is a boolean. If not its likely someone is calling the wrong function and we should display an error.

        Activity

        Hide
        Michael de Raadt added a comment -

        Thanks for reporting this, Dan.

        Show
        Michael de Raadt added a comment - Thanks for reporting this, Dan.
        Hide
        Andrew Davis added a comment - - edited

        A possible error message, probably produced via a thrown coding exception, could be something like "Parameter type mismatch. Are you mixing up upgrade_main_savepoint() and upgrade_mod_savepoint()?"

        Show
        Andrew Davis added a comment - - edited A possible error message, probably produced via a thrown coding exception, could be something like "Parameter type mismatch. Are you mixing up upgrade_main_savepoint() and upgrade_mod_savepoint()?"
        Hide
        Rajesh Taneja added a comment -

        Thanks Andrew
        Message updated.

        Show
        Rajesh Taneja added a comment - Thanks Andrew Message updated.
        Hide
        Rossiani Wijaya added a comment -

        Thanks for fixing it Raj.

        Patch looks great.

        Show
        Rossiani Wijaya added a comment - Thanks for fixing it Raj. Patch looks great.
        Hide
        Aparup Banerjee added a comment -

        Thanks for this improvement! This has been carefully integrated.

        Show
        Aparup Banerjee added a comment - Thanks for this improvement! This has been carefully integrated.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Just tested this by hacking one upgrade.php call here, adding 3rd non bool param I got the coding exception.

        So passing, ciao

        Note: Unless 100% untestable, try to add always testing instructions. If they are complex (require dev skills) just state it clearly.

        Note2: No worries, I'm the 1st that, sometimes, have skipped testing instructions, lol. Just we should minimize the cases.

        Show
        Eloy Lafuente (stronk7) added a comment - Just tested this by hacking one upgrade.php call here, adding 3rd non bool param I got the coding exception. So passing, ciao Note: Unless 100% untestable, try to add always testing instructions. If they are complex (require dev skills) just state it clearly. Note2: No worries, I'm the 1st that, sometimes, have skipped testing instructions, lol. Just we should minimize the cases.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Many thanks for the hard work, this has been sent upstream and is available in all the git and cvs repositories.

        Show
        Eloy Lafuente (stronk7) added a comment - Many thanks for the hard work, this has been sent upstream and is available in all the git and cvs repositories.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: