Opened 3 years ago
Last modified 7 weeks ago
#58180 new enhancement
Specify the REGEXP format for meta_query
| Reported by: | letraceursnork | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Database | Version: | 6.2 |
| Severity: | trivial | Keywords: | needs-docs dev-feedback has-patch |
| Cc: | Focuses: |
Description
Because of the fact that meta_query parameter with ['compare' => 'REGEXP', 'key' => 'foo', 'value' => '^bar'] working as substitution to raw SQL-request like ... foo.meta_key REGEXP ^bar ...
please, specify this explicitly in the documentation - especially the fact that this REGEXP should not be wrapped in /
Change History (3)
This ticket was mentioned in PR #12072 on WordPress/wordpress-develop by @patrickfl.
7 weeks ago
#3
- Keywords has-patch added
When a meta_query clause uses 'compare' => 'REGEXP' (or 'NOT REGEXP' / 'RLIKE'), the value is passed directly to MySQL's REGEXP operator. This is not obvious from the DocBlock, and a common mistake is to wrap the pattern in PCRE-style delimiters (e.g. /^bar/), which MySQL treats as literal characters.
This adds a note to the $value parameter in the WP_Meta_Query DocBlock clarifying that for the REGEXP-family compares the value is used as a raw MySQL regular expression and should not be wrapped in delimiters such as /.
Documentation only; no behavioral change.
Props letraceursnork.
Fixes #58180.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
@SergeyBiryukov check this out pls