Changeset 40275
- Timestamp:
- 03/11/2017 02:26:11 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r40145 r40275 850 850 'update_term_meta_cache' => false, 851 851 'orderby' => 'none', 852 'suppress_filter' => true, 852 853 ); 853 854 … … 1013 1014 * @since 4.5.0 Changed the function signature so that the `$args` array can be provided as the first parameter. 1014 1015 * Introduced 'meta_key' and 'meta_value' parameters. Introduced the ability to order results by metadata. 1016 * @since 4.8.0 Introduced 'suppress_filter' parameter. 1015 1017 * 1016 1018 * @internal The `$deprecated` parameter is parsed for backward compatibility only. … … 1084 1086 * Default empty. 1085 1087 * @type string $meta_compare Comparison operator to test the 'meta_value'. Default empty. 1088 * @type bool $suppress_filter Whether to suppress the {@see 'get_terms'} filter. Default false. 1086 1089 * } 1087 1090 * @param array $deprecated Argument array, when using the legacy function parameter format. If present, this … … 1095 1098 1096 1099 $term_query = new WP_Term_Query(); 1100 1101 $defaults = array( 1102 'suppress_filter' => false, 1103 ); 1097 1104 1098 1105 /* … … 1109 1116 if ( $do_legacy_args ) { 1110 1117 $taxonomies = (array) $args; 1111 $args = wp_parse_args( $deprecated );1118 $args = wp_parse_args( $deprecated, $defaults ); 1112 1119 $args['taxonomy'] = $taxonomies; 1113 1120 } else { 1114 $args = wp_parse_args( $args );1121 $args = wp_parse_args( $args, $defaults ); 1115 1122 if ( isset( $args['taxonomy'] ) && null !== $args['taxonomy'] ) { 1116 1123 $args['taxonomy'] = (array) $args['taxonomy']; … … 1126 1133 } 1127 1134 1135 // Don't pass suppress_filter to WP_Term_Query. 1136 $suppress_filter = $args['suppress_filter']; 1137 unset( $args['suppress_filter'] ); 1138 1128 1139 $terms = $term_query->query( $args ); 1129 1140 1130 1141 // Count queries are not filtered, for legacy reasons. 1131 1142 if ( ! is_array( $terms ) ) { 1143 return $terms; 1144 } 1145 1146 if ( $suppress_filter ) { 1132 1147 return $terms; 1133 1148 } -
trunk/tests/phpunit/tests/term/getTermBy.php
r38677 r40275 193 193 $this->assertContains( 'LIMIT 1', $wpdb->last_query ); 194 194 } 195 196 /** 197 * @ticket 21760 198 */ 199 public function test_prevent_recursion_by_get_terms_filter() { 200 $action = new MockAction(); 201 202 add_filter( 'get_terms', array( $action, 'filter' ) ); 203 get_term_by( 'name', 'burrito', 'post_tag' ); 204 remove_filter( 'get_terms', array( $action, 'filter' ) ); 205 206 $this->assertEquals( 0, $action->get_call_count() ); 207 } 195 208 }
Note: See TracChangeset
for help on using the changeset viewer.