From 6bdcd9266c0d61eca6a30fc00fab1ae5e01cbe66 Mon Sep 17 00:00:00 2001 From: Sandy Pleyte Date: Tue, 18 Feb 2014 10:38:13 +0100 Subject: [PATCH] Fixed #2601, the callback functions expect param 1 to be a reference to the $config --- src/Composer/Config/JsonConfigSource.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Composer/Config/JsonConfigSource.php b/src/Composer/Config/JsonConfigSource.php index 5223eb5d2..506be613e 100644 --- a/src/Composer/Config/JsonConfigSource.php +++ b/src/Composer/Config/JsonConfigSource.php @@ -23,8 +23,10 @@ use Composer\Json\JsonManipulator; */ class JsonConfigSource implements ConfigSourceInterface { + /** + * @var \Composer\Json\JsonFile + */ private $file; - private $manipulator; /** * Constructor @@ -118,7 +120,7 @@ class JsonConfigSource implements ConfigSourceInterface } else { // on failed clean update, call the fallback and rewrite the whole file $config = $this->file->read(); - array_unshift($args, $config); + $this->array_unshift_ref($args, $config); call_user_func_array($fallback, $args); $this->file->write($config); } @@ -127,4 +129,18 @@ class JsonConfigSource implements ConfigSourceInterface @chmod($this->file->getPath(), 0600); } } + + /** + * Prepend a reference to an element to the beginning of an array. + * + * @param array $array array + * @param mixed $value mixed + * @return array + */ + function array_unshift_ref(&$array, &$value) + { + $return = array_unshift($array, ''); + $array[0] =& $value; + return $return; + } }