From 5e62f870779b50d1b8624874d8ae54c6b0fd58c8 Mon Sep 17 00:00:00 2001 From: Patrik Karisch Date: Wed, 10 Jul 2013 23:52:37 +0200 Subject: [PATCH] fixed behavior on setFlag() --- src/Fetch/Server.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Fetch/Server.php b/src/Fetch/Server.php index e009168..9b08fad 100644 --- a/src/Fetch/Server.php +++ b/src/Fetch/Server.php @@ -179,21 +179,27 @@ class Server return; if (isset(self::$exclusiveFlags[$flag])) { - $kill = $flag; + $kill = self::$exclusiveFlags[$flag]; } elseif ($index = array_search($flag, self::$exclusiveFlags)) { $kill = $index; } - if (isset($kill) && isset($this->flags[$kill])) - unset($this->flags[$kill]); + if (isset($kill) && false !== $index = array_search($kill, $this->flags)) + unset($this->flags[$index]); + $index = array_search($flag, $this->flags); if (isset($value) && $value !== true) { - if ($value == false) { - unset($this->flags[$flag]); - } else { - $this->flags[] = $flag . '=' . $value; + if ($value == false && $index !== false) { + unset($this->flags[$index]); + } elseif ($value != false) { + $match = preg_grep('/' . $flag . '/', $this->flags); + if (reset($match)) { + $this->flags[key($match)] = $flag . '=' . $value; + } else { + $this->flags[] = $flag . '=' . $value; + } } - } else { + } elseif ($index === false) { $this->flags[] = $flag; } }