Skip to content

Commit ff79ced

Browse files
author
Cari Spruiell
committed
Merge remote-tracking branch 'remotes/api/MAGETWO-44728-HHVM-Cant-create-admin-role-Given-encoding-not-supported-on-this-OS' into API-Bug-PR
2 parents 7fc2956 + 94e0368 commit ff79ced

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lib/internal/Magento/Framework/Validator/StringLength.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,35 @@ class StringLength extends \Zend_Validate_StringLength implements \Magento\Frame
1313
* @var string
1414
*/
1515
protected $_encoding = 'UTF-8';
16+
17+
/**
18+
* {@inheritdoc}
19+
*/
20+
public function setEncoding($encoding = null)
21+
{
22+
if ($encoding !== null) {
23+
$orig = PHP_VERSION_ID < 50600
24+
? iconv_get_encoding('internal_encoding')
25+
: ini_get('default_charset');
26+
if (PHP_VERSION_ID < 50600) {
27+
$result = iconv_set_encoding('internal_encoding', $encoding);
28+
} else {
29+
ini_set('default_charset', $encoding);
30+
$result = ini_get('default_charset');
31+
}
32+
if (!$result) {
33+
#require_once 'Zend/Validate/Exception.php';
34+
throw new Zend_Validate_Exception('Given encoding not supported on this OS!');
35+
}
36+
37+
if (PHP_VERSION_ID < 50600) {
38+
iconv_set_encoding('internal_encoding', $orig);
39+
} else {
40+
ini_set('default_charset', $orig);
41+
}
42+
}
43+
44+
$this->_encoding = $encoding;
45+
return $this;
46+
}
1647
}

0 commit comments

Comments
 (0)