[wp-trac] [WordPress Trac] #58206: Replace usage of strpos with str_contains

WordPress Trac noreply at wordpress.org
Wed Jun 21 19:36:24 UTC 2023


#58206: Replace usage of strpos with str_contains
-------------------------------------+-------------------------------------
 Reporter:  spacedmonkey             |       Owner:  SergeyBiryukov
     Type:  enhancement              |      Status:  assigned
 Priority:  normal                   |   Milestone:  6.3
Component:  General                  |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  good-first-bug has-      |     Focuses:  performance, coding-
  patch 2nd-opinion commit           |  standards
-------------------------------------+-------------------------------------

Comment (by flixos90):

 Chiming in here due to the ongoing discussion: I believe what is being
 discussed here applies holistically not only to this ticket, but also
 #58012 and #58220.

 I personally think all of these are not as much about performance as they
 are about code cleanup and using the modern PHP functions available for
 specific purposes. It is good that we're benchmarking performance, and
 while it's hard to say which of the two options is ''currently'' faster, I
 think it's fair to say that in any case based on the benchmarks done the
 overall performance impact is negligible.

 I would advise that we make a decision decoupled from the performance &
 benchmarking comversation, simply because the difference is so little that
 due to variance sometimes it will ''seem'' it's faster while other times
 it will ''seem'' that it's slower. To me, the main discussion point is the
 tradeoff between using modern PHP best practices vs avoiding refactoring
 that is not critical.

 From a performance perspective, it's fair to say that, just conceptually,
 I assume that sites on PHP 8+ will be faster when using the new functions
 while sites on PHP <8 will either see no difference or be slightly slower
 (due to using the polyfill). But again, I'd say we shouldn't focus on this
 point as much.

 I personally don't have a strong opinion in either direction, though I'd
 argue that in the long term we should probably use the modern PHP
 functions natively available. But most importantly, I wanted to chime in
 so that we can hopefully avoid deep diving into a performance discussion
 on these tickets, which per the above is pretty much a moot point.

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


More information about the wp-trac mailing list