The following patch adds several functions that can be used by any module:
system_set_default_theme($theme)
block_set_status($module, $delta, $status, $theme)
block_set_position($module, $delta, $region, $position, $theme)

It also adds two functions to install.inc, which can only be called when that file is included:
drupal_install_module($module)
drupal_uninstall_module($module)

The uninstall function in particular calls a module's 'uninstall' hook, then *deletes* its entry from the system table. There's no UI for it yet, but the feature has been requested by a number of users -- modules would be expected to drop their tables and so on in the 'uninstall' hook.

The main purpose of all of these functions is to make more of Drupal's system management work available via API functions. With the installer, and the advent of install profiles, making it easier to do this work without a long list of db_query() calls is a good thing.

CommentFileSizeAuthor
utility_functions.patch3.67 KBeaton
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

I +1 the principle, I think having these available will be a good thing; they'll be useful in refactoring the modules/themes admin page.

Dries’s picture

Can't we use these in core itself?

merlinofchaos’s picture

Dries: I sure hope so =)

eaton’s picture

Dries: Actually I'm in the process of making a new version of this patch that would use the same functions on admin/theme, admin/module, and so on. Once I'm finished with it (hopefully in the next day or so) even the install system would be able to use single-call 'install module x' functions.

So, yes. Eating our own dogfood, coming soon to a patch near you. :-)

eaton’s picture

Some of the module install/enabling related functions in this patch ended up being important for an actual bug-fix over at http://drupal.org/node/76209. I've split out those changes in particular to that patch, and will be re-rolling a version of this patch that *just* includes the block and theme management code (as well as changes to system.module and block.module to use the new centralized functions.)

webchick’s picture

Version: x.y.z » 6.x-dev
Status: Needs review » Needs work

While the patch still (surprisingly!) applies, I'm pretty sure the module_install and module_uninstall functions are totally irrelevant at this point. Marking CNW. It would be nice to have those block helper functions for install profiles.

catch’s picture

Version: 6.x-dev » 7.x-dev
casey’s picture

Version: 7.x-dev » 8.x-dev

We do have now:

http://api.drupal.org/api/function/drupal_install_modules/7
http://api.drupal.org/api/function/drupal_uninstall_modules/7

Leaves this issue to:
system_set_default_theme($theme)
block_set_status($module, $delta, $status, $theme)
block_set_position($module, $delta, $region, $position, $theme)

valthebald’s picture

Issue summary: View changes
Issue tags: +Needs issue summary update

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Closed (outdated)

@eaton, thanks for patch.

With the move to OO code this is not outdated.