فهرست منبع

ZF-9179: honor "default" param of _getParam()

- Applied patch from Martin Hujer, fixing issue

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22792 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 15 سال پیش
والد
کامیت
d86d78814a
2فایلهای تغییر یافته به همراه10 افزوده شده و 1 حذف شده
  1. 1 1
      library/Zend/Controller/Action.php
  2. 9 0
      tests/Zend/Controller/ActionTest.php

+ 1 - 1
library/Zend/Controller/Action.php

@@ -580,7 +580,7 @@ abstract class Zend_Controller_Action implements Zend_Controller_Action_Interfac
     protected function _getParam($paramName, $default = null)
     {
         $value = $this->getRequest()->getParam($paramName);
-        if ((null === $value) && (null !== $default)) {
+		 if ((null === $value || '' === $value) && (null !== $default)) {
             $value = $default;
         }
 

+ 9 - 0
tests/Zend/Controller/ActionTest.php

@@ -245,6 +245,15 @@ class Zend_Controller_ActionTest extends PHPUnit_Framework_TestCase
         $this->assertEquals(0, $this->_controller->getParam('bar', -1));
         $this->assertEquals(-1, $this->_controller->getParam('baz', -1));
     }
+	
+	/**
+     * @group ZF-9179
+     */
+	public function testGetParamForEmptyString()
+	{
+		$this->_controller->setParam('lang', '');
+		$this->assertEquals('en', $this->_controller->getParam('lang', 'en'));
+	}
 
     public function testGetParams()
     {