Skip to content

Commit aacad2c

Browse files
Jiaming Youmeta-codesync[bot]
authored andcommitted
Fixed passing null to strpos/strrpos/substr etc
Summary: in PHP 8.1+, passing null to strpos/strrpos/substr etc. emits deprecation warnings, and PHP 9 will make this a fatal error. If this SDK ever targets PHP 9+, you'd want a guard Per PHP version: PHP 8.0: silent coercion (null → ""), returns false. No warning. PHP 8.1 – 8.x: emits an E_DEPRECATED warning, still returns false. Just a log entry, execution continues. PHP 9.0 (planned): throws an uncaught TypeError. Execution halts at the call site and propagates up the stack — same observable behavior as the JS TypeError we just fixed. So the fix calculus changes once PHP 9 is in play: Today (PHP 8.x at Meta): no crash, no fix needed PHP 9: same crash class as the Node.js bug — would need a similar early-return guard in computeETLDPlus1ForHost If the team plans to upgrade, applying the analogous PHP guard now would future-proof. ___ overriding_review_checks_triggers_an_audit_and_retroactive_review Oncall Short Name: advertiser_experience_foundations Differential Revision: D104760726 fbshipit-source-id: 8665505c6b91a81f440ade4a90e58779a65a169f
1 parent a2def12 commit aacad2c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

php/capi-param-builder/src/ParamBuilder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ private function computeETLDPlus1ForHost($host)
345345
if ($this->etld_plus_1 === null || $this->host !== $host) {
346346
// in case a new host is passed in for the same request
347347
$this->host = $host;
348+
if ($host === null || $host === '') {
349+
$this->etld_plus_1 = null;
350+
$this->sub_domain_index = 0;
351+
return;
352+
}
348353
$host = ParamBuilder::extractHostFromHttpHost($host);
349354

350355
if (

0 commit comments

Comments
 (0)