Skip to content

Commit 7581067

Browse files
committed
Merge pull request #9 from LExpress/upstream-1.4.19
Apply patches from symfony 1.4.19
2 parents b5eb093 + 89b4da3 commit 7581067

File tree

6 files changed

+23
-15
lines changed

6 files changed

+23
-15
lines changed

lib/controller/sfController.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ public function setRenderMode($mode)
489489
*/
490490
public function inCLI()
491491
{
492-
return 0 == strncasecmp(PHP_SAPI, 'cli', 3);
492+
return 'cli' == PHP_SAPI;
493493
}
494494

495495
/**

lib/database/sfPDODatabase.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@ public function shutdown()
109109
*/
110110
public function __call($method, $arguments)
111111
{
112-
return $this->getConnection()->$method($arguments);
112+
return call_user_func_array(array($this->getConnection(), $method), $arguments);
113113
}
114114
}

lib/exception/sfException.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,9 @@ static protected function outputStackTrace(Exception $exception)
195195
}
196196
}
197197

198-
// when using CLI, we force the format to be TXT
199-
if (0 == strncasecmp(PHP_SAPI, 'cli', 3))
198+
// when using CLI, we force the format to be TXT. Compare exactly to
199+
// the string 'cli' because the php 5.4 server is identified by 'cli-server'
200+
if ('cli' == PHP_SAPI)
200201
{
201202
$format = 'txt';
202203
}

lib/request/sfWebRequest.class.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -660,28 +660,34 @@ public function setRelativeUrlRoot($value)
660660
public function splitHttpAcceptHeader($header)
661661
{
662662
$values = array();
663+
$groups = array();
663664
foreach (array_filter(explode(',', $header)) as $value)
664665
{
665666
// Cut off any q-value that might come after a semi-colon
666667
if ($pos = strpos($value, ';'))
667668
{
668-
$q = (float) trim(substr($value, strpos($value, '=') + 1));
669+
$q = trim(substr($value, strpos($value, '=') + 1));
669670
$value = substr($value, 0, $pos);
670671
}
671672
else
672673
{
673674
$q = 1;
674675
}
675676

676-
if (0 < $q)
677-
{
678-
$values[trim($value)] = $q;
679-
}
677+
$groups[$q][] = $value;
680678
}
681679

682-
arsort($values);
680+
krsort($groups);
681+
682+
foreach ($groups as $q => $items) {
683+
if (0 < $q) {
684+
foreach ($items as $value) {
685+
$values[] = trim($value);
686+
}
687+
}
688+
}
683689

684-
return array_keys($values);
690+
return $values;
685691
}
686692

687693
/**

lib/storage/sfPDOSessionStorage.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function sessionRead($id)
115115
$sessionRows = $stmt->fetchAll(PDO::FETCH_NUM);
116116
if (count($sessionRows) == 1)
117117
{
118-
return $sessionRows[0][0];
118+
return is_resource($sessionRows[0][0]) ? stream_get_contents($sessionRows[0][0]) : $sessionRows[0][0];
119119
}
120120
else
121121
{

test/unit/request/sfWebRequestTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

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

13-
$t = new lime_test(108);
13+
$t = new lime_test(109);
1414

1515
class myRequest extends sfWebRequest
1616
{
@@ -121,15 +121,16 @@ public function resetPathInfoArray()
121121

122122
$request->acceptableContentTypes = null;
123123
$_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xhtml+xml,application/xml,text/html;q=0.9,text/plain;q=0.8,*/*;q=0.5';
124-
$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');
124+
$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');
125125

126126
// ->splitHttpAcceptHeader()
127127
$t->diag('->splitHttpAcceptHeader()');
128128

129129
$t->is($request->splitHttpAcceptHeader(''), array(), '->splitHttpAcceptHeader() returns an empty array if the header is empty');
130-
$t->is($request->splitHttpAcceptHeader('a,b,c'), array('c', 'b', 'a'), '->splitHttpAcceptHeader() returns an array of values');
130+
$t->is($request->splitHttpAcceptHeader('a,b,c'), array('a', 'b', 'c'), '->splitHttpAcceptHeader() returns an array of values');
131131
$t->is($request->splitHttpAcceptHeader('a,b;q=0.7,c;q=0.3'), array('a', 'b', 'c'), '->splitHttpAcceptHeader() strips the q value');
132132
$t->is($request->splitHttpAcceptHeader('a;q=0.1,b,c;q=0.3'), array('b', 'c', 'a'), '->splitHttpAcceptHeader() sorts values by the q value');
133+
$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');
133134
$t->is($request->splitHttpAcceptHeader('a; q=0.1, b, c; q=0.3'), array('b', 'c', 'a'), '->splitHttpAcceptHeader() trims whitespaces');
134135
$t->is($request->splitHttpAcceptHeader('a; q=0, b'), array('b'), '->splitHttpAcceptHeader() removes values when q = 0 (as per the RFC)');
135136

0 commit comments

Comments
 (0)