I think this has to do with the batch system, though I am not sure.

I have written an install profile for D8, everything was fine then D8 changed (as it does) and there was a problem with the script when it was trying to register node types. Before the node types where in the config system they where registered in code. I did this with a loop (so did the standard install profile). This caused an error that wasn't getting reported.

I have reproduced this by putting the following code into the minimal install profile.

  for($i = 0; $i <= 10; $i ++) {
    fake_function_of_doom();
  }

without the loop it will error out just fine, however, with the loop it errors silently. Depending on the function it will error silently and just hang or it will try and restart the installation process.

Comments

Thomas Brekelmans’s picture

I don't think your loop runs?
Your condition ($i == 10) will never be met because it's not TRUE when the loop starts ($i = 0), so the increment ($i ++) will never happen and the body of the loop won't be executed I think?
If you change your condition to $i <= 10 or something similar that'll get the loop running.

See:
http://php.net/manual/en/control-structures.for.php

frob’s picture

Whoops, I must have injected a typo when I copied it over to the issue. I have fixed the issue summery.

frob’s picture

Issue summary: View changes

Updated issue summary.

tlyngej’s picture

Issue summary: View changes

Does hook_task even exist anymore?

This issue might be obsolete.

frob’s picture

I think it is hook_install_task now, but I am still looking.

Either way this still needs to be tested/reviewed patched or closed.

btw, I am looking at function install_tasks($install_state) in install.core.inc

tlyngej’s picture

Right, let's see if we can get it to fail in the hook_install_task() then. That should be easy enough.

frob’s picture

Title: hook_task fails silently if there is an error in a loop » hook_install_task fails silently if there is an error in a loop?
tlyngej’s picture

Tested this by adding the following to minimal.install

function minimal_install_tasks() {

  for ($i = 0; $i <= 10; $i ++) {
    $file = '/tmp/people.txt';
    // Open the file to get existing content
    $current = file_get_contents($file);
    // Append a new person to the file
    $current .= "John Smith $i\n";
    // Write the contents back to the file
    file_put_contents($file, $current);
  }
}

It ran just fine.

Then I appended fake_function_of_doom(); to for loop. Ran it again and got a:

Error: Call to undefined function fake_function_of_doom() in
/home/tlj/docker/drupal8/httpdocs/core/profiles/minimal/minimal.install, line 32

It does look like the issue has been fixed at some point over the last couple of years.

frob, what do you think?

frob’s picture

Status: Active » Fixed

Sounds fixed to me. Could you post the code that generated the error?

tlyngej’s picture

What I did to make the installation stall was just adding to the loop. Like this

function minimal_install_tasks() {

  for ($i = 0; $i <= 10; $i ++) {
    $file = '/tmp/people.txt';
    // Open the file to get existing content
    $current = file_get_contents($file);
    // Append a new person to the file
    $current .= "John Smith $i\n";
    // Write the contents back to the file
    file_put_contents($file, $current);
    fake_function_of_doom();
  }
}

Status: Fixed » Closed (fixed)

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