Skip to content

Commit d1e8a73

Browse files
committed
GitHub Issue facebookarchive#546: Received a fatal because mb_substr was not found.
Added logic to wrap the extension missing fatal error and ensured the mb_filter function is taken from PHP base namespace and not from the FB SDK namespace. Test running and succeeded: PHPUnit 4.8.21 by Sebastian Bergmann and contributors. ............................................................... 63 / 267 ( 23%) ............................................................... 126 / 267 ( 47%) ............................................................... 189 / 267 ( 70%) ............................................................... 252 / 267 ( 94%) ............... Time: 6.36 seconds, Memory: 12.00Mb OK (267 tests, 614 assertions)
1 parent bb1e618 commit d1e8a73

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Facebook/PseudoRandomString/PseudoRandomStringGeneratorTrait.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,15 @@ public function validateLength($length)
4848
*
4949
* @param string $binaryData The binary data to convert to hex.
5050
* @param int $length The length of the string to return.
51+
* @throws \RuntimeException Throws an exception when multibyte support is not enabled
5152
*
5253
* @return string
5354
*/
5455
public function binToHex($binaryData, $length)
5556
{
56-
return mb_substr(bin2hex($binaryData), 0, $length);
57+
if(true !== extension_loaded('mbstring')) {
58+
throw new \RuntimeException('Multibyte support required');
59+
}
60+
return \mb_substr(\bin2hex($binaryData), 0, $length);
5761
}
5862
}

0 commit comments

Comments
 (0)