[wp-trac] [WordPress Trac] #61296: Add "force" parameter to get_option and get_transient

WordPress Trac noreply at wordpress.org
Thu Sep 5 20:34:30 UTC 2024


#61296: Add "force" parameter to get_option and get_transient
-----------------------------------------+------------------------------
 Reporter:  juvodesign                   |       Owner:  (none)
     Type:  enhancement                  |      Status:  reopened
 Priority:  normal                       |   Milestone:  Awaiting Review
Component:  Options, Meta APIs           |     Version:
 Severity:  normal                       |  Resolution:
 Keywords:  has-patch reporter-feedback  |     Focuses:
-----------------------------------------+------------------------------

Comment (by juvodesign):

 Exactly as @alexeykorotkov described. I ran into issues where the default
 behavior caused the in-memory caching mechanism of WordPress to contain
 old data.

 I noticed the issue when heavily using the action scheduler of
 WooCommerce. When process A and B start running at the same time and A
 changes data of a transient while B also already read that same transient,
 which caused to have it in memory already, there is no way with
 get_transient to get the latest transient data modified by A.


 == Example scenario:

 Time 0: Action Scheduler initiates Process A and Process B asynchronously.
 Time 1: Process B reads transient 'X' with value '100' and caches it in
 memory.
 Time 2: Process A modifies transient 'X' to value '200'.
 Time 3: Process B continues execution, using its cached value of '100' for
 transient 'X'.
 Time 4: Process B calls get_transient('X'), which returns the cached value
 '100' instead of the updated value '200'.

 In this scenario, Process B operates on outdated data, potentially leading
 to inconsistencies or errors in the application logic.

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


More information about the wp-trac mailing list