[wp-trac] [WordPress Trac] #63910: In wp_switch_roles_and_user there is no cast to int applied to $new_site_id and $old_site_id

WordPress Trac noreply at wordpress.org
Tue Sep 2 13:10:24 UTC 2025


#63910: In wp_switch_roles_and_user there is no cast to int applied to $new_site_id
and $old_site_id
--------------------------------+-----------------------------
 Reporter:  eumene              |      Owner:  (none)
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Networks and Sites  |    Version:  6.8.2
 Severity:  normal              |   Keywords:
  Focuses:  multisite           |
--------------------------------+-----------------------------
 In function wp_switch_roles_and_user in file wp-includes/ms-blogs.php
 there is the following `if`

 {{{#!php
 <?php
 if ( $new_site_id === $old_site_id ) {
                 return;
 }
 }}}

 In other cases, when WP is using a $site_id, it applies an int casting to
 be sure to use the right variable type - see funtions

 populate_site_meta
 get_instance in WP_Site class
 ....

 I think you must add casting to both variables $new_site_id and
 $old_site_id before compare them using === operator or change the operator
 to ==

 Thanks for your work

 Diego

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63910>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list