Make WordPress Core

Changes between Initial Version and Version 34 of Ticket #22192


Ignore:
Timestamp:
09/15/2023 07:46:06 AM (15 months ago)
Author:
mukesh27
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #22192

    • Property Status changed from new to assigned
    • Property Focuses performance added
    • Property Cc knut@… atimmermans@… added
    • Property Component changed from Performance to Options and Meta
    • Property Summary changed from update_metadata() and update_option() strict checks can cause false negatives to update_option() strict checks can cause false negatives
    • Property Owner set to mukesh27
    • Property Milestone changed from to 6.4
    • Property Keywords has-patch 2nd-opinion dev-feedback has-unit-tests added; needs-patch needs-unit-tests removed
  • Ticket #22192 – Description

    initial v34  
    22
    33{{{
    4 add_post_meta( $post_id, 'key', 1 );
    5 update_post_meta( $post_id, 'key', 1 );
     4add_option( $option_name, 1 );
     5update_option( $option_name, 1 );
    66}}}
    77
    88The update should not work, because they are the same. However, the meta cache will have "1" as a string, and then it will strict compare it to 1 as an integer. Thus, an unnecessary update will run.
    99
    10 Best I can tell, this could also affect update_option().
    11 
    1210It is quite common to use integers and booleans directly into these functions. They should be smart enough to recognize that "1" == 1 == true and "0" == 0 == false, and that any numeric string is also equal to a properly cast integer.
    1311
    14 Unit tests needed.
     12The new changes need unit tests.
    1513
    1614Ticket from which this was spun: #22189, saving navigation menus is slow.