Page MenuHomePhabricator

[Wilds] Use "random_bytes()" if it is available (after PHP7)
ClosedPublic

Authored by epriestley on Oct 2 2018, 6:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 24, 1:43 AM
Unknown Object (File)
Thu, Nov 21, 5:11 PM
Unknown Object (File)
Sat, Nov 16, 7:41 PM
Unknown Object (File)
Fri, Nov 8, 4:55 PM
Unknown Object (File)
Thu, Oct 31, 6:40 AM
Unknown Object (File)
Oct 22 2024, 9:39 AM
Unknown Object (File)
Oct 19 2024, 9:47 PM
Unknown Object (File)
Oct 18 2024, 6:33 PM
Subscribers
None

Details

Summary

Ref T13209. In PHP7 and newer, the function random_bytes() gives us simple access to cryptographic randomness across platforms. Prefer it if it's available.

Notably, the other sources often aren't available on Windows, and particularly aren't available on a clean/default install with modern software versions. So the major motivation is to make things work better out-of-the-box on Windows.

Test Plan

On Windows, saw Filesystem unit tests which call readRandomBytes() now pass.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Oct 2 2018, 6:08 PM
Harbormaster failed remote builds in B20977: Diff 47135!
epriestley updated this revision to Diff 47136.
  • More correct fix for error message.
epriestley added inline comments.
src/filesystem/Filesystem.php
484

This just printed "s", not "%s".

(Since I think it's unlikely that we'll ever have untrusted, non-technical translators work with this codebase I'm generally inclined to think we should just embed strings like this in the text rather than parameterize them. Embedded strings are simpler for us to work with, avoid mistakes like this one, and it seems unlikely that a translator would incorrectly translate this string into another language by mistake.)

This revision is now accepted and ready to land.Oct 2 2018, 7:20 PM
This revision was automatically updated to reflect the committed changes.