Opened 14 years ago
Closed 3 weeks ago
#15249 closed enhancement (maybelater)
Filtering get_search_sql for advanced queries
Reported by: | sc0ttkclark | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.1 |
Component: | Query | Keywords: | needs-patch needs-unit-tests |
Focuses: | Cc: |
Description
Currently in the code for 3.1 (trunk) there are no filters running on the new function get_search_sql which would be useful for plugins to perform more complex MySQL functionality on specific columns.
I suggest adding a filter ;)
Attachments (7)
Change History (29)
#4
@
14 years ago
For search, we already have the 'posts_search' filter. Should figure out what to do with that.
#5
@
14 years ago
In both cases (comment.php / user.php within /wp-includes/), as long as the array passed to get_search_sql is within $this then it can be useful as it is now there is no information available as to what fields are being searched unless the dev copies that code - making it less future proof. Thoughts?
#6
@
14 years ago
- Keywords has-patch needs-review added
Added patch that includes the new filters for Users / Comments - implemented in comment.php and user.php (not within get_search_sql function itself due to the lack of information the function is given like no access to $this)
#7
@
14 years ago
- Keywords 3.2-early added
- Milestone changed from Awaiting Review to Future Release
All the Search SQL's should have consistent filters to allow for other search engines to be droped in amongst other things.
This needs a review to ensure that all required locations are changed.
#9
@
12 years ago
- Keywords dev-feedback added; needs-review 3.2-early removed
Refreshed the patch on this ticket for 3.5
#12
@
11 years ago
- Focuses docs added
- Keywords needs-docs added; dev-feedback removed
- Milestone changed from Future Release to 4.0
Refreshed against our new code structure. These need filter docs.
#14
follow-up:
↓ 15
@
11 years ago
- Keywords 2nd-opinion added; commit removed
What would be a use case for these filters?
We already have comments_clauses and pre_user_query. We've also added user_search_columns in 3.6.
#15
in reply to:
↑ 14
@
10 years ago
Replying to SergeyBiryukov:
What would be a use case for these filters?
In retrospect, I'd kind of like to see a consistent approach taken with search SQL filters as alluded to by @dd32 in comment:7. Maybe even a single get_search_sql
filter with multiple contexts.
#16
@
10 years ago
+1 on get_search_sql single filter
The use case here is for plugins like Pods which may add additional tables to WordPress, to be able to further refine a query to search values in the related table. For instance, someone can extend a Post Type with a table-based Pod, which lets you essentially create a table that contains columns of custom fields and only those fields that you need (each table has a matching id column that matches up to wp_posts).
So, you could provide those custom fields in your query as normal, and Pods will detect if they are covered by the separate table or not, and adjust the query as needed, to be able to join it's table by ID and search that custom field column.
#17
@
10 years ago
- Focuses docs removed
@sc0ttkclark: Would you care to patch up a single hook approach instead?
At the moment, it appears this function has disappeared from trunk for whatever reason. It's no longer in /wp-includes/classes.php so I'll keep an eye out for where it's being moved to before patching.