Changeset 54571
- Timestamp:
- 10/17/2022 06:13:25 PM (2 years ago)
- Location:
- branches/5.0
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.0
- Property svn:mergeinfo changed
/trunk merged: 54521-54530,54541
- Property svn:mergeinfo changed
-
branches/5.0/src/wp-admin/includes/ajax-actions.php
r45941 r54571 2470 2470 // Filter query clauses to include filenames. 2471 2471 if ( isset( $query['s'] ) ) { 2472 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );2472 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 2473 2473 } 2474 2474 -
branches/5.0/src/wp-admin/includes/post.php
r44339 r54571 1181 1181 // Filter query clauses to include filenames. 1182 1182 if ( isset( $q['s'] ) ) { 1183 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );1183 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 1184 1184 } 1185 1185 -
branches/5.0/src/wp-includes/class-wp-query.php
r47647 r54571 438 438 private $compat_methods = array( 'init_query_flags', 'parse_tax_query' ); 439 439 440 /** 441 * Controls whether an attachment query should include filenames or not. 442 * 443 * @since 6.0.3 444 * @var bool 445 */ 446 protected $allow_query_attachment_by_filename = false; 440 447 /** 441 448 * Resets query flags to false. … … 1299 1306 1300 1307 $like = $n . $wpdb->esc_like( $term ) . $n; 1301 $search .= $wpdb->prepare( "{$searchand}(({$wpdb->posts}.post_title $like_op %s) $andor_op ({$wpdb->posts}.post_excerpt $like_op %s) $andor_op ({$wpdb->posts}.post_content $like_op %s))", $like, $like, $like ); 1308 1309 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 1310 $search .= $wpdb->prepare( "{$searchand}(({$wpdb->posts}.post_title $like_op %s) $andor_op ({$wpdb->posts}.post_excerpt $like_op %s) $andor_op ({$wpdb->posts}.post_content $like_op %s) $andor_op (sq1.meta_value $like_op %s))", $like, $like, $like, $like ); 1311 } else { 1312 $search .= $wpdb->prepare( "{$searchand}(({$wpdb->posts}.post_title $like_op %s) $andor_op ({$wpdb->posts}.post_excerpt $like_op %s) $andor_op ({$wpdb->posts}.post_content $like_op %s))", $like, $like, $like ); 1313 } 1302 1314 $searchand = ' AND '; 1303 1315 } … … 1635 1647 $q = $this->fill_query_vars($q); 1636 1648 1649 /** 1650 * Filters whether an attachment query should include filenames or not. 1651 * 1652 * @since 6.0.3 1653 * 1654 * @param bool $allow_query_attachment_by_filename Whether or not to include filenames. 1655 */ 1656 $this->allow_query_attachment_by_filename = apply_filters( 'wp_allow_query_attachment_by_filename', false ); 1657 remove_all_filters( 'wp_allow_query_attachment_by_filename' ); 1658 1637 1659 // Parse meta query 1638 1660 $this->meta_query = new WP_Meta_Query(); … … 2039 2061 } 2040 2062 2041 if ( ! empty( $this->tax_query->queries ) || !empty( $this->meta_query->queries) ) {2063 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) || ! empty( $this->allow_query_attachment_by_filename ) ) { 2042 2064 $groupby = "{$wpdb->posts}.ID"; 2043 2065 } … … 2111 2133 } 2112 2134 $where .= $search . $whichauthor . $whichmimetype; 2135 2136 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 2137 $join .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )"; 2138 } 2113 2139 2114 2140 if ( ! empty( $this->meta_query->queries ) ) { -
branches/5.0/src/wp-includes/comment.php
r44844 r54571 2184 2184 } 2185 2185 2186 $filter_comment = false; 2187 if ( ! has_filter( 'pre_comment_content', 'wp_filter_kses' ) ) { 2188 $filter_comment = ! user_can( isset( $comment['user_id'] ) ? $comment['user_id'] : 0, 'unfiltered_html' ); 2189 } 2190 2191 if ( $filter_comment ) { 2192 add_filter( 'pre_comment_content', 'wp_filter_kses' ); 2193 } 2194 2186 2195 // Escape data pulled from DB. 2187 2196 $comment = wp_slash($comment); … … 2193 2202 2194 2203 $commentarr = wp_filter_comment( $commentarr ); 2204 2205 if ( $filter_comment ) { 2206 remove_filter( 'pre_comment_content', 'wp_filter_kses' ); 2207 } 2195 2208 2196 2209 // Now extract the merged array. -
branches/5.0/src/wp-includes/customize/class-wp-customize-header-image-control.php
r41935 r54571 104 104 105 105 <button type="button" class="choice thumbnail" 106 data-customize-image-value="{{ {data.header.url}}}"106 data-customize-image-value="{{data.header.url}}" 107 107 data-customize-header-image-data="{{JSON.stringify(data.header)}}"> 108 108 <span class="screen-reader-text"><?php _e( 'Set image' ); ?></span> 109 <img src="{{ {data.header.thumbnail_url}}}" alt="{{{data.header.alt_text || data.header.description}}}">109 <img src="{{data.header.thumbnail_url}}" alt="{{data.header.alt_text || data.header.description}}" /> 110 110 </button> 111 111 -
branches/5.0/src/wp-includes/customize/class-wp-customize-site-icon-control.php
r41162 r54571 67 67 <img src="{{ data.attachment.sizes.full ? data.attachment.sizes.full.url : data.attachment.url }}" alt="<?php esc_attr_e( 'Preview as a browser icon' ); ?>"/> 68 68 </div> 69 <span class="browser-title" aria-hidden="true"><?php bloginfo( 'name'); ?></span>69 <span class="browser-title" aria-hidden="true"><?php echo esc_js( get_bloginfo( 'name' ) ); ?></span> 70 70 </div> 71 71 <img class="app-icon-preview" src="{{ data.attachment.sizes.full ? data.attachment.sizes.full.url : data.attachment.url }}" alt="<?php esc_attr_e( 'Preview as an app icon' ); ?>"/> -
branches/5.0/src/wp-includes/date.php
r41162 r54571 146 146 */ 147 147 public function __construct( $date_query, $default_column = 'post_date' ) { 148 if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] )) {149 $this->relation = 'OR';148 if ( isset( $date_query['relation'] ) ) { 149 $this->relation = $this->sanitize_relation( $date_query['relation'] ); 150 150 } else { 151 151 $this->relation = 'AND'; … … 225 225 $this->validate_date_values( $queries ); 226 226 } 227 228 // Sanitize the relation parameter. 229 $queries['relation'] = $this->sanitize_relation( $queries['relation'] ); 227 230 228 231 foreach ( $queries as $key => $q ) { … … 999 1002 return $wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time ); 1000 1003 } 1004 1005 /** 1006 * Sanitizes a 'relation' operator. 1007 * 1008 * @since 6.0.3 1009 * 1010 * @param string $relation Raw relation key from the query argument. 1011 * @return string Sanitized relation ('AND' or 'OR'). 1012 */ 1013 public function sanitize_relation( $relation ) { 1014 if ( 'OR' === strtoupper( $relation ) ) { 1015 return 'OR'; 1016 } else { 1017 return 'AND'; 1018 } 1019 } 1001 1020 } -
branches/5.0/src/wp-includes/deprecated.php
r43827 r54571 3953 3953 } 3954 3954 } 3955 3956 /** 3957 * Filter the SQL clauses of an attachment query to include filenames. 3958 * 3959 * @since 4.7.0 3960 * @deprecated 6.0.3 3961 * @access private 3962 * 3963 * @param array $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY, 3964 * DISTINCT, fields (SELECT), and LIMITS clauses. 3965 * @return array The unmodified clauses. 3966 */ 3967 function _filter_query_attachment_filenames( $clauses ) { 3968 _deprecated_function( __FUNCTION__, '6.0.3', 'add_filter( "wp_allow_query_attachment_by_filename", "__return_true" )'); 3969 remove_filter( 'posts_clauses', __FUNCTION__ ); 3970 return $clauses; 3971 } 3972 -
branches/5.0/src/wp-includes/functions.php
r46492 r54571 657 657 * Determines whether the publish date of the current post in the loop is different 658 658 * from the publish date of the previous post in the loop. 659 * 659 * 660 660 * For more information on this and similar theme functions, check out 661 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 661 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 662 662 * Conditional Tags} article in the Theme Developer Handbook. 663 * 663 * 664 664 * @since 0.71 665 665 * … … 1352 1352 * 1353 1353 * Checks for the 'siteurl' option for whether WordPress is installed. 1354 * 1354 * 1355 1355 * For more information on this and similar theme functions, check out 1356 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 1356 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 1357 1357 * Conditional Tags} article in the Theme Developer Handbook. 1358 1358 * … … 2413 2413 if ( $type !== $real_mime ) { 2414 2414 /* 2415 * Everything else including image/* and application/*: 2415 * Everything else including image/* and application/*: 2416 2416 * If the real content type doesn't match the file extension, assume it's dangerous. 2417 2417 */ … … 2422 2422 } 2423 2423 2424 // The mime type must be allowed 2424 // The mime type must be allowed 2425 2425 if ( $type ) { 2426 2426 $allowed = get_allowed_mime_types(); … … 2696 2696 $html = __( 'The link you followed has expired.' ); 2697 2697 if ( wp_get_referer() ) { 2698 $html .= '</p><p>'; 2699 $html .= sprintf( '<a href="%s">%s</a>', 2700 esc_url( remove_query_arg( 'updated', wp_get_referer() ) ), 2698 $wp_http_referer = remove_query_arg( 'updated', wp_get_referer() ); 2699 $wp_http_referer = wp_validate_redirect( esc_url_raw( $wp_http_referer ) ); 2700 $html .= '</p><p>'; 2701 $html .= sprintf( 2702 '<a href="%s">%s</a>', 2703 esc_url( $wp_http_referer ), 2701 2704 __( 'Please try again.' ) 2702 2705 ); -
branches/5.0/src/wp-includes/media-template.php
r43829 r54571 1252 1252 <img id="preview-favicon" src="{{ data.url }}" alt="<?php esc_attr_e( 'Preview as a browser icon' ); ?>"/> 1253 1253 </div> 1254 <span class="browser-title" aria-hidden="true"><?php bloginfo( 'name'); ?></span>1254 <span class="browser-title" aria-hidden="true"><?php echo esc_js( get_bloginfo( 'name' ) ); ?></span> 1255 1255 </div> 1256 1256 -
branches/5.0/src/wp-includes/pluggable.php
r47964 r54571 313 313 $phpmailer->clearCustomHeaders(); 314 314 $phpmailer->clearReplyTos(); 315 $phpmailer->Body = ''; 316 $phpmailer->AltBody = ''; 315 317 316 318 // From email and name -
branches/5.0/src/wp-includes/post.php
r52473 r54571 1019 1019 /** 1020 1020 * Determines whether a post type is registered. 1021 * 1021 * 1022 1022 * For more information on this and similar theme functions, check out 1023 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 1023 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 1024 1024 * Conditional Tags} article in the Theme Developer Handbook. 1025 1025 * … … 1779 1779 } 1780 1780 1781 return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public ); 1781 if ( ! is_object( $post_type ) ) { 1782 return false; 1783 } 1784 1785 $is_viewable = $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public ); 1786 1787 /** 1788 * Filters whether a post type is considered "viewable". 1789 * 1790 * The returned filtered value must be a boolean type to ensure 1791 * `is_post_type_viewable()` only returns a boolean. This strictness 1792 * is by design to maintain backwards-compatibility and guard against 1793 * potential type errors in PHP 8.1+. Non-boolean values (even falsey 1794 * and truthy values) will result in the function returning false. 1795 * 1796 * @since 5.9.0 1797 * 1798 * @param bool $is_viewable Whether the post type is "viewable" (strict type). 1799 * @param WP_Post_Type $post_type Post type object. 1800 */ 1801 return true === apply_filters( 'is_post_type_viewable', $is_viewable, $post_type ); 1802 } 1803 1804 /** 1805 * Determines whether a post status is considered "viewable". 1806 * 1807 * For built-in post statuses such as publish and private, the 'public' value will be evaluated. 1808 * For all others, the 'publicly_queryable' value will be used. 1809 * 1810 * @since 5.7.0 1811 * @since 5.9.0 Added `is_post_status_viewable` hook to filter the result. 1812 * 1813 * @param string|stdClass $post_status Post status name or object. 1814 * @return bool Whether the post status should be considered viewable. 1815 */ 1816 function is_post_status_viewable( $post_status ) { 1817 if ( is_scalar( $post_status ) ) { 1818 $post_status = get_post_status_object( $post_status ); 1819 1820 if ( ! $post_status ) { 1821 return false; 1822 } 1823 } 1824 1825 if ( 1826 ! is_object( $post_status ) || 1827 $post_status->internal || 1828 $post_status->protected 1829 ) { 1830 return false; 1831 } 1832 1833 $is_viewable = $post_status->publicly_queryable || ( $post_status->_builtin && $post_status->public ); 1834 1835 /** 1836 * Filters whether a post status is considered "viewable". 1837 * 1838 * The returned filtered value must be a boolean type to ensure 1839 * `is_post_status_viewable()` only returns a boolean. This strictness 1840 * is by design to maintain backwards-compatibility and guard against 1841 * potential type errors in PHP 8.1+. Non-boolean values (even falsey 1842 * and truthy values) will result in the function returning false. 1843 * 1844 * @since 5.9.0 1845 * 1846 * @param bool $is_viewable Whether the post status is "viewable" (strict type). 1847 * @param stdClass $post_status Post status object. 1848 */ 1849 return true === apply_filters( 'is_post_status_viewable', $is_viewable, $post_status ); 1850 } 1851 1852 /** 1853 * Determines whether a post is publicly viewable. 1854 * 1855 * Posts are considered publicly viewable if both the post status and post type 1856 * are viewable. 1857 * 1858 * @since 5.7.0 1859 * 1860 * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 1861 * @return bool Whether the post is publicly viewable. 1862 */ 1863 function is_post_publicly_viewable( $post = null ) { 1864 $post = get_post( $post ); 1865 1866 if ( ! $post ) { 1867 return false; 1868 } 1869 1870 $post_type = get_post_type( $post ); 1871 $post_status = get_post_status( $post ); 1872 1873 return is_post_type_viewable( $post_type ) && is_post_status_viewable( $post_status ); 1782 1874 } 1783 1875 … … 2045 2137 * Sticky posts should remain at the top of The Loop. If the post ID is not 2046 2138 * given, then The Loop ID for the current post will be used. 2047 * 2139 * 2048 2140 * For more information on this and similar theme functions, check out 2049 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 2141 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 2050 2142 * Conditional Tags} article in the Theme Developer Handbook. 2051 * 2143 * 2052 2144 * @since 2.7.0 2053 2145 * … … 5027 5119 /** 5028 5120 * Determines whether an attachment URI is local and really an attachment. 5029 * 5121 * 5030 5122 * For more information on this and similar theme functions, check out 5031 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 5123 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 5032 5124 * Conditional Tags} article in the Theme Developer Handbook. 5033 * 5125 * 5034 5126 * @since 2.0.0 5035 5127 * … … 5528 5620 /** 5529 5621 * Determines whether an attachment is an image. 5530 * 5622 * 5531 5623 * For more information on this and similar theme functions, check out 5532 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 5624 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 5533 5625 * Conditional Tags} article in the Theme Developer Handbook. 5534 5626 * … … 6540 6632 6541 6633 /** 6542 * Filter the SQL clauses of an attachment query to include filenames.6543 *6544 * @since 4.7.06545 * @access private6546 *6547 * @global wpdb $wpdb WordPress database abstraction object.6548 *6549 * @param array $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY,6550 * DISTINCT, fields (SELECT), and LIMITS clauses.6551 * @return array The modified clauses.6552 */6553 function _filter_query_attachment_filenames( $clauses ) {6554 global $wpdb;6555 remove_filter( 'posts_clauses', __FUNCTION__ );6556 6557 // Add a LEFT JOIN of the postmeta table so we don't trample existing JOINs.6558 $clauses['join'] .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )";6559 6560 $clauses['groupby'] = "{$wpdb->posts}.ID";6561 6562 $clauses['where'] = preg_replace(6563 "/\({$wpdb->posts}.post_content (NOT LIKE|LIKE) (\'[^']+\')\)/",6564 "$0 OR ( sq1.meta_value $1 $2 )",6565 $clauses['where'] );6566 6567 return $clauses;6568 }6569 6570 /**6571 6634 * Sets the last changed time for the 'posts' cache group. 6572 6635 * -
branches/5.0/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
r44206 r54571 49 49 // Filter query clauses to include filenames. 50 50 if ( isset( $query_args['s'] ) ) { 51 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );51 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 52 52 } 53 53 -
branches/5.0/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
r43756 r54571 128 128 129 129 /** 130 * Checks if the terms for a post can be read. 131 * 132 * @since 6.0.3 133 * 134 * @param WP_Post $post Post object. 135 * @param WP_REST_Request $request Full details about the request. 136 * @return bool Whether the terms for the post can be read. 137 */ 138 public function check_read_terms_permission_for_post( $post, $request ) { 139 // If the requested post isn't associated with this taxonomy, deny access. 140 if ( ! is_object_in_taxonomy( $post->post_type, $this->taxonomy ) ) { 141 return false; 142 } 143 144 // Grant access if the post is publicly viewable. 145 if ( is_post_publicly_viewable( $post ) ) { 146 return true; 147 } 148 149 // Otherwise grant access if the post is readable by the logged in user. 150 if ( current_user_can( 'read_post', $post->ID ) ) { 151 return true; 152 } 153 154 // Otherwise, deny access. 155 return false; 156 } 157 158 /** 130 159 * Checks if a request has access to read terms in the specified taxonomy. 131 160 * … … 137 166 public function get_items_permissions_check( $request ) { 138 167 $tax_obj = get_taxonomy( $this->taxonomy ); 168 139 169 if ( ! $tax_obj || ! $this->check_is_taxonomy_allowed( $this->taxonomy ) ) { 140 170 return false; 141 171 } 172 142 173 if ( 'edit' === $request['context'] && ! current_user_can( $tax_obj->cap->edit_terms ) ) { 143 return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) ); 144 } 174 return new WP_Error( 175 'rest_forbidden_context', 176 __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ), 177 array( 'status' => rest_authorization_required_code() ) 178 ); 179 } 180 181 if ( ! empty( $request['post'] ) ) { 182 $post = get_post( $request['post'] ); 183 184 if ( ! $post ) { 185 return new WP_Error( 186 'rest_post_invalid_id', 187 __( 'Invalid post ID.' ), 188 array( 189 'status' => 400, 190 ) 191 ); 192 } 193 194 if ( ! $this->check_read_terms_permission_for_post( $post, $request ) ) { 195 return new WP_Error( 196 'rest_forbidden_context', 197 __( 'Sorry, you are not allowed to view terms for this post.' ), 198 array( 199 'status' => rest_authorization_required_code(), 200 ) 201 ); 202 } 203 } 204 145 205 return true; 146 206 } -
branches/5.0/src/wp-includes/widgets.php
r43827 r54571 1409 1409 if ( is_wp_error($rss) ) { 1410 1410 if ( is_admin() || current_user_can('manage_options') ) 1411 echo '<p><strong>' . __( 'RSS Error:' ) . '</strong> ' . $rss->get_error_message() . '</p>';1411 echo '<p><strong>' . __( 'RSS Error:' ) . '</strong> ' . esc_html( $rss->get_error_message() ) . '</p>'; 1412 1412 return; 1413 1413 } … … 1518 1518 1519 1519 if ( ! empty( $args['error'] ) ) { 1520 echo '<p class="widget-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . $args['error']. '</p>';1520 echo '<p class="widget-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . esc_html( $args['error'] ) . '</p>'; 1521 1521 } 1522 1522 -
branches/5.0/src/wp-mail.php
r39772 r54571 60 60 wp_die( __('There doesn’t seem to be any new mail.') ); 61 61 } 62 63 // Always run as an unauthenticated user. 64 wp_set_current_user( 0 ); 62 65 63 66 for ( $i = 1; $i <= $count; $i++ ) { … … 125 128 $author = sanitize_email($author); 126 129 if ( is_email($author) ) { 127 /* translators: Post author email address */128 echo '<p>' . sprintf(__('Author is %s'), $author) . '</p>';129 130 $userdata = get_user_by('email', $author); 130 131 if ( ! empty( $userdata ) ) { 131 $post_author = $userdata->ID;132 $post_author = $userdata->ID; 132 133 $author_found = true; 133 134 } -
branches/5.0/src/wp-trackback.php
r41980 r54571 13 13 wp( array( 'tb' => '1' ) ); 14 14 } 15 16 // Always run as an unauthenticated user. 17 wp_set_current_user( 0 ); 15 18 16 19 /** -
branches/5.0/tests/phpunit/tests/query/search.php
r38844 r54571 371 371 372 372 add_post_meta( $attachment, '_wp_attached_file', 'some-image1.png', true ); 373 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );373 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 374 374 375 375 // Pass post_type a string value. … … 397 397 398 398 add_post_meta( $attachment, '_wp_attached_file', 'some-image2.png', true ); 399 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );399 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 400 400 401 401 // Pass post_type an array value. … … 448 448 add_post_meta( $attachment, '_wp_attached_file', 'some-image4.png', true ); 449 449 add_post_meta( $attachment, '_test_meta_key', 'value', true ); 450 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );450 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 451 451 452 452 // Pass post_type a string value. … … 484 484 485 485 add_post_meta( $attachment, '_wp_attached_file', 'some-image5.png', true ); 486 add_filter( ' posts_clauses', '_filter_query_attachment_filenames' );486 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 487 487 488 488 // Pass post_type a string value. … … 507 507 * @ticket 22744 508 508 */ 509 public function test_filter_query_attachment_filenames_unhooks_itself() { 510 add_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); 511 512 apply_filters( 'posts_clauses', array( 513 'where' => '', 514 'groupby' => '', 515 'join' => '', 516 'orderby' => '', 517 'distinct' => '', 518 'fields' => '', 519 'limit' => '', 520 ) ); 521 522 $result = has_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); 523 524 $this->assertFalse( $result ); 509 public function test_wp_query_removes_filter_wp_allow_query_attachment_by_filename() { 510 $attachment = self::factory()->post->create( 511 array( 512 'post_type' => 'attachment', 513 'post_status' => 'publish', 514 'post_title' => 'bar foo', 515 'post_content' => 'foo bar', 516 'post_excerpt' => 'This post has foo', 517 ) 518 ); 519 520 add_post_meta( $attachment, '_wp_attached_file', 'some-image1.png', true ); 521 add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); 522 523 $q = new WP_Query( 524 array( 525 's' => 'image1', 526 'fields' => 'ids', 527 'post_type' => 'attachment', 528 'post_status' => 'inherit', 529 ) 530 ); 531 532 $this->assertSame( array( $attachment ), $q->posts ); 533 534 /* 535 * WP_Query should have removed the wp_allow_query_attachment_by_filename filter 536 * and thus not match the attachment created above 537 */ 538 $q->get_posts(); 539 $this->assertEmpty( $q->posts ); 525 540 } 526 541 -
branches/5.0/tests/phpunit/tests/rest-api/rest-comments-controller.php
r43445 r54571 2605 2605 'author_name' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2606 2606 'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2607 'author' => self::$editor_id, 2607 2608 ), array( 2608 2609 'content' => array( … … 2612 2613 'author_name' => 'div strong', 2613 2614 'author_user_agent' => 'div strong', 2615 'author' => self::$editor_id, 2614 2616 ) ); 2615 2617 } else { … … 2619 2621 'author_name' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2620 2622 'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2623 'author' => self::$editor_id, 2621 2624 ), array( 2622 2625 'content' => array( … … 2626 2629 'author_name' => 'div strong', 2627 2630 'author_user_agent' => 'div strong', 2631 'author' => self::$editor_id, 2628 2632 ) ); 2629 2633 } … … 2637 2641 'author_name' => '\\\&\\\ & &invalid; < < &lt;', 2638 2642 'author_user_agent' => '\\\&\\\ & &invalid; < < &lt;', 2643 'author' => self::$superadmin_id, 2639 2644 ), array( 2640 2645 'content' => array( … … 2644 2649 'author_name' => '\\\&\\\ & &invalid; < < &lt;', 2645 2650 'author_user_agent' => '\\\&\\\ & &invalid; < < &lt;', 2651 'author' => self::$superadmin_id, 2646 2652 ) ); 2647 2653 } … … 2654 2660 'author_name' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2655 2661 'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2662 'author' => self::$superadmin_id, 2656 2663 ), array( 2657 2664 'content' => array( … … 2661 2668 'author_name' => 'div strong', 2662 2669 'author_user_agent' => 'div strong', 2670 'author' => self::$superadmin_id, 2663 2671 ) ); 2664 2672 }
Note: See TracChangeset
for help on using the changeset viewer.