[wp-trac] [WordPress Trac] #61694: Ensure compat functions do not rely on external functions

WordPress Trac noreply at wordpress.org
Thu Jul 18 21:01:43 UTC 2024


#61694: Ensure compat functions do not rely on external functions
----------------------------+---------------------
 Reporter:  jorbin          |       Owner:  (none)
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  6.7
Component:  Bootstrap/Load  |     Version:
 Severity:  normal          |  Resolution:
 Keywords:                  |     Focuses:
----------------------------+---------------------

Comment (by joemcgill):

 Thanks for opening this issue. I agree with the two improvements you
 suggest and suggest a third, which is to review the current functions
 defined in `compat.php` and resolve any current dependencies on external
 functions that may not be loaded when these functions are called.

 Currently, this includes calls to `get_option()` in `_mb_substr()` and
 `_mb_strlen()`, but previously included calls to `is_utf8_charset()`. This
 was fixed in [58763] by splitting the stateless logic into an internal
 function that is included in `compat.php` directly. For uses of
 `get_option()` there really isn't any stateless logic that could be split,
 so a different approach is needed, like wrapping calls to internal
 functions in `try/catch` blocks or `function_exists()` checks to avoid
 potential fatals.

 Alternately, we could take the stance that these compat functions are only
 meant to support WP Core's own usage of the functions being pollyfilled
 when not available at the platform level and allow potential fatals
 triggered by third party code to be handled by those third parties. I'm
 not advocating for this stance, but do think it's a valid option that
 should be discussed.

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


More information about the wp-trac mailing list