Refactor gallery search query building#2347
Conversation
Build the gallery search WHERE/JOIN clauses with $wpdb->prepare() and $wpdb->esc_like() instead of manual string concatenation, and drop the redundant decode of the already-decoded search parameter. No change to search behavior.
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Refactors gallery search SQL clause construction to reduce manual string concatenation by using $wpdb->prepare() / $wpdb->esc_like(), and removes an unnecessary urldecode() call while aiming to keep search behavior unchanged.
Changes:
- Adds
$wpdb->prepare()and$wpdb->esc_like()for multiple WHERE fragments inrtmedia_search_fillter_where_query(). - Removes
urldecode()from the search parameter sanitation pipeline. - Updates JOIN construction for attribute search to quote the slug via
$wpdb->prepare().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
krishana7911
left a comment
There was a problem hiding this comment.
@the-hercules added some comments.
…pes are sanitized
…ents for trusted identifiers
|
Unable to PHPCS or SVG scan one or more files due to error running PHPCS/SVG scanner:
The error may be temporary. If the error persists, please contact a human (commit-ID: b7d7a9f). |
| $author_id = implode( ',', array_map( 'absint', array_filter( explode( ',', $author_id ) ) ) ); | ||
| $member_type = implode( ',', array_map( 'absint', array_filter( explode( ',', $member_type ) ) ) ); |
| $where .= " OR $table_name.media_author IN (" . $author_id . ') '; | ||
| } | ||
| if ( ! empty( $member_type ) ) { | ||
| $where .= " OR $table_name.media_author IN (" . $member_type . ') '; | ||
| } |
Refactors the WHERE/JOIN construction in the gallery search filters (
rtmedia_search_fillter_where_query/rtmedia_search_fillter_join_query) to build clauses with$wpdb->prepare()and$wpdb->esc_like()instead of manual string concatenation, and drops a redundant decode of the already-decoded search parameter. No change to search behavior.