[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 20:02:43 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: 4.9
Severity: normal | Resolution:
Keywords: | Focuses: multisite
--------------------------------+------------------------------
Changes (by spacedmonkey):
* version: 6.8.2 => 4.9
Comment:
@eumene Can you provide some more complex on where this error happens? Are
you calling this function in your own code and it is having issues?
In your own code, you could just do this.
{{{#!php
wp_switch_roles_and_user( (int) $new_site_id, (int) $old_site_id );
}}}
This code function is only called in one place in core.
[https://github.com/WordPress/wordpress-
develop/blob/413b7ea23c6bca900ea4b9523ba98c5e4faa1169/src/wp-includes/ms-
default-filters.php#L37C14-L37C25 Here]. It is hooked into the
`switch_blog` action. Would be considing adding the casting of string to
int in the action, like this.
{{{#!php
do_action( 'switch_blog', (int) $new_blog_id, (int) $prev_blog_id,
'switch' );
}}}
Thoughts?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63910#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list