For WP 4.1, I’ll be working on improvements to
WP_Date_Query, the Three Tenors Three Stooges Three Amigos of WordPress. Here’s a summary of the proposed changes, with some notes about where help is needed.
Unit test Code written to test a small piece of code or functionality within a larger application. Everything from themes to WordPress core have a series of unit tests. Also see regression. coverage
Test coverage for these three classes has historically been pretty spotty, but is absolutely critical for any meaningful refactoring to take place. I’ve meticulously picked over them and created a set of comprehensive tests for each one (#29560, #29718, #29781). Coverage is now quite good, but more eyes are always welcome.
Multi-relational and nested queries
All three classes currently accept a ‘relation’ parameter, which allows multiple query clauses to be joined with
OR. So, for instance, you can query for: posts that are in the ‘Boone’ category The 'category' taxonomy lets you group posts / content together that share a common bond. Categories are pre-defined and broad ranging. AND have the tag A directory in Subversion. WordPress uses tags to store a single snapshot of a version (3.6, 3.6.1, etc.), the common convention of tags in version control systems. (Not to be confused with post tags.) ‘Awesome’ AND do not have the term ‘Raphael’ in the
favorite_turtle taxonomy A taxonomy is a way to group things together. In WordPress, some common taxonomies are category, link, tag, or post format. https://codex.wordpress.org/Taxonomies#Default_Taxonomies.. But this syntax only allows for so much expressiveness: you can’t mix AND and OR, and you can’t group clauses. These limitations make it difficult to use these queries in support of complex content filtering – like you might need, say, if you’re using WordPress to power the inventory system for an online store.
For 4.1, I’ll be working on allowing the necessary syntax for multi-relation queries that can be grouped and nested to an arbitrary depth. See the following tickets for patches and discussion:
- #29642 Meta Meta is a term that refers to the inside workings of a group. For us, this is the team that works on internal WordPress sites like WordCamp Central and Make WordPress.
- #29738 Tax
- #29822 Date
Much of the infrastructure that will support the new syntax will be shared between the classes. If you’re familiar with current
WP_*_Query internals, you may want to check out the patches and join the discussion at the WP_Meta_Query ticket, which is the furthest along of the three classes in this refactoring process.
Once the changes discussed above are in place, there are a number of smaller but equally lovely improvements I’d like to begin addressing:
- #29181 ‘EXISTS’ and ‘NOT EXISTS’ operators for
WP_Date_Query across tables
- #24093 Improve
WP_Meta_Query performance by switching to subqueries rather than table joins. This is one where we could use lots of testing; if you know how to set up a VM with an old version of MySQL MySQL is a relational database management system. A database is a structured collection of data where content, configuration and other options are stored. https://www.mysql.com/., then your help would be appreciated.
Do you have other ideas for how these three classes could be improved in 4.1 and beyond?