[wp-trac] [WordPress Trac] #61025: Do not write in DB when updating a user if no user data has changed

WordPress Trac noreply at wordpress.org
Thu Apr 18 22:31:13 UTC 2024


#61025: Do not write in DB when updating a user if no user data has changed
-------------------------+------------------------------
 Reporter:  asumaran     |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Users        |     Version:  6.5
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:  performance
-------------------------+------------------------------

Comment (by asumaran):

 Updated the patch to skip calling the profile_update action if the UPDATE
 query did not run.

 By not calling this action,
 [https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/includes
 /wc-user-functions.php#L807 WooCommerce] will avoid running an unnecessary
 UPDATE query to set the `last_update` user meta if the user data hasn't
 changed.

 Although, in the `profile_update` action the `$old_user_data` and
 `$userdata` is passed, we could use it to avoid running the query in
 WooCommerce's scope. But didn't make sense to me to avoid running the
 UPDATE query and then calling the `profile_update` action.

 I think it's consistent to avoid calling the action if the UPDATE query
 didn't run.

 So, either my changes make sense or a new filter is introduced to avoid
 the UPDATE query
  we are trying to avoid with my changes.

 Happy to hear anything about my proposal.

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


More information about the wp-trac mailing list