Opened 3 years ago

Closed 3 years ago

#15032 closed enhancement (wontfix)

WP_Object_Query

Reported by: scribu Owned by: scribu
Priority: normal Milestone:
Component: General Version:
Severity: normal Keywords: ongoing-project
Cc:

Description (last modified by scribu)

There's a lot of overlap between WP_Query and WP_User_Query.

It would be good if they both inherited from a general WP_Object_Query, which would handle taxonomy and meta queries.

We could then more easily create a WP_Comment_Query class, for example, which would further reduce code duplication.

Attachments (1)

15032.diff (7.6 KB) - added by scribu 3 years ago.

Download all attachments as: .zip

Change History (24)

  • Type changed from defect (bug) to enhancement
  • Description modified (diff)

scribu3 years ago

  • Keywords has-patch added
  • Milestone changed from Future Release to 3.1
  • Owner set to scribu
  • Status changed from new to accepted

(In [15715]) Introduce WP_Object_Query. See #15032

comment:5 in reply to: ↑ description ; follow-up: ↓ 7   filosofo3 years ago

Replying to scribu:

There's a lot of overlap between WP_Query and WP_User_Query.

It would be good if they both inherited from a general WP_Object_Query, which would handle taxonomy and meta queries.

I don't understand the point of the inheritance here. Usually, inheritance involves substantial properties or behavior to be inherited; here, WP_Object_Query has two (private) methods and a property. There's nothing to speak of being inherited; there's no expected re-use of the private methods for any given object; its code re-use could easily be done with a couple of functions.

Also, the name is misleading. Both of WP_Object_Query's methods and its one property have to do with the object's meta information, not the object proper.

Also, shouldn't get_meta_sql be named something like get_intersecting_meta_sql or the like? Something like get_unioned_meta_sql seems like the next logical, additional function or method.

comment:7 in reply to: ↑ 5   scribu3 years ago

Replying to filosofo:

I don't understand the point of the inheritance here. Usually, inheritance involves substantial properties or behavior to be inherited; here, WP_Object_Query has two (private) methods and a property. There's nothing to speak of being inherited; there's no expected re-use of the private methods for any given object; its code re-use could easily be done with a couple of functions.

I plan to move _wp_search_sql() in it and also the taxonomy stuff, just for starters. You'll see. :)

There is an @access protected. The point of @access really is to tell what the visibility is of the method for PHP4 classes, which doesn't have the keywords to describe it. It is also useful to prevent it from being displayed on phpdocumentor web sites, but its values aren't only private and public.

Yes, it's been addressed in [15723].

(In [15731]) Generalize taxonomy queries:

  • transform wp_tax_query() into WP_Object_Query::get_tax_sql()
  • create parse_tax_query() method in WP_Query
  • add doc-block for $tax_query and $meta_query

See #15032. See #12891.

(In [16018]) Move get() and set() methods from WP_Query to WP_Object_Query. See #15032

(In [16051]) Move WP_Object_Query to it's own file. See #15032

(In [16052]) Remove duplicate file docs. See #15032

(In [16053]) Make get_meta_sql() return associative array. See #15032

(In [16142]) Rename class.wp-object-query.php to class-wp-object-query.php. See #15032

(In [16143]) Just pass meta type to get_meta_sql(). See #15032

  • Keywords ongoing-project added; has-patch removed

(In [16266]) Make get_meta_sql() a standalone function. See #15032

(In [16267]) Make get_tax_sql() a standalone function. See #15032

(In [16351]) Split get_search_sql(). See #15170. See #15032

(In [16352]) Revert most of [16018]. See #15032

(In [16353]) Kill WP_Object_Query. See #15032

  • Milestone 3.1 deleted
  • Resolution set to wontfix
  • Status changed from accepted to closed
Note: See TracTickets for help on using tickets.