Skip to content

Commit

Permalink
JApplicationWeb::setHeader behavior
Browse files Browse the repository at this point in the history
Fix Travis CI error regarding invalid foreach
  • Loading branch information
stutteringp0et committed Apr 10, 2016
1 parent f2ead45 commit 95a7029
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions libraries/joomla/application/web.php
Expand Up @@ -626,11 +626,14 @@ public function setHeader($name, $value, $replace = false)
$value = (string) $value;

// create an array of names to search for duplicates
$names = array();
foreach($this->response->headers as $key=>$header) {
$names[$key]=$header['name'];
$key = false;
if(count($this->response->headers)) {
$names = array();
foreach($this->response->headers as $key=>$header) {
$names[$key]=$header['name'];
}
$key = array_search($name,$names); // find existing headers by name
}
$key = array_search($name,$names); // find existing headers by name
if($key !== false && $replace || $key === false) { // found & replace or not found
if($key !== false) { // remove before insert when header is found
unset($this->response->headers[$key]);
Expand Down

0 comments on commit 95a7029

Please sign in to comment.