[wp-trac] [WordPress Trac] #57867: Fix PHP warning when passing NULL to rtrim().

WordPress Trac noreply at wordpress.org
Sat Mar 4 11:21:59 UTC 2023


#57867: Fix PHP warning when passing NULL to rtrim().
-----------------------------------------+------------------------------
 Reporter:  tools400                     |       Owner:  (none)
     Type:  enhancement                  |      Status:  new
 Priority:  normal                       |   Milestone:  Awaiting Review
Component:  Formatting                   |     Version:  trunk
 Severity:  normal                       |  Resolution:
 Keywords:  has-patch reporter-feedback  |     Focuses:
-----------------------------------------+------------------------------
Changes (by johnbillion):

 * keywords:  has-patch => has-patch reporter-feedback


Comment:

 Thanks for the PR @tools400, and welcome.

 The `$value` parameter of `untrailingslashit()` should only ever be a
 string. Putting this guard in place to avoid a PHP warning when it's
 `null` is really just papering over the problem instead of fixing the root
 cause. It would be better to find and fix the situation in which `null`
 gets passed to this parameter in the first place.

 Does this error still occur if you deactivate all your plugins and switch
 to one of the default "Twenty" themes? I think it's quite likely that a
 plugin or theme on your site is passing `null` to this function.

 Which version of PHP are you using?

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


More information about the wp-trac mailing list