Make WordPress Core

Changes between Version 4 and Version 5 of Ticket #55942, comment 70


Ignore:
Timestamp:
05/05/2023 09:26:45 PM (11 months ago)
Author:
azaozz
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #55942, comment 70

    v4 v5  
    14141. If you use a DB option added by another plugin, and the other plugin's author decides to change a DB option value type from `string` to `boolean`, and the type is "globally registered", your code may throw a fatal error. This is the same as changing the type of the return value from a function. Expecting one type of data by a third-party code and getting another signifies a badly written code. That's all.
    1515
    16 However if the type of the option value is not "globally registered" but instead is passed when retrieving the value (like the current patch), your code will not throw a fatal error. You will get an empty string if the third-party plugin author suddenly switched the option to a boolean.
     16However if the type of the option value is not "globally registered" but instead is passed when retrieving the value (like the current patch), your code will not throw a fatal error. You will get an empty string or a `'1'` if the third-party plugin author suddenly switched the option to a boolean.
    1717
    18182. Then there is the case of the third-party plugin being deactivated, so the DB option is no longer "globally registered". What then? `get_option()` just reverts to the old behavior of returning string equivalents? More chances for fatal errors...