Now that we have a solution for #2098389: subdirs kicks in even when subdirs module is disabled. we need that in more modules.
Lets investigate core and contrib.

I know hosting_site_git is one such contrib.

And we should probably document this.... provision.api.php? community site?

CommentFileSizeAuthor
#6 hostmaster.documentation.2099889-6.patch591 byteshelmo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

anarcat’s picture

Component: Code » Documentation

I think this is mostly a documentation task for core - unless I am missing something, most existing modules in core use some kind of toggle from the frontend already and don't enable themselves by mistake.

So yes, community site and api.php.

ergonlogic’s picture

For 7.x-3.x, we should probably evaluate the existing toggles used in core, and consider switching to the hook_drush_load() method where appropriate. Since it'll mean fewer files loaded and hooks fired on each and every invocation of Drush, it should result in a smaller memory footprint and better performance.

anarcat’s picture

agreed.

ergonlogic’s picture

It looks like hooks in *.provision.inc files still get fired regardless of hook_drush_load(). After a quick grep through provision, I couldn't see where these are being auto-included. Is Drush just including *.inc in the root of Drush commands?

Moving these files into an includes/ directory and then explicitly including them into the main commandfile makes them respect the results of hook_drush_load().

anarcat’s picture

this is based on the engine system.

example, for install:

function provision_drupal_drush_engine_drupal() {
  $engines = array();
  $engines['clear'] = array();
  $engines['cron_key'] = array();
  $engines['deploy'] = array();
  $engines['import'] = array();
  $engines['install'] = array();
  $engines['packages'] = array();
  $engines['verify'] = array();
  return $engines;
}
# [...]
function drush_provision_drupal_provision_install_backend() {
  drush_include_engine('drupal', 'install');
}

I am not sure how migrate is fired, but I assume there is something similar.

helmo’s picture

Status: Active » Needs review
FileSize
591 bytes

Here's a suggestion for provision.api.php.

And I've added http://community.aegirproject.org/dev-cheat-sheet#Enablingdisabling_drus...

helmo’s picture

And a follow up for provision_tasks_extra in: #2106435: Check hosting_features in _drush_load hook

anarcat’s picture

that seems like a good idea.

ergonlogic’s picture

Since we need to #2102341: Differentiate between a feature being disabled vs absent, this'll end up having to look more like:

/*
 * Implements hook_drush_load().
 *
 * In a drush contrib check if the frontend part (hosting_hook variant) is enabled.
 */
function hook_drush_load() {
  $features = drush_get_option('hosting_features', array());
  return array_key_exists('hook', $features) // Front-end module is installed...
         && $features['hook'];               // ... and enabled.
}
helmo’s picture

@ergonlogic: I had missed that issue.

To improve the DX we could replace 'hook' with a variable.. now that we use it twice. e.g. $hosting_feature_name

helmo’s picture

Status: Needs review » Fixed

pushed slightly updated as bbf9d23b0553c6847da475833ed75951b1bfdd91

/**
 * Implements hook_drush_load().
 *
 * In a drush contrib check if the frontend part (hosting_hook variant) is enabled.
 */
function hook_drush_load() {
  $features = drush_get_option('hosting_features', array());
  $hook_feature_name = 'something';

  return array_key_exists($hook_feature_name, $features) // Front-end module is installed...
    && $features[$hook_feature_name];                    // ... and enabled.
}

Fixed? Or are there more places where we need this?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.