Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #55603, comment 93


Ignore:
Timestamp:
10/16/2025 10:13:15 PM (4 months ago)
Author:
dmsnell
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #55603, comment 93

    initial v1  
    44 - Conditionally polyfilling the functions will not stand in the way of resolving this ticket. I will not close this ticket in the merge, but rather incorporate it into the independent work in #63863. PHP is losing functions that a variety of plugins and even Core currently calls. The polyfill will prevent unexpected site crashes; these crashes will be triggered in most cases by people who are not the direct site owners, so those affected will likely have little knowledge of how to fix the problem or agency to do it. The polyfills will keep WordPress reliable in the presence of a changing environment.
    55 - The polyfill functions are marked as deprecated. Whether calling PHP’s native deprecated functions or calling WordPress’ polyfilled functions, the warning instructs developers to update their code.
     6 - The polyfill functions are to be loaded in the recently-introduced `compat-utf8.php` module which should load early int he boot process and before any plugins have a chance to load. Plugins ought to detect that the functions already exist and defer their own polyfills.
    67 - Preventing sites from crashing will not obstruct any efforts to update code. What //does// hamper refactoring is that most existing uses of these functions is wrong, as the functions were built from the start with a contextual and confusing nuance. There is usually no simple refactor to replace `utf8_encode()` with something inside of the `mbstring` extension. Decisions have to be made in most cases on how and what to break when refactoring. For example, a common use of these functions is to determine if a string is //already encoded as UTF-8// and then convert it if not. Fundamentally that it is an unsound judgement. Refactors will need to determine if they want to preserve the defects or reject unsupported inputs, or make some other adjustment.
    78 - Having polyfills does not speak to the question of requiring `mbstring` and having `mbstring` does not resolve the legacy use of `utf8_encode()` and `utf8_decode()`. In other words, these are two independent issues.