[wp-trac] [WordPress Trac] #57580: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in functions.php

WordPress Trac noreply at wordpress.org
Wed Mar 15 14:33:37 UTC 2023


#57580: strpos(): Passing null to parameter #1 ($haystack) of type string is
deprecated  in functions.php
--------------------------+---------------------
 Reporter:  ipajen        |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  6.3
Component:  General       |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  PHP81 close   |     Focuses:
--------------------------+---------------------
Changes (by hellofromTonya):

 * keywords:  PHP81 close 2nd-opinion => PHP81 close


Comment:

 There's a mixture of parameter checks in Core:

 * Do nothing and let PHP handle reporting the incompatibility (which is
 the case here).
 * Add a `_doing_it_wrong()` to clear identify why it's wrong.
 * Add a `trigger_error()` to also identify why it's wrong.

 >The current hap-snap "add a _doing_it_wrong to a function whenever
 someone reports an issue of a plugin doing silly things" is not helping
 anyone in the long run.

 Yes, I agree with @jrf. I'm not seeing an advantage or benefit of adding
 this code into Core, unless it's specifically to avoid hiding the type
 incompatibility report due to the nature of the code itself in its
 context.

 >IMO we need a more structural approach
 >on whether and how to validate the type of received parameters in
 functions in Core

 Yes, I also agree with @jrf. Type validation is needed, but not in a
 haphazard and inconsistent way. Architectural decisions are needed. (Let's
 see if that can happen in 6.3). I don't think type validation though
 should exist to only duplicate reporting type mismatches. It should
 instead exist when needed within the context of the code it's being
 applied to.

 In this specific report, PHP is reporting the type mismatch. The function
 expects a `string` type. Passing a non-string is doing it wrong. The fix
 should be in the plugins, not in Core.

 I agree with @jrf that to close this ticket.

 @SergeyBiryukov are you okay with closing it?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57580#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list