I have attached a simple test install profile. My tasks gets called, and I pass it at batch array, but my batch array doesn't get executed. I am pretty sure it has to do with batch_process in install.core.inc on 446.

CommentFileSizeAuthor
test.zip1.25 KBpwaterz

Comments

pwaterz’s picture

Status: Active » Closed (works as designed)

Alright well I figured out the problem. I put hook_install_tasks in the .install file. This caused the profile to kinda of work, which made it really confusing. Someone should update the documentation on hook_install_task. I am going to close this.

gauravkumar87’s picture

Status: Closed (works as designed) » Active

Same Issue : I have an implementation of hook_install_tasks in my .profile file. For tasks set to type 'batch', install_run_task within install.core.inc gets called for case batch, the $batch object is retrieved properly from the callback via
$batch = $function($install_state);

Seems like there's a problem with the call to batch_process within install.core.inc

Has anyone else faced this issue? If so, please help. Thanks.

pwaterz’s picture

Do you have your hook install tasks in your .profile file?

gauravkumar87’s picture

Yes, was also following http://drupal.org/node/655190 and the documentation. Seems like support for that particular hook in .install files was added recently and one's supposed to use this in a .profile file generally. Does that make sense?

gauravkumar87’s picture

Tried implementing the same in my .install file as well, same issue.

function mymodule_install_tasks($install_state) {
        $flag = isset($install_state['flag']);
	$tasks = array();
	$tasks['install_mod'] = array(
		'display_name' => st('Install Mods'),
		'display' => TRUE,
		'type' => 'batch',
		'run' => $flag ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP, 
		'function' => '_install_mods',
	);
	return $tasks;
}

function _install_mods() {
	global $install_state;
	$batch = array(
	  'title' => t('Installing Mods'),
	);
	//copying implementation from install.core.inc since module_enable does not seem to play well with Batch API
	$files = system_rebuild_module_data();
	foreach ($install_state['mods'] as $key => $module) {
    $batch['operations'][] = array('_install_module_batch', array($module, $files[$module]->info['name']));
  }
	return $batch;
}

The Batch does not get processed irrespective of whether this resides in my .install or .profile file.

mrfelton’s picture

I have a module that runs a batch process as part of it's install hook. When this module is installed either as from an install profiles's .info file, or as part of an instal task, the batch is not properly executed.

pwaterz’s picture

Status: Active » Closed (works as designed)

Make sure that the hook_install_tasks is in the .profile file of your install profile. I am closing this.

mrfelton’s picture

Status: Closed (works as designed) » Active

It is. In my .profile file, I have the following:

// Include only when in install mode. MAINTENANCE_MODE is defined in
// install.php and in drush_core_site_install().
if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install') {
  include_once('example.install.inc');
}

The hook_install_tasks are in example.install.inc

I think, though I'm not sure, that my problem is slightly different. It's not an insall task of type batch, but a module's hook_install implementation that is being installed in an install task using module_enable.

pwaterz’s picture

This looks not related. I would post a new bug report

Version: 7.9 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.