Problem/Motivation

Drush make recursion is a very powerful way to build a site, but it can also bring its own problems. If a makefile consists of many projects with makefiles (e.g. features) alongside normal modules, then the build process suddenly becomes a lot more complex:

Even if these specific problems were somehow resolved, there's clearly still an identifiable user need for preventing makefile recursion: while the default behaviour should clearly be as is currently the case, giving the drush user the option to prevent recursion will really help them make those decisions: after all, drush make offers the option to download without core; it doesn't merely assume that, as it's a straightforward job to pull the modules out of a Drupal core, that option isn't necessary.

Proposed resolution

Two parts:

The first option permit quite granular control, if you personally are able to control the "master" makefile; otherwise, or just if the user prefers, the second option permits switching off recursion across all projects. In addition, a 'no-recursion' option sits very well alongside no-cache, no-clean, no-core etc. so there's precedent for that.

Patch to follow in first comment, so that its naming convention will be correct.

Remaining tasks

Adding to the recursion unit tests (hopefully to follow). Brief explanation of the --no-recursion parameter (and the [do_recursion] option) are included in the initial patch.

User interface changes

The --no-recursion option has been added to the drush make command. Also, any users maintaining a makefile have the extra makefile option of adding projects[projectname][do_recursion] = 0 to any projects they don't want to have made recursively by drush make.

API changes

See above. All API changes are backwards-compatible: the behaviour of existing makefiles, with existing command-line options, should be unchanged.

Also linked inline above:

Comments

jp.stacey’s picture

Status: Active » Needs work
StatusFileSize
new1.93 KB

Patch attached without tests. It does the following:

  • includes @joelcollinsdc's patch
  • changes object attribute name to $this->do_recursion to avoid possible confusion with $this->recurse() method
  • Also looks at the --no-recursion command-line option
  • Adds brief documentation

Looking at the tests now.

jp.stacey’s picture

Unfortunately the existing testMakeRecursion test is broken in 7.x-5.x: see attached. So it's hard at the moment to write a test. I'll see if I can patch against 7.x-5.9 and write a test on that basis for now.

jp.stacey’s picture

Status: Needs work » Needs review
StatusFileSize
new2.78 KB

OK, this patch contains both code changes and tests. It was written against a fork off 7.x-5.9, as the tests won't currently succeed on 7.x-5.x . But it should also successfully patch 7.x-5.x when the tests there start working, as the hunk offsets aren't much different.

jhedstrom’s picture

re #2 tests in the 5.x branch should now work (there was an issue with the commit from #1454534: Invalid argument supplied for foreach() wget.inc:42 fixed last week that I didn't realize needed a port to 5.x.

jp.stacey’s picture

@jhedstrom nice, thanks. I can confirm that the patch works against 5.x and that the two unit tests work too. I'd appreciate some more eyes on this!

jhedstrom’s picture

Status: Needs review » Needs work
+++ commands/make/make.project.incundefined
@@ -455,6 +460,11 @@ class DrushMakeProject {
+    if (!$this->do_recursion || drush_get_option('no-recursion')) {
+      drush_log(dt("Preventing recursive makefile parsing for !project",
+                array("!project" => $this->name)), 'notice');
+      return FALSE;

I don't think this should return FALSE, since that will cause the code in the make() method to also return FALSE, which may have unintended consequences. It should either return NULL (which would require the code in the make() method be changed to account for that), or return TRUE

Aside from that, tests are passing, and it looks good to me.

jp.stacey’s picture

Status: Needs work » Needs review
StatusFileSize
new2.78 KB

On reflection I agree. Given the user or their makefile has stated what should happen, then there are no unexpected circumstances occurring in the function that we need to raise a warning about (like e.g. the makefile not validating, which does return FALSE.)

Also, all other successful completions of the function return TRUE. As there's no situation in which the current code ever returns NULL, I think TRUE is best in this case too.

Patch re-rolled and attached.

zerolab’s picture

Confirming tests passing. And the patch looks good.

+1

dave reid’s picture

greg.1.anderson’s picture

Status: Needs review » Closed (duplicate)

Marking as closed (duplicate) per #9.

greg.1.anderson’s picture

Issue summary: View changes

Changed [recurse] to [do_recursion] to avoid potential slight confusion with the recurse() method on the project object