MDL-55272 lib: Allow random_bytes() to return large values.

PHP has a recursion limit and random_bytes on PHP5.6 without openssl
will error if sent a large value.  Using a loop has lower overhead than
recursion as well.
This commit is contained in:
Russell Smith
2016-08-16 12:15:04 +10:00
parent bba74ca5ce
commit ffd1a26a0b
2 changed files with 9 additions and 6 deletions
+3
View File
@@ -3047,6 +3047,9 @@ class core_moodlelib_testcase extends advanced_testcase {
$result = random_bytes_emulate(666);
$this->assertSame(666, strlen($result));
$result = random_bytes_emulate(40);
$this->assertSame(40, strlen($result));
$this->assertDebuggingNotCalled();
$result = random_bytes_emulate(0);