Moodle

Proposal to move the module post install hook to after the site course setup

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9
  • Fix Version/s: 2.0
  • Component/s: General, Installation
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

The new hook in 1.9 that allows a module to do some stuff post db install is awesome. However it would be more useful if the call was done later in the install process, once the site course is set-up.

Doing the call post site course set-up would allow module to make role overrides and on the site course and other such things and would basically maximise the usefulness of the hook.

I know nothing in core is using the hook, so unless there's a contrib module relying on the call it should be safe to move without breaking anything.

Any feedback is welcome.

Activity

Hide
Eloy Lafuente (stronk7) added a comment -

Just thinking about one alternative hook that could produce the same behaviour in your case (generating one module-instance after site course is created) and also could be used for other courses (not only site).

What about to add two new hooks to modules, say:

newmodule_after_course_creation($course)

newmodule_before_course_deletion($course)

(I've added both just to have them balanced, you can safely ignore the 2nd one)

The cause for this alternative, is that I really think the current newmodule_install() and newmodule_uninstall() are being executed in the correct place now. And moving them after site creation sounds really too much specific for me (while the proposal above sounds more general).

Also, I think we should start introducing the "after/before" or "post/pre" nomenclature to all hooks (plus documenting them) ASAP. It really helps understanding when they are executed.

Just my opinion. Also... suggesting this for 1.9.1... MD has the last word. Ciao

Show
Eloy Lafuente (stronk7) added a comment - Just thinking about one alternative hook that could produce the same behaviour in your case (generating one module-instance after site course is created) and also could be used for other courses (not only site). What about to add two new hooks to modules, say: newmodule_after_course_creation($course) newmodule_before_course_deletion($course) (I've added both just to have them balanced, you can safely ignore the 2nd one) The cause for this alternative, is that I really think the current newmodule_install() and newmodule_uninstall() are being executed in the correct place now. And moving them after site creation sounds really too much specific for me (while the proposal above sounds more general). Also, I think we should start introducing the "after/before" or "post/pre" nomenclature to all hooks (plus documenting them) ASAP. It really helps understanding when they are executed. Just my opinion. Also... suggesting this for 1.9.1... MD has the last word. Ciao
Hide
Matt Clarkson added a comment -

Adding an extra call works for me - there can never be too many hooks IMHO

I would like to see it in 1.9.1 also.

Show
Matt Clarkson added a comment - Adding an extra call works for me - there can never be too many hooks IMHO I would like to see it in 1.9.1 also.
Hide
Petr Škoda (skodak) added a comment -

site and default category is now created right after the installation of core, before any plugins

thanks for the report

Show
Petr Škoda (skodak) added a comment - site and default category is now created right after the installation of core, before any plugins thanks for the report

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: