mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Fix header collection from array (#18883)
* Fixed HeaderCollection::fromArray() key case * Added CHANGELOG.md line for #18883 (Fixed HeaderCollection::fromArray() key case)
This commit is contained in:
@ -17,6 +17,7 @@ Yii Framework 2 Change Log
|
||||
- Bug #18842: Fix `yii\base\Controller::bindInjectedParams()` to not throw error when argument of `ReflectionUnionType` type is passed (bizley)
|
||||
- Enh #18858: Reduce memory usage in `yii\base\View::afterRender` method (LeoOnTheEarth)
|
||||
- Bug #18880: Fix `yii\helpers\ArrayHelper::toArray()` for `DateTime` objects in PHP >= 7.4 (rhertogh)
|
||||
- Bug #18883: Fix `yii\web\HeaderCollection::fromArray()` now ensures lower case keys (rhertogh)
|
||||
|
||||
|
||||
2.0.43 August 09, 2021
|
||||
|
@ -180,7 +180,7 @@ class HeaderCollection extends BaseObject implements \IteratorAggregate, \ArrayA
|
||||
*/
|
||||
public function fromArray(array $array)
|
||||
{
|
||||
$this->_headers = $array;
|
||||
$this->_headers = array_change_key_case($array, CASE_LOWER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
27
tests/framework/web/HeaderCollectionTest.php
Normal file
27
tests/framework/web/HeaderCollectionTest.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace yiiunit\framework\web;
|
||||
|
||||
use yii\web\HeaderCollection;
|
||||
use yiiunit\TestCase;
|
||||
|
||||
/**
|
||||
* @group web
|
||||
*/
|
||||
class HeaderCollectionTest extends TestCase
|
||||
{
|
||||
public function testFromArray()
|
||||
{
|
||||
$headerCollection = new HeaderCollection();
|
||||
$location = 'my-test-location';
|
||||
$headerCollection->fromArray([
|
||||
'Location' => [$location],
|
||||
]);
|
||||
$this->assertEquals($location, $headerCollection->get('Location'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user