Browse Source

Merge branch 'SamMousa-10935-test-case'

batch-query-test
SilverFire - Dmitry Naumenko 9 years ago
parent
commit
b6cb1f58a9
  1. 1
      framework/CHANGELOG.md
  2. 7
      framework/web/UrlManager.php
  3. 20
      tests/framework/web/UrlManagerTest.php

1
framework/CHANGELOG.md

@ -8,6 +8,7 @@ Yii Framework 2 Change Log
- Bug #10850: Fixed unable to use 'definitions' and 'aliases' at `yii\widgets\MaskedInput` (rahimov, klimov-paul)
- Bug #10884: Fixed MessageFormatter for formatting messages when not all parameters are given (laxity7, cebe)
- Enh #10910: Fixed Captcha client side validation after image refresh, when controller is under module (silverfire)
- Bug #10935: Fixed cache key collision in `yii\web\UrlManager::createUrl()` (sammousa)
- Bug #10946: Fixed parameters binding to the SQL query in `yii\db\mysqlSchema::findConstraints()` (silverfire)
- Bug #10969: Fixed generator migration tool with decimal params in column (pana1990)
- Bug #10974: `yii.js` - fixed error in ajaxPrefilter event handler, caused by blocked frame (maximal)

7
framework/web/UrlManager.php

@ -315,7 +315,12 @@ class UrlManager extends Component
$baseUrl = $this->showScriptName || !$this->enablePrettyUrl ? $this->getScriptUrl() : $this->getBaseUrl();
if ($this->enablePrettyUrl) {
$cacheKey = $route . '?' . implode('&', array_keys($params));
$cacheKey = $route . '?';
foreach($params as $key => $value) {
if ($value !== null) {
$cacheKey .= $key . '&';
}
}
/* @var $rule UrlRule */
$url = false;

20
tests/framework/web/UrlManagerTest.php

@ -170,6 +170,26 @@ class UrlManagerTest extends TestCase
}
/**
* Issue #10935 - issue when one of rule params is null
* @see https://github.com/yiisoft/yii2/issues/10935
*/
public function testIssue10935() {
$manager = new UrlManager([
'rules' => [
'<param1>/<param2>' => 'site/index',
'<param1>' => 'site/index',
],
'enablePrettyUrl' => true,
'scriptUrl' => '/test',
]);
$this->assertEquals('/test/111', $manager->createUrl(['site/index', 'param1' => 111, 'param2' => null]));
$this->assertEquals('/test/111', $manager->createUrl(['site/index', 'param1' => 123, 'param2' => null]));
$this->assertEquals('/test/111/222', $manager->createUrl(['site/index', 'param1' => 111, 'param2' => 222]));
$this->assertEquals('/test/111/222', $manager->createUrl(['site/index', 'param1' => 112, 'param2' => 222]));
}
/**
* https://github.com/yiisoft/yii2/issues/6717
*/
public function testCreateUrlWithEmptyPattern()

Loading…
Cancel
Save