Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/controller/sfController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public function setRenderMode($mode)
*/
public function inCLI()
{
return 0 == strncasecmp(PHP_SAPI, 'cli', 3);
return 'cli' == PHP_SAPI;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/database/sfPDODatabase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,6 @@ public function shutdown()
*/
public function __call($method, $arguments)
{
return $this->getConnection()->$method($arguments);
return call_user_func_array(array($this->getConnection(), $method), $arguments);
}
}
5 changes: 3 additions & 2 deletions lib/exception/sfException.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ static protected function outputStackTrace(Exception $exception)
}
}

// when using CLI, we force the format to be TXT
if (0 == strncasecmp(PHP_SAPI, 'cli', 3))
// when using CLI, we force the format to be TXT. Compare exactly to
// the string 'cli' because the php 5.4 server is identified by 'cli-server'
if ('cli' == PHP_SAPI)
{
$format = 'txt';
}
Expand Down
20 changes: 13 additions & 7 deletions lib/request/sfWebRequest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,28 +660,34 @@ public function setRelativeUrlRoot($value)
public function splitHttpAcceptHeader($header)
{
$values = array();
$groups = array();
foreach (array_filter(explode(',', $header)) as $value)
{
// Cut off any q-value that might come after a semi-colon
if ($pos = strpos($value, ';'))
{
$q = (float) trim(substr($value, strpos($value, '=') + 1));
$q = trim(substr($value, strpos($value, '=') + 1));
$value = substr($value, 0, $pos);
}
else
{
$q = 1;
}

if (0 < $q)
{
$values[trim($value)] = $q;
}
$groups[$q][] = $value;
}

arsort($values);
krsort($groups);

foreach ($groups as $q => $items) {
if (0 < $q) {
foreach ($items as $value) {
$values[] = trim($value);
}
}
}

return array_keys($values);
return $values;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/storage/sfPDOSessionStorage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function sessionRead($id)
$sessionRows = $stmt->fetchAll(PDO::FETCH_NUM);
if (count($sessionRows) == 1)
{
return $sessionRows[0][0];
return is_resource($sessionRows[0][0]) ? stream_get_contents($sessionRows[0][0]) : $sessionRows[0][0];
}
else
{
Expand Down
7 changes: 4 additions & 3 deletions test/unit/request/sfWebRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

require_once(dirname(__FILE__).'/../../bootstrap/unit.php');

$t = new lime_test(108);
$t = new lime_test(109);

class myRequest extends sfWebRequest
{
Expand Down Expand Up @@ -121,15 +121,16 @@ public function resetPathInfoArray()

$request->acceptableContentTypes = null;
$_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xhtml+xml,application/xml,text/html;q=0.9,text/plain;q=0.8,*/*;q=0.5';
$t->is($request->getAcceptableContentTypes(), array('text/xml', 'application/xml', 'application/xhtml+xml', 'text/html', 'text/plain', '*/*'), '->getAcceptableContentTypes() returns an array with all accepted content types');
$t->is($request->getAcceptableContentTypes(), array('text/xml', 'application/xhtml+xml', 'application/xml', 'text/html', 'text/plain', '*/*'), '->getAcceptableContentTypes() returns an array with all accepted content types');

// ->splitHttpAcceptHeader()
$t->diag('->splitHttpAcceptHeader()');

$t->is($request->splitHttpAcceptHeader(''), array(), '->splitHttpAcceptHeader() returns an empty array if the header is empty');
$t->is($request->splitHttpAcceptHeader('a,b,c'), array('c', 'b', 'a'), '->splitHttpAcceptHeader() returns an array of values');
$t->is($request->splitHttpAcceptHeader('a,b,c'), array('a', 'b', 'c'), '->splitHttpAcceptHeader() returns an array of values');
$t->is($request->splitHttpAcceptHeader('a,b;q=0.7,c;q=0.3'), array('a', 'b', 'c'), '->splitHttpAcceptHeader() strips the q value');
$t->is($request->splitHttpAcceptHeader('a;q=0.1,b,c;q=0.3'), array('b', 'c', 'a'), '->splitHttpAcceptHeader() sorts values by the q value');
$t->is($request->splitHttpAcceptHeader('a;q=0.3,b,c;q=0.3'), array('b', 'a', 'c'), '->splitHttpAcceptHeader() sorts values by the q value including equal values');
$t->is($request->splitHttpAcceptHeader('a; q=0.1, b, c; q=0.3'), array('b', 'c', 'a'), '->splitHttpAcceptHeader() trims whitespaces');
$t->is($request->splitHttpAcceptHeader('a; q=0, b'), array('b'), '->splitHttpAcceptHeader() removes values when q = 0 (as per the RFC)');

Expand Down