[wp-trac] [WordPress Trac] #59450: Fix get_bloginfo

WordPress Trac noreply at wordpress.org
Tue Sep 26 11:29:44 UTC 2023


#59450: Fix get_bloginfo
--------------------------+-----------------------------
 Reporter:  Cybr          |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  2.3
 Severity:  normal        |   Keywords:  has-patch
  Focuses:  performance   |
--------------------------+-----------------------------
 `get_bloginfo()` is a popular function. Alas, it performs checks for an
 often unused parameter: `$url`.

 Moreover, the `! str_contains()` chain can be exchanged for a simpler
 `preg_match()`.
 See, for performance: https://3v4l.org/dqBgA.

 The attached patch will address both issues.

 Note that the performance impact is mostly due to the use of NOT and
 writing to a variable.
 Here's the performance benchmark of that: https://3v4l.org/8hSiW.
 When we fix that and then compare it to `preg_match()`, it becomes a
 matter of preference: https://3v4l.org/3AXAY.

 Still, `str_contains()` relies on a polyfill for many sites.

 It's been like this [https://github.com/WordPress/wordpress-
 develop/commit/c6cef97007c10717c6f78427603ebda45ecb91f8#diff-
 b047a66a50212c4e9109c23c02e0a2add317d86edf6c53bb590e7ddfd9006c36R145 since
 WP 2.3], so it might be worthwhile to write a sniff for this as it went
 unnoticed for 16 years.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59450>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list