168 | 168 | // tax + cat with tax added |
169 | 169 | $this->go_to( home_url( "/testtax/tax-slug2/?cat=$this->cat_id" ) ); |
170 | 170 | $this->assertQueryTrue( 'is_category', 'is_tax', 'is_archive' ); |
171 | 171 | $this->assertNotEmpty( get_query_var( 'tax_query' ) ); |
172 | 172 | $this->assertNotEmpty( get_query_var( 'taxonomy' ) ); |
173 | 173 | $this->assertNotEmpty( get_query_var( 'term_id' ) ); |
174 | 174 | $this->assertNotEmpty( get_query_var( 'cat' ) ); |
175 | 175 | $this->assertEquals( get_queried_object(), $this->cat ); |
176 | 176 | } |
177 | 177 | |
178 | 178 | function pre_get_posts_tax_category_tax_query( &$query ) { |
179 | 179 | $query->set( 'tax_query', array( |
180 | 180 | array( 'taxonomy' => 'testtax', 'field' => 'term_id', 'terms' => $this->tax_id ) |
181 | 181 | ) ); |
182 | 182 | } |
| 183 | |
| 184 | /** |
| 185 | * @group fatal-in-tax |
| 186 | */ |
| 187 | function test_fatal_errors_around_here() { |
| 188 | |
| 189 | // piggybacking on these tests. |
| 190 | remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) ); |
| 191 | $this->go_to( home_url( "/" ) ); |
| 192 | |
| 193 | $args = array( |
| 194 | 'tax_query' => array( |
| 195 | 'relation' => 'AND', |
| 196 | array( |
| 197 | 'taxonomy' => 'testtax', |
| 198 | 'field' => 'slug', |
| 199 | 'terms' => array( |
| 200 | 'tax-slug' |
| 201 | ) |
| 202 | ) |
| 203 | /*, // Happens with, or without, the following |
| 204 | array( |
| 205 | 'taxonomy' => 'testtax', |
| 206 | 'field' => 'slug', |
| 207 | 'terms' => array( |
| 208 | 'tax-slug2' |
| 209 | ) |
| 210 | )*/ |
| 211 | ) |
| 212 | ); |
| 213 | |
| 214 | $q = new WP_Query( $args ); |
| 215 | $object = $q->get_queried_object(); |
| 216 | |
| 217 | // Shouldn't fatal here. |
| 218 | // Warning: Illegal string offset 'terms' in wp-includes/query.php on line 3875 |
| 219 | // Warning: Illegal string offset 'field' in wp-includes/query.php on line 3876 |
| 220 | // Fatal error: Only variables can be passed by reference in wp-includes/query.php on line 3879 |
| 221 | |
| 222 | } |
| 223 | |