Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit d3b8a27

Browse files
committed
Fixes Zend_Validate_StringLength::setEncoding() with ini_set
Closes zendframework#634
1 parent 202c1b3 commit d3b8a27

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

library/Zend/Validate/StringLength.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ public function setEncoding($encoding = null)
205205
if (PHP_VERSION_ID < 50600) {
206206
$result = iconv_set_encoding('internal_encoding', $encoding);
207207
} else {
208-
$result = ini_set('default_charset', $encoding);
208+
ini_set('default_charset', $encoding);
209+
$result = ini_get('default_charset');
209210
}
210211
if (!$result) {
211212
require_once 'Zend/Validate/Exception.php';

tests/Zend/Validate/StringLengthTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ public function testDifferentEncodingWithValidator()
178178
$this->assertEquals('ISO-8859-1', $validator->getEncoding());
179179
}
180180

181+
/**
182+
* @expectedException Zend_Validate_Exception
183+
* @group GH-634
184+
*/
185+
public function testWrongEncoding()
186+
{
187+
$this->_validator->setEncoding('');
188+
}
189+
181190
/**
182191
* @ZF-4352
183192
*/

0 commit comments

Comments
 (0)