<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[29933] trunk: Use table aliases for columns in SQL generated by WP_Date_Query.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/29933">29933</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/29933","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>boonebgorges</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2014-10-17 01:19:03 +0000 (Fri, 17 Oct 2014)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Use table aliases for columns in SQL generated by WP_Date_Query.
The use of non-aliased column names (eg 'post_date' instead of 'wp_posts.post_date')
in WP_Date_Query causes SQL notices and other failures when queries involve
table joins, such as date_query combined with tax_query or meta_query. This
changeset modifies WP_Date_Query::validate_column() to add the table alias when
it can be detected from the column name (ie, in the case of core columns).
A side effect of this change is that it is now possible to use WP_Date_Query
to build WHERE clauses across multiple tables, though there is currently no
core support for the automatic generation of the necessary JOIN clauses. See
Props ew_holmes, wonderboymusic, neoxx, Viper007Bond, boonebgorges.
Fixes <a href="https://core.trac.wordpress.org/ticket/25775">#25775</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesdatephp">trunk/src/wp-includes/date.php</a></li>
<li><a href="#trunktestsphpunittestsdatequeryphp">trunk/tests/phpunit/tests/date/query.php</a></li>
<li><a href="#trunktestsphpunittestsquerydateQueryphp">trunk/tests/phpunit/tests/query/dateQuery.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesdatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/date.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/date.php 2014-10-17 00:40:06 UTC (rev 29932)
+++ trunk/src/wp-includes/date.php 2014-10-17 01:19:03 UTC (rev 29933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -435,6 +435,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Validates a column name parameter.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Column names without a table prefix (like 'post_date') are checked against a whitelist of
+ * known tables, and then, if found, have a table prefix (such as 'wp_posts.') prepended.
+ * Prefixed column names (such as 'wp_posts.post_date') bypass this whitelist check,
+ * and are only sanitized to remove illegal characters.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @since 3.7.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -442,22 +447,53 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string A validated column name value.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function validate_column( $column ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $valid_columns = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_date', 'post_date_gmt', 'post_modified',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_modified_gmt', 'comment_date', 'comment_date_gmt'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Filter the list of valid date query columns.
- *
- * @since 3.7.0
- *
- * @param array $valid_columns An array of valid date query columns. Defaults are 'post_date', 'post_date_gmt',
- * 'post_modified', 'post_modified_gmt', 'comment_date', 'comment_date_gmt'
- */
- if ( ! in_array( $column, apply_filters( 'date_query_valid_columns', $valid_columns ) ) )
- $column = 'post_date';
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $column;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Attempt to detect a table prefix.
+ if ( false === strpos( $column, '.' ) ) {
+ /**
+ * Filter the list of valid date query columns.
+ *
+ * @since 3.7.0
+ *
+ * @param array $valid_columns An array of valid date query columns. Defaults
+ * are 'post_date', 'post_date_gmt', 'post_modified',
+ * 'post_modified_gmt', 'comment_date', 'comment_date_gmt'
+ */
+ if ( ! in_array( $column, apply_filters( 'date_query_valid_columns', $valid_columns ) ) ) {
+ $column = 'post_date';
+ }
+
+ $known_columns = array(
+ $wpdb->posts => array(
+ 'post_date',
+ 'post_date_gmt',
+ 'post_modified',
+ 'post_modified_gmt',
+ ),
+ $wpdb->comments => array(
+ 'comment_date',
+ 'comment_date_gmt',
+ ),
+ );
+
+ // If it's a known column name, add the appropriate table prefix.
+ foreach ( $known_columns as $table_name => $table_columns ) {
+ if ( in_array( $column, $table_columns ) ) {
+ $column = $table_name . '.' . $column;
+ break;
+ }
+ }
+
+ }
+
+ // Remove unsafe characters.
+ return preg_replace( '/[^a-zA-Z0-9_$\.]/', '', $column );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestsdatequeryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/date/query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/date/query.php 2014-10-17 00:40:06 UTC (rev 29932)
+++ trunk/tests/phpunit/tests/date/query.php 2014-10-17 01:19:03 UTC (rev 29933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -201,48 +201,87 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_validate_column_post_date() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Date_Query( array() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'post_date', $q->validate_column( 'post_date' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $wpdb->posts . '.post_date', $q->validate_column( 'post_date' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_validate_column_post_date_gmt() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Date_Query( array() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'post_date_gmt', $q->validate_column( 'post_date_gmt' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $wpdb->posts . '.post_date_gmt', $q->validate_column( 'post_date_gmt' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_validate_column_post_modified() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Date_Query( array() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'post_modified', $q->validate_column( 'post_modified' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $wpdb->posts . '.post_modified', $q->validate_column( 'post_modified' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_validate_column_post_modified_gmt() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Date_Query( array() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'post_modified_gmt', $q->validate_column( 'post_modified_gmt' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $wpdb->posts . '.post_modified_gmt', $q->validate_column( 'post_modified_gmt' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_validate_column_comment_date() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Date_Query( array() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'comment_date', $q->validate_column( 'comment_date' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $wpdb->comments . '.comment_date', $q->validate_column( 'comment_date' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_validate_column_comment_date_gmt() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Date_Query( array() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'comment_date_gmt', $q->validate_column( 'comment_date_gmt' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $wpdb->comments . '.comment_date_gmt', $q->validate_column( 'comment_date_gmt' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_validate_column_invalid() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Date_Query( array() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'post_date', $q->validate_column( 'foo' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $wpdb->posts . '.post_date', $q->validate_column( 'foo' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 25775
+ */
+ public function test_validate_column_with_date_query_valid_columns_filter() {
+ $q = new WP_Date_Query( array() );
+
+ add_filter( 'date_query_valid_columns', array( $this, 'date_query_valid_columns_callback' ) );
+
+ $this->assertSame( 'my_custom_column', $q->validate_column( 'my_custom_column' ) );
+
+ remove_filter( 'date_query_valid_columns', array( $this, 'date_query_valid_columns_callback' ) );
+ }
+
+ /**
+ * @ticket 25775
+ */
+ public function test_validate_column_prefixed_column_name() {
+ $q = new WP_Date_Query( array() );
+
+ $this->assertSame( 'foo.bar', $q->validate_column( 'foo.bar' ) );
+ }
+
+ /**
+ * @ticket 25775
+ */
+ public function test_validate_column_prefixed_column_name_with_illegal_characters() {
+ $q = new WP_Date_Query( array() );
+
+ $this->assertSame( 'foo.bar', $q->validate_column( 'f"\'oo\/.b;:()ar' ) );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> public function test_build_value_value_null() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px"> $q = new WP_Date_Query( array() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $q->build_value( 'foo', null ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -902,4 +941,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( @$this->q->validate_date_values( array( 'dayofyear' => $day_of_year ) ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /** Helpers **********************************************************/
+
+ public function date_query_valid_columns_callback( $columns ) {
+ $columns[] = 'my_custom_column';
+ return $columns;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsquerydateQueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/query/dateQuery.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/query/dateQuery.php 2014-10-17 00:40:06 UTC (rev 29932)
+++ trunk/tests/phpunit/tests/query/dateQuery.php 2014-10-17 01:19:03 UTC (rev 29933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -610,6 +610,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_date_params_monthnum_m_duplicate() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->create_posts();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $posts = $this->_get_query_result( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -629,11 +631,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertContains( "MONTH( post_date ) = 5", $this->q->request );
- $this->assertNotContains( "MONTH( post_date ) = 9", $this->q->request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertContains( "MONTH( $wpdb->posts.post_date ) = 5", $this->q->request );
+ $this->assertNotContains( "MONTH( $wpdb->posts.post_date ) = 9", $this->q->request );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_date_params_week_w_duplicate() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->create_posts();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $posts = $this->_get_query_result( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -652,11 +656,43 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertContains( "WEEK( post_date, 1 ) = 21", $this->q->request );
- $this->assertNotContains( "WEEK( post_date, 1 ) = 22", $this->q->request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertContains( "WEEK( $wpdb->posts.post_date, 1 ) = 21", $this->q->request );
+ $this->assertNotContains( "WEEK( $wpdb->posts.post_date, 1 ) = 22", $this->q->request );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 25775
+ */
+ public function test_date_query_with_taxonomy_join() {
+ $p1 = $this->factory->post->create( array(
+ 'post_date' => '2013-04-27 01:01:01',
+ ) );
+ $p2 = $this->factory->post->create( array(
+ 'post_date' => '2013-03-21 01:01:01',
+ ) );
+
+ register_taxonomy( 'foo', 'post' );
+ wp_set_object_terms( $p1, 'bar', 'foo' );
+
+ $posts = $this->_get_query_result( array(
+ 'date_query' => array(
+ 'year' => 2013,
+ ),
+ 'tax_query' => array(
+ array(
+ 'taxonomy' => 'foo',
+ 'terms' => array( 'bar' ),
+ 'field' => 'name',
+ ),
+ ),
+ ) );
+
+ _unregister_taxonomy( 'foo' );
+
+ $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * @ticket 29822
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_date_query_one_nested_query() {
</span></span></pre>
</div>
</div>
</body>
</html>