Scott Taylor
60b0cd7943
The keyword elseif
should be used instead of else if
so that all control keywords look like single words.
...
This was a mess, is now standardized across the codebase, except for a few 3rd-party libs.
See #30799 .
Built from https://develop.svn.wordpress.org/trunk@31090
git-svn-id: http://core.svn.wordpress.org/trunk@31071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-08 07:05:25 +00:00
Scott Taylor
42f5acd869
Improve some docs for @param
. Remove an unneeded $wpdb
global import.
...
See #30799 .
Built from https://develop.svn.wordpress.org/trunk@30979
git-svn-id: http://core.svn.wordpress.org/trunk@30965 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-20 20:56:22 +00:00
Boone Gorges
5eeea164ef
In WP_Meta_Query
, interpret 'value' correctly when used with EXISTS/NOT EXISTS.
...
As in earlier versions, EXISTS with a value is equivalent to '=', while NOT
EXISTS should always ignore 'value'.
Props barrykooij.
Fixes #30681 for trunk.
Built from https://develop.svn.wordpress.org/trunk@30846
git-svn-id: http://core.svn.wordpress.org/trunk@30836 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-14 19:01:26 +00:00
Drew Jaynes
23707b1ada
Convert various uses of (optional)
in core parameter descriptions to use the style prescribed in the inline documentation standards for PHP.
...
The style for marking parameters optional in inline PHP docs is: `@param type $var Optional. Description. Accepts. Default.`, where Accepts can be omitted on a case-by-case basis.
Props coffee2code.
Fixes #30591 .
Built from https://develop.svn.wordpress.org/trunk@30753
git-svn-id: http://core.svn.wordpress.org/trunk@30743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-06 21:24:45 +00:00
John Blackbourn
d28823df33
Revert r30115 which was a breaking change for code which interacts with the return value of get_metadata()
when no meta key is specified.
...
See #15030
Built from https://develop.svn.wordpress.org/trunk@30701
git-svn-id: http://core.svn.wordpress.org/trunk@30691 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-02 03:35:22 +00:00
Scott Taylor
a0df295f5c
Improve various @param
docs.
...
See #30224 .
Built from https://develop.svn.wordpress.org/trunk@30674
git-svn-id: http://core.svn.wordpress.org/trunk@30664 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-30 23:24:25 +00:00
Drew Jaynes
d6e6dbf086
Docs Formatting: Backtick-escape inline code for all dynamic hook docs in wp-includes/meta.php.
...
Affects DocBlocks for the following hooks:
* `add_{$meta_type}_metadata`
* `add_{$meta_type}_meta`
* `added_{$meta_type}_meta`
* `update_{$meta_type}_metadata`
* `update_{$meta_type}_meta`
* `updated_{$meta_type}_meta`
* `delete_{$meta_type}_metadata`
* `delete_{$meta_type}_meta`
* `deleted_{$meta_type}_meta`
* `get_{$meta_type}_metadata`
* `delete_{$meta_type}meta`
* `deleted_{$meta_type}meta`
* `sanitize_{$meta_type}_meta_{$meta_key}`
See #30552 .
Built from https://develop.svn.wordpress.org/trunk@30655
git-svn-id: http://core.svn.wordpress.org/trunk@30645 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-30 12:03:24 +00:00
Drew Jaynes
f6fd6e09b1
4.1 Docs Audit: Improve inline documentation for various WP_Meta_Query
methods introduced or modified in 4.1.
...
See #30469 .
Built from https://develop.svn.wordpress.org/trunk@30617
git-svn-id: http://core.svn.wordpress.org/trunk@30607 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-28 12:02:22 +00:00
Scott Taylor
106da1e9e6
In WP_Meta_Query->get_sql_for_clause()
, the empty initialization of $where
is dead code and can be removed.
...
See #30224 .
Built from https://develop.svn.wordpress.org/trunk@30163
git-svn-id: http://core.svn.wordpress.org/trunk@30163 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-01 22:03:22 +00:00
Drew Jaynes
a929ac44e1
Relocate hook docs so they directly precede the hook lines moved into foreach statements in [30140].
...
It's necessary for hook docs to directly precede hook lines so the parser can correctly match them up. This change relocates hook docs for `update_{$meta_type}_meta`, `update_postmeta`, `updated_{$meta_type}_meta`, and `updated_postmeta`.
Fixes #11683 .
Built from https://develop.svn.wordpress.org/trunk@30149
git-svn-id: http://core.svn.wordpress.org/trunk@30149 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-01 04:18:23 +00:00
Boone Gorges
c27548265e
Pass all updated meta IDs to filters in update_metadata()
.
...
Props wonderboymusic.
Fixes #11683 .
Built from https://develop.svn.wordpress.org/trunk@30140
git-svn-id: http://core.svn.wordpress.org/trunk@30140 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-01 02:39:24 +00:00
Drew Jaynes
66c47f29bb
Correct references of @uses $wpdb
in core documentation to use @global
.
...
See #30191 , [30105].
Fixes #30217 .
Built from https://develop.svn.wordpress.org/trunk@30122
git-svn-id: http://core.svn.wordpress.org/trunk@30122 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-31 17:56:22 +00:00
Boone Gorges
93ae51e801
Unserialize get_metadata()
results when 'key' is omitted.
...
Props mattkeys, nacin.
Fixes #15030 .
Built from https://develop.svn.wordpress.org/trunk@30115
git-svn-id: http://core.svn.wordpress.org/trunk@30115 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-30 10:25:22 +00:00
Drew Jaynes
f8657d5890
Remove redundant and erroneous @uses
tag from most core inline documentation.
...
Per our inline documentation standards, no further use of the `@uses` tag is recommended as used and used-by relationships can be derived through other means. This removes most uses of the tag in core documentation, with remaining tags to be converted to `@global` or `@see` as they apply.
Fixes #30191 .
Built from https://develop.svn.wordpress.org/trunk@30105
git-svn-id: http://core.svn.wordpress.org/trunk@30105 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-30 01:05:24 +00:00
Boone Gorges
b137059656
Make orderby=meta_value compatible with meta_query when relation=OR.
...
Passing orderby=meta_value and meta_key=foo to WP_Query should require that
each matched post have a meta value with the key 'foo'. To make this
requirement compatible with meta_query params that have the relation OR, we
nest the meta_query param, and join it using AND to a meta_query clause
generated from the meta_key/meta_compare/meta_type query vars.
Fixes #25538 .
Built from https://develop.svn.wordpress.org/trunk@29964
git-svn-id: http://core.svn.wordpress.org/trunk@29711 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-19 18:54:19 +00:00
Boone Gorges
09e1239ad6
Remove redundant table alias check in WP_Meta_Query.
...
Also adds documentation for 'meta_query_find_compatible_table_alias' filter.
See #24093 .
Built from https://develop.svn.wordpress.org/trunk@29953
git-svn-id: http://core.svn.wordpress.org/trunk@29701 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-18 02:22:19 +00:00
Boone Gorges
4ca2996eff
Bail from cleaning meta query clause when it's not an array.
...
Later isset() checks on string values were causing notices on PHP < 5.4.
Props jorbin.
See #29642 .
Built from https://develop.svn.wordpress.org/trunk@29941
git-svn-id: http://core.svn.wordpress.org/trunk@29692 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-17 20:25:19 +00:00
Boone Gorges
9345e9ffa5
Overhaul SQL generating logic in WP_Meta_Query to avoid unnecessary table joins.
...
The logic used to generate clause SQL in `WP_Meta_Query` is somewhat arcane,
stemming mostly from an ongoing effort to eliminate costly table joins when
they are not necessary. By systematizing the process of looking for shareable
joins - as was done in `WP_Tax_Query` [29902] - it becomes possible to simplify
the construction of SQL queries in `get_sql_for_clause()`. Moreover, the
simplified logic is actually considerably better at identifying shareable
joins, such that certain uses of `WP_Meta_Query` will see joins reduced by 50%
or more.
Includes integration tests for a representative cross-section of the query
clause combinations that result in shared table aliases.
Props boonebgorges, sc0ttkclark.
See #24093 .
Built from https://develop.svn.wordpress.org/trunk@29940
git-svn-id: http://core.svn.wordpress.org/trunk@29691 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-17 20:21:18 +00:00
Boone Gorges
d64b1ed955
Use only LEFT JOINs when a meta_query contains a NOT EXISTS clause.
...
Mixing LEFT and INNER JOIN in these cases results in posts with no metadata
being improperly excluded from results.
Props johnrom.
Fixes #29062 .
Built from https://develop.svn.wordpress.org/trunk@29890
git-svn-id: http://core.svn.wordpress.org/trunk@29646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 02:17:18 +00:00
Boone Gorges
d1d9915f07
Introduce support for nested queries in WP_Meta_Query.
...
Previously, meta query arguments could be joined by a single AND or OR relation.
Now, these queries can be arbitrarily nested, allowing clauses to be linked
together with multiple relations.
Adds unit tests for the new nesting syntax. Modifies a few existing unit tests
that were overly specific for the old SQL syntax. Backward compatibility with
existing syntax is fully maintained.
Props boonebgorges, DrewAPicture.
See #29642 .
Built from https://develop.svn.wordpress.org/trunk@29887
git-svn-id: http://core.svn.wordpress.org/trunk@29643 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-13 22:03:18 +00:00
Andrew Nacin
9cbad29eb8
Meta Query: Revert [28659] (and [28665]) due to regressions.
...
props boonebgorges.
fixes #29285 . see #25538 .
Built from https://develop.svn.wordpress.org/trunk@29650
git-svn-id: http://core.svn.wordpress.org/trunk@29424 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-27 20:23:16 +00:00
Scott Taylor
eb66e40790
After [29339] and [29341], add more unit tests and less ambiguous type-checking before bailing in meta-related functions that expect a numeric value for $object_id
.
...
Props SergeyBiryukov.
Fixes #28315 .
Built from https://develop.svn.wordpress.org/trunk@29421
git-svn-id: http://core.svn.wordpress.org/trunk@29199 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-06 22:08:16 +00:00
Scott Taylor
0d2a5c437e
Bail on update_user_meta()
when $object_id
is non-numeric.
...
Adds unit test.
Props jacklenox, wonderboymusic.
Fixes #28315 .
Built from https://develop.svn.wordpress.org/trunk@29339
git-svn-id: http://core.svn.wordpress.org/trunk@29119 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-01 17:10:15 +00:00
Scott Taylor
05eeb16e30
Replace all uses of like_escape()
with $wpdb->esc_like()
.
...
Props miqrogroove.
See #10041 .
Built from https://develop.svn.wordpress.org/trunk@28712
git-svn-id: http://core.svn.wordpress.org/trunk@28528 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-10 00:44:15 +00:00
Scott Taylor
38819880ec
Wrap individual meta query WHERE
clases in parens, missed in 28659
.
...
Props boonebgorges.
Fixes #25538 .
Built from https://develop.svn.wordpress.org/trunk@28665
git-svn-id: http://core.svn.wordpress.org/trunk@28483 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-04 18:21:15 +00:00
Scott Taylor
a7c2180672
Fix SQL generation when meta_query
has an 'relation' => 'OR'
for its queries and wants to 'orderby' => 'meta_value'
.
...
Adds unit test.
Props jackreichert.
Fixes #25538 .
Built from https://develop.svn.wordpress.org/trunk@28659
git-svn-id: http://core.svn.wordpress.org/trunk@28477 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-04 05:48:14 +00:00
Scott Taylor
b539c1cd76
Add missing access modifiers to methods in WP_Meta_Query
.
...
See #27881 , #22234 .
Built from https://develop.svn.wordpress.org/trunk@28522
git-svn-id: http://core.svn.wordpress.org/trunk@28348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-19 06:35:14 +00:00
Scott Taylor
b2b25f7326
In update_metadata_by_mid()
, $original_value
is unused.
...
See #27882 .
Built from https://develop.svn.wordpress.org/trunk@28328
git-svn-id: http://core.svn.wordpress.org/trunk@28156 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-06 21:29:26 +00:00
Drew Jaynes
a10a55cf87
Fix a typo in the deleted_{$meta_type}_meta
hook description.
...
Props aliso.
Fixes #25826 .
Built from https://develop.svn.wordpress.org/trunk@27723
git-svn-id: http://core.svn.wordpress.org/trunk@27560 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-25 20:34:15 +00:00
Drew Jaynes
97958a3c16
Inline documentation for hooks in wp-includes/meta.php.
...
Props raamdev and kpdesign.
Fixes #25826 .
Built from https://develop.svn.wordpress.org/trunk@27698
git-svn-id: http://core.svn.wordpress.org/trunk@27537 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-25 08:56:14 +00:00
Scott Taylor
0115ba2f30
When using meta_query
in a WP_Query
, passing NOT EXISTS
or ''
to compare
should not require value
to be set. The resulting SQL should then produce the appropriate OR
clause for existence of non-existence after passing the query to the $key_only_queries
stack internally.
...
Adds unit tests.
Props chrisguitarguy, for the original patch.
Fixes #23268 .
Built from https://develop.svn.wordpress.org/trunk@27689
git-svn-id: http://core.svn.wordpress.org/trunk@27528 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-24 19:57:15 +00:00
Andrew Nacin
0e2a70e8f5
Return false from metadata_exists() if the get_$type_metadata filter returns a false value.
...
props xknown.
fixes #22746 .
Built from https://develop.svn.wordpress.org/trunk@27562
git-svn-id: http://core.svn.wordpress.org/trunk@27405 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-17 19:40:16 +00:00
Sergey Biryukov
ab8847316c
Correct return values for update_metadata() and related functions.
...
fixes #21864 .
Built from https://develop.svn.wordpress.org/trunk@27191
git-svn-id: http://core.svn.wordpress.org/trunk@27050 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-18 21:36:14 +00:00
Scott Taylor
05b22769e9
In update_meta_cache()
, ensure that meta is always stored in the same order. Removes an unnecessary $wpdb->prepare
statement. Adds unit test.
...
Props mattheu.
Fixes #25511 .
Built from https://develop.svn.wordpress.org/trunk@26307
git-svn-id: http://core.svn.wordpress.org/trunk@26211 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-21 19:31:10 +00:00
Scott Taylor
53a2c3a181
Produce proper CAST
for DECIMAL
and NUMERIC
in Meta Query. Adds a bunch of unit tests.
...
Props ericlewis.
Fixes #23033 .
Built from https://develop.svn.wordpress.org/trunk@26055
git-svn-id: http://core.svn.wordpress.org/trunk@25980 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-08 23:11:08 +00:00
Scott Taylor
5129b9d0ff
Respect the compare
operator value in meta_query
when value
evaluates to null
. Adds Unit Test.
...
Props bradyvercher, gradyetc.
Fixes #22967 .
Built from https://develop.svn.wordpress.org/trunk@26053
git-svn-id: http://core.svn.wordpress.org/trunk@25978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-08 22:52:08 +00:00
Andrew Nacin
4ea86c6b47
Return false in update_metadata() and update_metadata_by_mid() when the DB query fails.
...
props leewillis77.
fixes #24933 .
Built from https://develop.svn.wordpress.org/trunk@25583
git-svn-id: http://core.svn.wordpress.org/trunk@25500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-23 20:31:09 +00:00
Andrew Nacin
d814ad50b3
Add REGEXP to meta queries.
...
"REGEXP is usually a terrible idea to use, but I see no reason to disallow it."
props wonderboymusic.
fixes #18736 .
Built from https://develop.svn.wordpress.org/trunk@25525
git-svn-id: http://core.svn.wordpress.org/trunk@25445 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-20 20:13:09 +00:00
Scott Taylor
8038d7f9e8
Move get_meta_type()
into the WP_Meta_Query
class as get_cast_for_type()
. WP_Query
can then access it like: $this->meta_query->get_cast_for_type()
.
...
See #21621 , [25255].
Built from https://develop.svn.wordpress.org/trunk@25269
git-svn-id: http://core.svn.wordpress.org/trunk@25235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-05 23:32:09 +00:00
Scott Taylor
4be84bbdfb
When meta_type
is passed with orderby => meta_value
, orderby
must also use CAST()
to avoid scenarios like: SELECT
ing by UNSIGNED
and then ordering by CHAR
. Adds unit test.
...
Fixes #21621 .
Built from https://develop.svn.wordpress.org/trunk@25255
git-svn-id: http://core.svn.wordpress.org/trunk@25223 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-05 16:57:08 +00:00
Scott Taylor
a9dc60c9a8
Improve inline docs for function params that can be serialized when non-scalar. Fixes #18488 .
...
Built from https://develop.svn.wordpress.org/trunk@25076
git-svn-id: http://core.svn.wordpress.org/trunk@25061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-21 21:11:09 +00:00
Andrew Nacin
4fd4d4452f
Use sanitize_key() instead of esc_sql() when 'escaping' variable DB field names. see #21767 .
...
git-svn-id: http://core.svn.wordpress.org/trunk@24714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-16 14:21:05 +00:00
Sergey Biryukov
6c89e06a2a
Avoid an undefined index notice. props DrewAPicture. fixes #22096 .
...
git-svn-id: http://core.svn.wordpress.org/trunk@24580 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-08 01:49:13 +00:00
Mark Jaquith
24ac7c4ac5
Prevent invalid queries in certain empty-array-passing meta_query cases.
...
fixes #22096 . props wonderboymusic.
git-svn-id: http://core.svn.wordpress.org/trunk@24563 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-05 16:40:46 +00:00
Sergey Biryukov
58c364947f
PHPDoc fixes and additions. fixes #24616 .
...
git-svn-id: http://core.svn.wordpress.org/trunk@24490 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-06-21 12:45:11 +00:00
Ryan Boren
15a06a35ab
Use wp_unslash() instead of stripslashes() and stripslashes_deep(). Use wp_slash() instead of add_magic_quotes().
...
see #WP21767
git-svn-id: http://core.svn.wordpress.org/trunk@23591 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-03 16:30:38 +00:00
Ryan Boren
43a7e695e9
Revert 23416, 23419, 23445 except for wp_reset_vars() changes. We are going a different direction with the slashing cleanup, so resetting to a clean slate. see #21767
...
git-svn-id: http://core.svn.wordpress.org/trunk@23554 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-01 16:28:40 +00:00
Ryan Boren
cc5ed3a485
Change all core API to expect unslashed rather than slashed arguments.
...
The exceptions to this are update_post_meta() and add_post_meta() which are often used by plugins in POST handlers and will continue accepting slashed data for now.
Introduce wp_upate_post_meta() and wp_add_post_meta() as unslashed alternatives to update_post_meta() and add_post_meta(). These functions could become methods in WP_Post so don't use them too heavily yet.
Remove all escape() calls from wp_xmlrpc_server. Now that core expects unslashed data this is no longer needed.
Remove addslashes(), addslashes_gpc(), add_magic_quotes() calls on data being prepared for handoff to core functions that until now expected slashed data. Adding slashes in no longer necessary.
Introduce wp_unslash() and use to it remove slashes from GPCS data before using it in core API. Almost every instance of stripslashes() in core should now be wp_unslash(). In the future (a release or three) when GPCS is no longer slashed, wp_unslash() will stop stripping slashes and simply return what is passed. At this point wp_unslash() calls can be removed from core.
Introduce wp_slash() for slashing GPCS data. This will also turn into a noop once GPCS is no longer slashed. wp_slash() should almost never be used. It is mainly of use in unit tests.
Plugins should use wp_unslash() on data being passed to core API.
Plugins should no longer slash data being passed to core. So when you get_post() and then wp_insert_post() the post data from get_post() no longer needs addslashes(). Most plugins were not bothering with this. They will magically start doing the right thing. Unfortunately, those few souls who did it properly will now have to avoid calling addslashes() for 3.6 and newer.
Use wp_kses_post() and wp_kses_data(), which expect unslashed data, instead of wp_filter_post_kses() and wp_filter_kses(), which expect slashed data. Filters are no longer passed slashed data.
Remove many no longer necessary calls to $wpdb->escape() and esc_sql().
In wp_get_referer() and wp_get_original_referer(), return unslashed data.
Remove old stripslashes() calls from WP_Widget::update() handlers. These haven't been necessary since WP_Widget.
Switch several queries over to prepare().
Expect something to break.
Props alexkingorg
see #21767
git-svn-id: http://core.svn.wordpress.org/trunk@23416 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-02-14 22:51:06 +00:00
Mark Jaquith
cd250fa7df
Defer the meta_id-fetching query until after comparison of the previous value, so that redundant calls to update_metadata() can bail without making that query. props nacin. fixes #22191
...
git-svn-id: http://core.svn.wordpress.org/trunk@22231 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-15 05:51:38 +00:00
Ryan Boren
778ba1c1b2
Improve performance of WP_Meta_Query when doing OR queries on meta keys. Props joehoyle, SergeyBiryukov. fixes #19729
...
git-svn-id: http://core.svn.wordpress.org/trunk@22103 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-03 12:35:06 +00:00