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

Avoid partial author ID replacement in posts_where_filter #565

Closed
wants to merge 0 commits into from
Closed

Avoid partial author ID replacement in posts_where_filter #565

wants to merge 0 commits into from

Conversation

jeremyfelt
Copy link
Contributor

@jeremyfelt jeremyfelt commented Jul 16, 2018

If a user with the ID of 1 visited the author archive page for a user with the ID of 17, the regex would filter out the 1 of 17 and replace with the corresponding guest author ID resulting in a SQL string like '2039'7. This results in invalid SQL.

This PR adds a trailing space to the end of the current user query and requires that space in the preg_replace(). There's probably another way to do this by forcing the match to occur at the end of the string, but this is what I've got. :)

Query text generated before (bad):

AND ((wp_44_term_taxonomy.taxonomy = 'author' AND wp_44_term_taxonomy.term_id = '2039'7 OR (wp_44_term_taxonomy.taxonomy = 'author' AND wp_44_term_taxonomy.term_id = '1916'))) AND wp_44_posts.post_type = 'post' AND (wp_44_posts.post_status = 'publish' OR wp_44_posts.post_status = 'private')"

Query text generated after (good):

AND ((wp_44_posts.post_author = 17 OR (wp_44_term_taxonomy.taxonomy = 'author' AND wp_44_term_taxonomy.term_id = '1916'))) AND wp_44_posts.post_type = 'post' AND (wp_44_posts.post_status = 'publish' OR wp_44_posts.post_status = 'private')

I think this was introduced in 08c0315.

jeremyfelt added a commit to washingtonstateuniversity/WSUWP-Build-Plugins-Public that referenced this pull request Jul 16, 2018
@jeremyfelt jeremyfelt closed this Aug 8, 2018
@jeremyfelt
Copy link
Contributor Author

Closed this because I deleted the fork. Looks like the commit is still visible if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant