Error: Call-time pass-by-reference has been removed in path/to/sites/all/themes/boilerplate/boilerplate.drush.inc, line 92

It's in this line:
$custom = str_replace('/contrib/', '/custom/', $newtheme_path, &$count);

Introduced in this commit (16-Jan-2013):
http://drupalcode.org/project/boilerplate.git/commitdiff/b2c1b3bb5266c3c...

The first issue here is that the developer must be running PHP with a low error reporting setting or running a very old version of PHP. Call-time pass-by-reference has been deprecated for a long time, as of PHP 5.3 (June 2009!) it raises a warning and as of PHP 5.4 (March 2012) it raises a fatal error.
http://php.net/manual/en/language.references.pass.php

This means that you really can't use this parameter in a str_replace anymore. So you can test for the string with strpos and then do the replace if it works. Should be the same result (untested code - I'm being told it's late and I need to quit!)

  if (strpos('/contrib/', $newtheme_path,) and is_dir(preg_replace('|/[^/]+$|', '', $custom))) {
    $newtheme_path = str_replace('/contrib/', '/custom/', $newtheme_path);
  }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ergophobe’s picture

Assigned: Unassigned » ergophobe
Status: Active » Needs review
FileSize
832 bytes

Here's a simple patch using the code in my initial comment.

Note that I have only done the most rudimentary testing. I don't use the /custom dir so I didn't test it. All I've tested is that I can now run

drush en boilerplate

without a fatal error.

twardnw’s picture

Status: Needs review » Fixed

Thanks for pointing this out (and the initial patch).

I've gone a little different direction with this now though, a bit simpler method to check where to put the theme. Pull the latest from git and take a look ;)

ergophobe’s picture

Looks good! I always try to make the smallest number of changes to someone else's code, but yeah, that's better than the preg_replace() solution.

Anyway, thanks for staying on it!

Status: Fixed » Closed (fixed)

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

theamoeba’s picture

+1

michaelmallett’s picture

Can you submit this as a patch please twardnw?

michaelmallett’s picture

Status: Closed (fixed) » Needs work

I tried to use the patch for the issue from git and I still get the error from line 80 and 103
$custom = str_replace('/contrib/', '/custom/', $newtheme_path, &$count);

apprentia’s picture

Issue summary: View changes

I've built a number of sites with boilerplate but I am encountering this for the first time.
A drush status prior to the error gives this information :
Drupal version : 7.26
Drush version : 6.2.0
PHP configuration : php5.5.3

I'm using the 7.x-1.9 of boilerplate. and I'm getting this error whenever I try to drush in the project. (not getting the error in other projects that don"t have boilerplate)

"Error: Call-time pass-by-reference has been removed in /boilerplate.drush.inc, line 92"

Could this be something to do with the vesion of PHP that I'm running?

in #2 twardnw "Pull the latest from git and take a look ;)", isn't that what i did when I got the last version of the theme?

I'm a little bit lost as to what i should do... can you please clarify it for me?

theamoeba’s picture

Why is this still an issue in 2014?

grendzy’s picture

Assigned: ergophobe » Unassigned
Status: Needs work » Closed (fixed)

This was fixed in http://cgit.drupalcode.org/boilerplate/commit/?id=a1aac65. The fix will be in the next release.