Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use prefix instead of parsing our own #7185

Merged
merged 1 commit into from
Sep 28, 2023

Conversation

JoryHogeveen
Copy link
Member

@JoryHogeveen JoryHogeveen commented Sep 25, 2023

Enhance compatibility with other plugins.

Related GitHub issue(s)

Fixes #7181

Changelog text for these changes

PR checklist

Enhance compatibility with other plugins.
Fixes #7181
@JoryHogeveen JoryHogeveen self-assigned this Sep 25, 2023
@JoryHogeveen JoryHogeveen added Type: Bug Status: PR > Pending Code Review PR is pending code review by core developers Status: PR > QA pending QA needs to be done labels Sep 25, 2023
@JoryHogeveen JoryHogeveen added this to the Pods 3.0.4 milestone Sep 25, 2023
@JoryHogeveen JoryHogeveen added the Focus: Other Compatibility Compatibility with third-party plugins, themes, and libraries label Sep 25, 2023
@what-the-diff
Copy link

what-the-diff bot commented Sep 25, 2023

PR Summary

  • Updated variable in pick.php file
    In our code, specifically in a file called pick.php, we've replaced a piece of code ($wpdb->base_prefix) with a different one ($wpdb->prefix). This might seem like a small change, but it's crucial for keeping the system running smoothly and effectively.

@sc0ttkclark sc0ttkclark modified the milestones: Pods 3.0.4, Pods 3.0.5 Sep 28, 2023
@sc0ttkclark
Copy link
Member

There was a reason this was in place, I need to go figure out why that was and how to continue supporting that (if it's still a valid reason).

@sc0ttkclark
Copy link
Member

Walking backwards from most recent to the original introduction of this usage:

Given that, I think your PR looks good -- EXCEPT -- this is not what WP_User uses (as of WP 4.9+) and that's what we need to follow instead here.

	/**
	 * Sets the site to operate on. Defaults to the current site.
	 *
	 * @since 4.9.0
	 *
	 * @global wpdb $wpdb WordPress database abstraction object.
	 *
	 * @param int $site_id Site ID to initialize user capabilities for. Default is the current site.
	 */
	public function for_site( $site_id = '' ) {
		global $wpdb;

		if ( ! empty( $site_id ) ) {
			$this->site_id = absint( $site_id );
		} else {
			$this->site_id = get_current_blog_id();
		}

		$this->cap_key = $wpdb->get_blog_prefix( $this->site_id ) . 'capabilities';

		$this->caps = $this->get_caps_data();

		$this->get_role_caps();
	}

So the solution here needs to actually be calling $wpdb->get_blog_prefix() instead.

@sc0ttkclark
Copy link
Member

Just did more digging into the wpdb class and it looks like when switching blogs, it accounts for everything automatically so the code that WP_User is using isn't necessary since our context doesn't need to be able to check by site ID -- only the current site context. We can merge this as-is.

@sc0ttkclark sc0ttkclark changed the base branch from main to release/3.0.5 September 28, 2023 02:13
@sc0ttkclark sc0ttkclark merged commit 7c6bb84 into release/3.0.5 Sep 28, 2023
7 of 8 checks passed
@sc0ttkclark sc0ttkclark deleted the feature/7181-wpdb-prefix branch September 28, 2023 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Focus: Other Compatibility Compatibility with third-party plugins, themes, and libraries Status: PR > Pending Code Review PR is pending code review by core developers Status: PR > QA pending QA needs to be done Type: Bug
Projects
Status: Done
2 participants