Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 9 years ago

#15032 closed enhancement (wontfix)

WP_Object_Query

Reported by: scribu's profile scribu Owned by: scribu's profile scribu
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: ongoing-project
Focuses: 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 14 years ago.

Download all attachments as: .zip

Change History (27)

#1 @scribu
14 years ago

  • Type changed from defect (bug) to enhancement

#2 @scribu
14 years ago

  • Description modified (diff)

@scribu
14 years ago

#3 @scribu
14 years ago

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

#4 @scribu
14 years ago

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

#5 in reply to: ↑ description ; follow-up: @filosofo
14 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.

#6 @filosofo
14 years ago

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.

#7 in reply to: ↑ 5 @scribu
14 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. :)

#8 @jacobsantos
14 years ago

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.

#9 @scribu
14 years ago

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

#10 @scribu
14 years ago

(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.

#11 @scribu
14 years ago

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

#12 @scribu
14 years ago

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

#13 @scribu
14 years ago

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

#14 @scribu
14 years ago

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

#15 @scribu
14 years ago

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

#16 @scribu
14 years ago

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

#17 @scribu
14 years ago

  • Keywords ongoing-project added; has-patch removed

#18 @scribu
14 years ago

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

#19 @scribu
14 years ago

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

#20 @scribu
14 years ago

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

#21 @scribu
14 years ago

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

#22 @scribu
14 years ago

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

#23 @scribu
14 years ago

  • Milestone 3.1 deleted
  • Resolution set to wontfix
  • Status changed from accepted to closed

#24 @ramiy
11 years ago

Related: #24826

Overlap between WP_Query and WP_User_Query and WP_Comment_Query.

#25 @DrewAPicture
11 years ago

  • Cc xoodrew@… added

This ticket was mentioned in Slack in #core by wonderboymusic. View the logs.


9 years ago

Note: See TracTickets for help on using tickets.