From: Chuck Hagenbuch Date: Sat, 5 Dec 2009 04:51:58 +0000 (-0500) Subject: Clone Horde_Url objects in static methods. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=20ba9921f7b2d1a75f093bfac2aea6ee7798be0c;p=horde.git Clone Horde_Url objects in static methods. This avoids reference problems changing URLs as a result of later calls when we're building pieces of URLs repeatedly. This can lead to really bad behavior, like deletion of tasks in Nag when clicking what's supposed to be an edit link. --- diff --git a/framework/Util/lib/Horde/Util.php b/framework/Util/lib/Horde/Util.php index 29e0d95c3..6eaa734d3 100644 --- a/framework/Util/lib/Horde/Util.php +++ b/framework/Util/lib/Horde/Util.php @@ -235,8 +235,13 @@ class Horde_Util } if ($url instanceof Horde_Url) { - $url->raw = !$encode; - return $url->add($parameter, $value); + // In many places we re-use URLs assuming they are strings. With + // Horde_Url objects, this can lead to reference problems and URLs + // being mysteriously modified. For now, we have to clone any + // objects to avoid modifying them. + $url2 = clone($url); + $url2->raw = !$encode; + return $url2->add($parameter, $value); } $horde_url = new Horde_Url($url, !$encode); @@ -254,12 +259,16 @@ class Horde_Util */ static public function removeParameter($url, $remove) { - $horde_url = new Horde_Url($url); - if ($url instanceof Horde_Url) { - return $url->remove($remove); + // In many places we re-use URLs assuming they are strings. With + // Horde_Url objects, this can lead to reference problems and URLs + // being mysteriously modified. For now, we have to clone any + // objects to avoid modifying them. + $url2 = clone($url); + return $url2->remove($remove); } + $horde_url = new Horde_Url($url); return $horde_url->remove($remove); }