Phutil is not yet loaded during preamble, so we can't use it.
This change fixes a regression introduced here, fixing PHP 8.1 support:
rP96ae4ba13acb: PHP 8.1: fixes for strlen() not accepting NULL anymore, part 2
Ref T15064
Differential D25114
Fix preamble-support avivey on Apr 7 2023, 10:25. Authored by
Details
Phutil is not yet loaded during preamble, so we can't use it. This change fixes a regression introduced here, fixing PHP 8.1 support: rP96ae4ba13acb: PHP 8.1: fixes for strlen() not accepting NULL anymore, part 2 Ref T15064 Included test script.
Diff Detail
Event Timeline
Comment Actions Hi @avivey thanks for this fix in my regression. Feel free to update this to just negate the if and make it correct, or here there is a quick fix ready to be accepted: D25119: Fix regression in preamble (I've done that just in order to be nice and don't bother you with additional fatigue for my regression. So, if you have time just continue here, or move to D25119) Comment Actions Since the bug you found was major, and my tests didn't catch it, I'm going to do another round of more in-depth testing for this...
Comment Actions Added a test-script to check all possible inputs. It's not run automatically, because this isn't part of the main code. Anyway, turns out that $forwarded_for in line 23 is never null, because "isset() will return false when checking a variable that has been assigned to null." (https://www.php.net/manual/en/function.isset); so strlen is fine here. Comment Actions Thank you for this fix and for the tests I still recommend this: if(!is_string($forwarded_for) || $forwarded_for === '') { In order to exclude non-strings, non empty strings, and with O(1) complexity instead of O(N) or something depending on the length of the string, so that we minimize CPU cycles and Greta Thunberg goes like "wooooow Phorge"
|