I cloned the latest 6.x-3.x branch and suddenly everything stopped working. Trying to make any make file produced the following error:

Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Unsupported operand types in
/Users/i4veritas/.drush/drush_make/drush_make.drush.inc, line 180

Debug and verbose:

Undefined variable: build_path drush_make.drush.inc:174 [8.45 sec,      [notice]
4.01 MB]
Object of class DrushMakeParserObject could not be converted to int     [notice]
drush_make.drush.inc:180 [8.45 sec, 4.01 MB]
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Unsupported operand types in
/Users/i4veritas/.drush/drush_make/drush_make.drush.inc, line 180
[8.55 sec, 4.01 MB]

Since a checkout of this branch was working a few weeks a go I ran a git bisect and identified the offending commit:
4678d7fd6d6a3ef2eeb90e2449e795f49661357a by Dimitri on August 7th

CommentFileSizeAuthor
#3 0001-Issue-1248686-by-ao2-Error-Unsupported-operand-types.patch3.55 KBao2
#1 missing_build_path.jpg84.44 KBAnonymous (not verified)

Comments

Anonymous’s picture

StatusFileSize
new84.44 KB

The undefined variable notice is due because the function signature of drush_make_projects() has changed. It no longer takes $build_path, but that variable is used later in the project array.

ao2’s picture

Priority: Normal » Critical

I think the problem is not related to the missing $build_type, this is just a notice:

Undefined variable: build_path drush_make.drush.inc:174 [0.13 sec, 8.24MB]    [notice]

and could be fixed with:

diff --git a/drush_make.drush.inc b/drush_make.drush.inc
index 4da221f..e0ee9a5 100644
--- a/drush_make.drush.inc
+++ b/drush_make.drush.inc
@@ -166,6 +166,7 @@ function drush_make_projects($recursion, $contrib_destination, $info) {
     }
   }
   $ignore_checksums = drush_get_option('ignore-checksums');
+  $build_path = drush_get_context('drush_make_build_path');
   foreach ($info['projects'] as $key => $project) {
     // Merge the known data onto the project info.
     $project += array(

The real problem is that, since commit 4678d7f, each $project in $info['projects'] is not an array anymore, but an object of type DrushMakeParserObject (which extends ArrayObject, something different from the base array() type) and then the union operator ($project += array(...);) is not defined (Unsupported operand types).

I tried with something like:

diff --git a/drush_make.drush.inc b/drush_make.drush.inc
index 4da221f..53a5028 100644
--- a/drush_make.drush.inc
+++ b/drush_make.drush.inc
@@ -166,9 +166,10 @@ function drush_make_projects($recursion, $contrib_destination, $info) {
     }
   }
   $ignore_checksums = drush_get_option('ignore-checksums');
+  $build_path = drush_get_context('drush_make_build_path');
   foreach ($info['projects'] as $key => $project) {
     // Merge the known data onto the project info.
-    $project += array(
+    $project->merge(array(
       'name'                => $key,
       'core'                => $info['core'],
       'build_path'          => $build_path,
@@ -177,7 +178,7 @@ function drush_make_projects($recursion, $contrib_destination, $info) {
       'location'            => drush_get_option('drush-make-update-default-url'),
       'subdir'              => '',
       'directory_name'      => (isset($project['type']) && $project['type'] == 'library' ? $key : ''),
-    );
+    ));

     if ($project['location'] != 'http://updates.drupal.org/release-history' && !isset($project['type'])) {
       $project = drush_make_updatexml($project);
diff --git a/drush_make.parser.inc b/drush_make.parser.inc
index 2277e7d..fac01d6 100644
--- a/drush_make.parser.inc
+++ b/drush_make.parser.inc
@@ -418,6 +418,13 @@ class DrushMakeParserObject extends ArrayObject {
       $current = $value;
     }
   }
+
+   function merge($array) {
+    if (is_array($array)) {
+      $this->store += $array;
+    }
+  }
+
   function __toString() {
     if (is_string($this->store)) {
       return $this->store;

But this is still not enough to make drush make working again...

@dmitrig01, in future please make sure the repository is in a working state before you push (ideally one should try to keep the code functional even after every commit for rebase to be really effective).

Thanks,
Antonio

ao2’s picture

Status: Active » Needs review
Issue tags: ++patch
StatusFileSize
new3.55 KB

The attached patch should fix the issue, we have also to convert from DrushMakeParserObject to an actual array before iterating over the projects.

diff --git a/drush_make.project.inc b/drush_make.project.inc
index b753fa0..10c1323 100644
--- a/drush_make.project.inc
+++ b/drush_make.project.inc
@@ -8,8 +8,9 @@ class DrushMakeProject {
    * Set attributes and retrieve project information.
    */
   function __construct($project) {
-    $project['base_contrib_destination'] = $project['contrib_destination'];
-    foreach ($project as $key => $value) {
+    $project_array = $project->toValue();
+    $project_array['base_contrib_destination'] = $project_array['contrib_destination'];
+    foreach ($project_array as $key => $value) {
       $this->{$key} = $value;
     }
   }

@dmitrig01 if you take it, please use git-am so I get in the history as the author, thanks.

BTW, I have some more patches stacked in my local tree for 6.x-3.x, I'd like to talk about them sometimes.

Regards,
Antonio

jhedstrom’s picture

This fixes the issue of the fatal error, and seems to work with both Drush 4 and Drush 5.

matason’s picture

Status: Needs review » Reviewed & tested by the community

I was experiencing the fatal error, the patch on #4 fixed it, thanks @ao2

tim.plunkett’s picture

Issue tags: -+patch

Always nice to find a working patch when you hit a bug.

mrfelton’s picture

Can confirm that this resolves the issue.

geek-merlin’s picture

This patch made my day! THX!

drzraf’s picture

patch from comment #3 fixed it

webchick’s picture

Also confirming fix.

helmo’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

[ Powered by #1115636: Issue Macros and Templates - Drush Make]

Drush make is being merged into drush core (discussed in issue:#1310130: Put drush make in drush core)
This means that the issue queue is also moving. The Drush project has a component called 'Make' for this purpose.

We would like to take this opportunity to leave behind old/obsolete issues, allowing us to focus on a stable make command in core. E.g. one of the major tasks ahead is making more use of the Drush core code for handling downloads and decompression.

If you feel that this issue is still relevant, feel free to re-open and move it to the Drush queue.

More information will be posted on the drush_make and drush project pages.