mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing RequestHandlerComponent::prefers() with array input. Test case updated. Fixes #6290
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8141 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
225e5e6aa8
commit
97652231a0
2 changed files with 7 additions and 1 deletions
|
@ -524,6 +524,7 @@ class RequestHandlerComponent extends Object {
|
|||
return $this->ext;
|
||||
}
|
||||
|
||||
$types = $type;
|
||||
if (is_string($type)) {
|
||||
$types = array($type);
|
||||
}
|
||||
|
@ -550,7 +551,11 @@ class RequestHandlerComponent extends Object {
|
|||
return $accepts[0];
|
||||
}
|
||||
|
||||
$accepts = array_intersect($this->__acceptTypes, $accepts);
|
||||
$acceptedTypes = array();
|
||||
foreach ($this->__acceptTypes as $type) {
|
||||
$acceptedTypes[] = $this->mapType($type);
|
||||
}
|
||||
$accepts = array_intersect($acceptedTypes, $accepts);
|
||||
return $accepts[0];
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -416,6 +416,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
$this->RequestHandler->ext = 'rss';
|
||||
$this->assertEqual($this->RequestHandler->prefers(), 'rss');
|
||||
$this->assertFalse($this->RequestHandler->prefers('xml'));
|
||||
$this->assertEqual($this->RequestHandler->prefers(array('js', 'xml', 'xhtml')), 'xml');
|
||||
$this->assertTrue($this->RequestHandler->accepts('xml'));
|
||||
|
||||
$_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
|
||||
|
|
Loading…
Reference in a new issue