[wp-trac] [WordPress Trac] #48565: The `site_url` function doesn't work with objects implemented `__toString`

WordPress Trac noreply at wordpress.org
Thu Jan 4 22:16:56 UTC 2024


#48565: The `site_url` function doesn't work with objects implemented  `__toString`
-------------------------------+----------------------
 Reporter:  azeemhassni        |       Owner:  (none)
     Type:  defect (bug)       |      Status:  closed
 Priority:  normal             |   Milestone:
Component:  General            |     Version:  5.2.4
 Severity:  trivial            |  Resolution:  wontfix
 Keywords:  needs-patch close  |     Focuses:
-------------------------------+----------------------
Changes (by hellofromTonya):

 * status:  new => closed
 * resolution:   => wontfix
 * milestone:  Awaiting Review =>


Comment:

 >Personally I think this is enough of an edge case that this ticket should
 be closed off. The additional overhead to handle this case is not worth
 it. Just cast it to a string before passing into functions that expect a
 string.

 I agree with @johnbillion. This one is an interesting edge case that can
 be handled in before passing the `path` to `site_url()`. I don't think the
 overhead though benefits the majority of users.

 With no further follow-up for 4 years, I'll close this ticket as
 `wontfix`.

 >Plus, in the case of `get_site_url()` I think the reason for the
 `is_string()` check is to guard against passing, e.g., an array, without
 raising runtime errors.

 @pbiron this kind of strict data type checking should be part of a
 architectural design discussion of how to handle function/method input
 validation. For back-compat, consideration is needed for how Core has
 handled non-string data types. Your point is valid and something to
 holistically consider across Core's codebase.

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


More information about the wp-trac mailing list