Make WordPress Core


Ignore:
Timestamp:
10/17/2022 12:24:45 PM (4 years ago)
Author:
audrasjb
Message:

Media: Refactor search by filename within the admin.

Props vortfu, xknown, peterwilsoncc, paulkevan.
Merges [54524] to the 6.0 branch.

Location:
branches/6.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.0

  • branches/6.0/src/wp-includes/post.php

    r53300 r54534  
    79207920
    79217921/**
    7922  * Filters the SQL clauses of an attachment query to include filenames.
    7923  *
    7924  * @since 4.7.0
    7925  * @access private
    7926  *
    7927  * @global wpdb $wpdb WordPress database abstraction object.
    7928  *
    7929  * @param string[] $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY,
    7930  *                          DISTINCT, fields (SELECT), and LIMITS clauses.
    7931  * @return string[] The modified array of clauses.
    7932  */
    7933 function _filter_query_attachment_filenames( $clauses ) {
    7934         global $wpdb;
    7935         remove_filter( 'posts_clauses', __FUNCTION__ );
    7936 
    7937         // Add a LEFT JOIN of the postmeta table so we don't trample existing JOINs.
    7938         $clauses['join'] .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )";
    7939 
    7940         $clauses['groupby'] = "{$wpdb->posts}.ID";
    7941 
    7942         $clauses['where'] = preg_replace(
    7943                 "/\({$wpdb->posts}.post_content (NOT LIKE|LIKE) (\'[^']+\')\)/",
    7944                 '$0 OR ( sq1.meta_value $1 $2 )',
    7945                 $clauses['where']
    7946         );
    7947 
    7948         return $clauses;
    7949 }
    7950 
    7951 /**
    79527922 * Sets the last changed time for the 'posts' cache group.
    79537923 *
Note: See TracChangeset for help on using the changeset viewer.