Commit Graph

683 Commits

Author SHA1 Message Date
Andrew Nacin
1579e45d41 Simplify the include graph after work to split out classes.
see #33413. More details there.

Built from https://develop.svn.wordpress.org/trunk@35718


git-svn-id: http://core.svn.wordpress.org/trunk@35682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-20 07:24:30 +00:00
Boone Gorges
623e467712 Introduce WP_Term.
`get_term()` now returns a `WP_Term` object, instead of a `stdClass` object.
Cache support and sanitization filters for individual terms are now more
centralized. For example, `get_term_by()` is able to cast results of its query
to a `WP_Term` object by passing it through `get_term()`.

The `$taxonomy` parameter for `get_term()` is now optional, as terms ought to
be unique to a taxonomy (ie, shared terms no longer exist). In cases where
`get_term()` detects that the term matching the specified term_id is from the
wrong taxonomy, it checks to see if you've requested a shared term, and if so,
it splits the term. This is used only for fallback purposes.

The elimination of shared terms allows the caching strategy for terms to be
simplified. Individual terms are now cached in a single 'terms' bucket.

Props flixos90, boonebgorges, scribu, dipesh.kakadiya.
See #14162.
Built from https://develop.svn.wordpress.org/trunk@34997


git-svn-id: http://core.svn.wordpress.org/trunk@34962 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-10 01:59:29 +00:00
Drew Jaynes
24180ac754 Docs: Clarify the file header summary for wp-includes/taxonomy.php, the top-level file for the core Taxonomy API.
See #33413. See #33701.

Built from https://develop.svn.wordpress.org/trunk@34404


git-svn-id: http://core.svn.wordpress.org/trunk@34368 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-22 13:23:25 +00:00
Scott Taylor
fa0dc526f4 Taxonomy: move WP_Tax_Query into its own file. taxonomy.php loads the new files, so this is 100% BC if someone is loading taxonomy.php directly. New files created using svn cp.
Creates: 
`class-wp-tax-query.php` 
`taxonomy-functions.php` 

`taxonomy.php` contains only top-level code. Class file only contains the class. Functions file only contains functions.

See #33413.

Built from https://develop.svn.wordpress.org/trunk@33760


git-svn-id: http://core.svn.wordpress.org/trunk@33728 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-26 12:49:21 +00:00
Dion Hulse
4f8ce1c232 Term Splitting: Switch to a faster cron unschedule process to benefit sites with thousands of affected jobs. Fix the cron hook name in the failsafe rescheduler.
Props Otto42, dd32, peterwilsoncc
See #33423

Built from https://develop.svn.wordpress.org/trunk@33727


git-svn-id: http://core.svn.wordpress.org/trunk@33695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-25 04:32:21 +00:00
Drew Jaynes
ea4f27f519 Docs: Add better documentation for all accepted values for the fields argument in get_terms().
See #32246.

Built from https://develop.svn.wordpress.org/trunk@33715


git-svn-id: http://core.svn.wordpress.org/trunk@33682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-23 17:40:24 +00:00
Boone Gorges
dc0e7671b0 In wp_delete_term(), the $deleted_term object passed to filters should be generated before term relationships are deleted.
This allows the `count` property to reflect the pre-delete state of affairs,
rather than always being 0.

Props nicholas_io.
Fixes #33485.
Built from https://develop.svn.wordpress.org/trunk@33711


git-svn-id: http://core.svn.wordpress.org/trunk@33678 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-22 19:43:26 +00:00
Boone Gorges
bc592af91f wp_update_term() should return a true integer for 'term_taxonomy_id'.
Props ipm-frommen.
Fixes #32876.
Built from https://develop.svn.wordpress.org/trunk@33652


git-svn-id: http://core.svn.wordpress.org/trunk@33619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-19 19:33:24 +00:00
Dion Hulse
25c5d372d3 Term Splitting: Fix a reversal of parameters to wp_schedule_single_event() introduced in [33621].
The existing invalid cron entries will not be purged automatically (as the 'timestamp' is never matched) so we do this ourselves.

Props mechter for noticing!
See #30261.
Fixes #33423 for trunk.

Built from https://develop.svn.wordpress.org/trunk@33646


git-svn-id: http://core.svn.wordpress.org/trunk@33613 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-19 11:31:26 +00:00
Boone Gorges
52a7082d11 Don't suspend cache invalidation when running term splitting batch routine.
`wp_suspend_cache_invalidation()` was originally added to increase performance,
but the switch to batch processing in [33615] mitigates serious performance
concerns.

As a precaution against timeouts, the batch size has been reduced from 20 to 10.

Props Chouby.
See #30261.
Built from https://develop.svn.wordpress.org/trunk@33619


git-svn-id: http://core.svn.wordpress.org/trunk@33586 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-15 19:25:26 +00:00
Boone Gorges
151d27369d Term splitting routine should be run in a separate process, triggered via wp-cron.
[32814] introduced a routine to split shared terms, which was run during the
regular WP database upgrade. This turned out to be problematic because plugins
are not loaded during the db upgrade (due to `WP_INSTALLING`), with the result
that plugins were not able to hook into the 'split_shared_term' action during
the bulk split. We work around this limitation by moving the term splitting
routine to a separate process, triggered by a wp-cron hook.

Props boonebgorges, Chouby, peterwilsoncc, pento, dd32.
Fixes #30261.
Built from https://develop.svn.wordpress.org/trunk@33615


git-svn-id: http://core.svn.wordpress.org/trunk@33582 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-14 03:59:26 +00:00
Boone Gorges
2c9e81349c When splitting a shared 'nav_menu' term, ensure that nav items and theme locations are retained.
Props boonebgorges, dd32.
Fixes #33187.
Built from https://develop.svn.wordpress.org/trunk@33611


git-svn-id: http://core.svn.wordpress.org/trunk@33578 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-12 14:07:26 +00:00
Drew Jaynes
137357b769 Fix formatting in the DocBlock for _split_shared_term().
See #32246. See #32891.

Built from https://develop.svn.wordpress.org/trunk@33238


git-svn-id: http://core.svn.wordpress.org/trunk@33210 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-13 21:57:24 +00:00
Boone Gorges
b1bd2e699d Don't allow $field param to be passed to get_term_link().
The new parameter creates inconsistencies in the signatures of the various
functions for fetching term links (`get_term_feed_link()`,
`get_edit_term_link()`, etc.).

Reverts [32553].

See #14156.
Built from https://develop.svn.wordpress.org/trunk@33022


git-svn-id: http://core.svn.wordpress.org/trunk@32993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-01 12:54:25 +00:00
John Blackbourn
b5973e92ec Introduce a no_terms label for taxonomies. This label is used when indicating that there are no terms in the given taxonomy associated with an object.
Fixes #32150
Props afercia

Built from https://develop.svn.wordpress.org/trunk@32933


git-svn-id: http://core.svn.wordpress.org/trunk@32904 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-25 00:16:27 +00:00
Boone Gorges
03be8647c5 Fix PHP notice in WP_Tax_Query::get_sql_for_clause().
Previously, the `$where` variable was not initialized, so that when an invalid
'operator' was passed, PHP would complain that `$where` was undefined.

Props dlh.
Fixes #32756.
Built from https://develop.svn.wordpress.org/trunk@32910


git-svn-id: http://core.svn.wordpress.org/trunk@32881 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-23 12:44:27 +00:00
Scott Taylor
5e994cd6a1 Customizer et al, use elseif in PHP, not else if.
This was corrected via brute force in [31090].

See #32444.

Built from https://develop.svn.wordpress.org/trunk@32874


git-svn-id: http://core.svn.wordpress.org/trunk@32845 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-19 22:01:25 +00:00
Boone Gorges
6105fca015 Add filters to wp_unique_term_slug().
This changeset adds two new filters:
* 'wp_unique_term_slug_is_bad_slug' lets developers control whether a test slug needs to be made unique, before the queries required to build a suffix are performed.
* 'wp_unique_term_slug' filters the output of the function.

These changes introduce parity with the filters in `wp_unique_post_slug()`.

Props coffee2code, bolo1988, boonebgorges.
Fixes #20783.
Built from https://develop.svn.wordpress.org/trunk@32837


git-svn-id: http://core.svn.wordpress.org/trunk@32808 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-18 13:20:26 +00:00
Boone Gorges
cf7e00ed9f Performance enhancements for _split_shared_term().
* Introduce a `$record` parameter, which defaults to true. When set to false, `_split_shared_term()` will not keep a record of split term data in wp_options. The judicious use of this flag can greatly improve performance when processing shared terms in batches.
* Allow term/tt objects to be passed to the `$term_id` and `$term_taxonomy_id` parameters. This has the potential to save database queries when the objects are already available.

See #30261.
Built from https://develop.svn.wordpress.org/trunk@32813


git-svn-id: http://core.svn.wordpress.org/trunk@32784 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 01:48:28 +00:00
Boone Gorges
e8ad0ff400 Filter out empty object_types in register_taxonomy_for_object_type().
This prevents weird edge bugs when registering an existing taxonomy with an
object type when the taxonomy was previously associated with no object types.

Fixes #32590.
Built from https://develop.svn.wordpress.org/trunk@32709


git-svn-id: http://core.svn.wordpress.org/trunk@32679 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-08 19:45:31 +00:00
Scott Taylor
4777433584 Add missing doc blocks to taxonomy.php.
Correct some `@return` values.
Some functions can `return new WP_Error` without setting it to a variable.
Some functions can return their `apply_filters(...)` call without first setting it to a variable.
`is_object_in_taxonomy()` can return its conditional instead of if/else true/false.
 
See #32444.

Built from https://develop.svn.wordpress.org/trunk@32627


git-svn-id: http://core.svn.wordpress.org/trunk@32597 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-27 22:00:25 +00:00
Boone Gorges
10dd80cc61 Introduced $field argument to get_term_link().
This new argument allows developers to specify which term field should be
matched by the value of the `$term` parameter (in particular, 'name' and
'term_taxonomy_id' are now supported).

Props sudar, mordauk.
Fixes #14156.
Built from https://develop.svn.wordpress.org/trunk@32553


git-svn-id: http://core.svn.wordpress.org/trunk@32523 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-23 18:29:26 +00:00
Boone Gorges
63eb910445 Respect $_wp_suspend_cache_invalidation in clean_term_cache().
Props tollmanz, rmccue.
Fixes #28743.
Built from https://develop.svn.wordpress.org/trunk@32498


git-svn-id: http://core.svn.wordpress.org/trunk@32468 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-12 20:14:26 +00:00
Drew Jaynes
674e47cc89 Fix a wide variety of syntactical, spacing, wording, and other issues in wp-includes/taxonomy.php.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@32453


git-svn-id: http://core.svn.wordpress.org/trunk@32423 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-07 20:37:41 +00:00
Drew Jaynes
3050d96310 Ensure the optional parameter in get_object_taxonomies() is documented as such.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@32452


git-svn-id: http://core.svn.wordpress.org/trunk@32422 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-07 20:37:17 +00:00
Drew Jaynes
b801f6f230 Add a description to the hook documentation for the created_$taxonomy action to clarify the dynamic portion of the hook name.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@32451


git-svn-id: http://core.svn.wordpress.org/trunk@32421 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-07 20:36:53 +00:00
Drew Jaynes
948186df0b Add missing parameter descriptions to the created_term hook documentation.
Props dlh.
Fixes #32276.

Built from https://develop.svn.wordpress.org/trunk@32450


git-svn-id: http://core.svn.wordpress.org/trunk@32420 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-07 20:36:29 +00:00
Boone Gorges
5c65164ea8 Improve sanitization of 'name' param in get_terms().
Values of 'name' that contain db-encoded character on insert - like an
ampersand, which is HTML-encoded in the database - will only match if they go
through the same `sanitize_term_field()` routine.

Fixes #32248.
Built from https://develop.svn.wordpress.org/trunk@32353


git-svn-id: http://core.svn.wordpress.org/trunk@32324 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-05 11:14:28 +00:00
Drew Jaynes
a3b092843b Add a changelog entry for the $resource_type parameter added to the get_ancestors filter in 4.1.1.
Props dimadin.
See #31925.

Built from https://develop.svn.wordpress.org/trunk@32351


git-svn-id: http://core.svn.wordpress.org/trunk@32322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-05 02:17:25 +00:00
Drew Jaynes
39064bac5e Ensure the optional parameters for get_taxonomies() are documented as such.
See #31800.

Built from https://develop.svn.wordpress.org/trunk@32349


git-svn-id: http://core.svn.wordpress.org/trunk@32320 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-05 02:05:24 +00:00
Drew Jaynes
6c9b20f94c Improve inline documentation in wp-includes/taxonomy.php.
* Adds missing `@since` versions
* Adds `@global` tags and descriptions to DocBlocks where appropriate

Props ChaseWiseman.
See #31800.

Built from https://develop.svn.wordpress.org/trunk@32348


git-svn-id: http://core.svn.wordpress.org/trunk@32319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-05 02:01:25 +00:00
Boone Gorges
af6b4cba24 Remove duplicate semicolon introduced in [32326].
Built from https://develop.svn.wordpress.org/trunk@32327


git-svn-id: http://core.svn.wordpress.org/trunk@32298 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-29 12:58:24 +00:00
Boone Gorges
a20841bc36 Improve performance of loop detection in _get_term_children().
Using an array keyed by term_id allows us to use `isset()` rather than the
slower `in_array()`. In addition, it lets us avoid the use of `wp_list_pluck()`
on large arrays, and helps us to avoid arrays that are unnecessarily large due
to duplicate entries.

Fixes #32144 for trunk.
Built from https://develop.svn.wordpress.org/trunk@32326


git-svn-id: http://core.svn.wordpress.org/trunk@32297 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-29 12:56:25 +00:00
Sergey Biryukov
35c0c59123 Add missing word to wp_insert_term() error strings.
props dipesh.kakadiya.
fixes #32031.
Built from https://develop.svn.wordpress.org/trunk@32297


git-svn-id: http://core.svn.wordpress.org/trunk@32268 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-26 11:50:26 +00:00
Sergey Biryukov
55a1de9b4f wp_update_term() should check if get_term() returned null.
props dlh.
fixes #31954.
Built from https://develop.svn.wordpress.org/trunk@32117


git-svn-id: http://core.svn.wordpress.org/trunk@32096 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-13 01:21:27 +00:00
Drew Jaynes
d9bfc88b8d Fix a variety of inline documentation syntactical issues in wp-includes/taxonomy.php.
See #31888.

Built from https://develop.svn.wordpress.org/trunk@32047


git-svn-id: http://core.svn.wordpress.org/trunk@32026 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-05 17:08:26 +00:00
Drew Jaynes
cedee3dd1c Supplement hook documentation for the get_terms_fields filter to more clearly explain the expected consequences of using it to modify the fields to select in a terms query.
Props boonebgorges.
Fixes #31174.

Built from https://develop.svn.wordpress.org/trunk@31855


git-svn-id: http://core.svn.wordpress.org/trunk@31834 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-20 20:11:26 +00:00
Boone Gorges
0b85f2f7b4 Ensure that the $exclusions parameter of 'list_terms_exclusions' filter is always a string.
Props fhwebcs.
Fixes #31681.
Built from https://develop.svn.wordpress.org/trunk@31813


git-svn-id: http://core.svn.wordpress.org/trunk@31795 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-18 18:23:26 +00:00
Boone Gorges
650ca95b95 In wp_insert_term(), allow a term with an existing name if a unique $slug has been provided.
`wp_insert_term()` protects against the creation of terms with duplicate names
at the same level of a taxonomy hierarchy. However, it's historically been
possible to override this protection by explicitly providing a value of `$slug`
that is unique at the hierarchy tier. This ability was broken in [31734], and
the current changeset restores the original behavior.

A number of unit tests are added and refactored in support of these changes.

See #17689 for discussion of a fix that was superceded by [31734]. This commit
retains the fix for the underlying bug described in that ticket.

See #31328.
Built from https://develop.svn.wordpress.org/trunk@31792


git-svn-id: http://core.svn.wordpress.org/trunk@31774 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-16 11:16:28 +00:00
Gary Pendergast
03ade8c011 Add emoji URL support, and Twemoji fallback for displaying slugs in wp-admin, when the browser doesn't natively support emoji.
Props pento, SergeyBiryukov and boonebgorges.

Fixes #31328


Built from https://develop.svn.wordpress.org/trunk@31734


git-svn-id: http://core.svn.wordpress.org/trunk@31715 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-11 22:55:28 +00:00
Drew Jaynes
6486a233c0 Remove a duplicate mention of the default value for the $number argument in get_terms().
Props iandunn.
Fixes #31526.

Built from https://develop.svn.wordpress.org/trunk@31652


git-svn-id: http://core.svn.wordpress.org/trunk@31633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-07 01:05:26 +00:00
Boone Gorges
3acf36fe48 Ensure that an array of object IDs is passed to the 'get_object_terms' filter.
Originally introduced in [31581].

Props doublesharp.
Fixes #18828.
Built from https://develop.svn.wordpress.org/trunk@31639


git-svn-id: http://core.svn.wordpress.org/trunk@31620 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-06 13:18:26 +00:00
Drew Jaynes
68bbc0e43d Correct the $number argument description in get_terms() to reflect that an empty string or 0 will return all possible results, not -1.
Previously, it was noted that -1 would return all possible results. However, as the value of `$number` is passed through `absint()`, -1 would actually be converted to 1, thereby producing unexpected results.

Props iandunn.
Fixes #31526.

Built from https://develop.svn.wordpress.org/trunk@31638


git-svn-id: http://core.svn.wordpress.org/trunk@31619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-06 08:05:25 +00:00
Boone Gorges
3db78d6a24 Introduce 'get_object_terms' filter in wp_get_object_terms().
The existing 'wp_get_object_terms' filter accepts a parameter `$taxonomies`,
which is a list of taxonomy names formatted for direct use in a MySQL IN clause.
This formatting makes it difficult to make use of the taxonomy list in filter
callbacks. However, changing the parameters passed to the existing filter
raises backward compatibility concerns, so we introduce a new filter that
receives a structured `$taxonomy_array` parameter.

We also take this opportunity to correct and clean up some of the documentation
on the 'wp_get_object_terms' filter.

Props postpostmodern, doublesharp, wonderboymusic, nacin.
Fixes #18828.
Built from https://develop.svn.wordpress.org/trunk@31581


git-svn-id: http://core.svn.wordpress.org/trunk@31562 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-27 20:31:26 +00:00
Boone Gorges
0d9275930b Add 'orderby=description' support to get_terms().
This fixes an interface inconsistency in edit-tags.php, where Description
appears as a sortable column header.

Props neil_pie.
Fixes #31364.
Built from https://develop.svn.wordpress.org/trunk@31532


git-svn-id: http://core.svn.wordpress.org/trunk@31513 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-24 16:37:26 +00:00
Boone Gorges
e89d237b86 Pass taxonomy name, not object, to 'edit_term_taxonomy' and 'edited_term_taxonomy' actions.
These actions are fired in a number of different places, and in some cases
the tax name is passed, while in others the taxonomy object is passed. This
inconsistency made it difficult for plugins to use the `$taxonomy` value.

Props ipm-frommen.
Fixes #30999.
Built from https://develop.svn.wordpress.org/trunk@31525


git-svn-id: http://core.svn.wordpress.org/trunk@31506 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-23 21:08:26 +00:00
John Blackbourn
948f657ea3 Return a WP_Error if an empty name is provided when registering a taxonomy.
Fixes #31135
Props tyxla, MikeHansenMe

Built from https://develop.svn.wordpress.org/trunk@31449


git-svn-id: http://core.svn.wordpress.org/trunk@31430 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-13 16:27:26 +00:00
Boone Gorges
44ac816aed Split shared taxonomy terms on term update.
When updating an existing taxonomy term that shares its `term_id` with
another term, we generate a new row in `wp_terms` and associate the updated
term_taxonomy_id with the new term. This separates the terms, such that
updating the name of one term does not change the name of any others.

In cases where a plugin or theme stores term IDs in the database, term splitting
can cause backward compatibility issues. The current changeset introduces
two utilities to aid developers with the transition. The `'split_shared_term'`
action fires when the split takes place, and should be used to catch changes in
term_id. In cases where `'split_shared_term'` cannot be used, the
`wp_get_split_term()` function gives developers access to data about terms
that have previously been split. Documentation for these functions, with
examples, can be found in the Plugin Developer Handbook. WordPress itself
stores term IDs in this way in two places; `_wp_check_split_default_terms()`
and `_wp_check_split_terms_in_menus()` are hooked to `'split_shared_term'` to
perform the necessary cleanup.

See [30241] for a previous attempt at the split. It was reverted in [30585]
for 4.1.0.

Props boonebgorges, mboynes.
See #5809.
Built from https://develop.svn.wordpress.org/trunk@31418


git-svn-id: http://core.svn.wordpress.org/trunk@31399 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-11 19:42:25 +00:00
Boone Gorges
669fa39005 Late escaping in get_terms() and WP_Tax_Query.
Props vortfu, dd32.
Built from https://develop.svn.wordpress.org/trunk@31367


git-svn-id: http://core.svn.wordpress.org/trunk@31348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-08 01:59:24 +00:00
Sergey Biryukov
09c1d34b96 Remove unnecessary array_shift() usage in get_terms() for better performance.
props bswatson, VolodymyrC.
fixes #31182.
Built from https://develop.svn.wordpress.org/trunk@31365


git-svn-id: http://core.svn.wordpress.org/trunk@31346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-07 19:45:25 +00:00
Boone Gorges
7560f446f9 Use field-specific sanitization in WP_Tax_Query::transform_query().
When terms are entered into the database, term fields are sanitized with
`sanitize_term_field()`. To ensure that the `SELECT ... WHERE` queries in
`WP_Tax_Query::transform_query()` are not broken by overzealous sanitization,
`sanitize_term_field()` should be used in that case as well. This fixes a bug
where a tax_query using 'field=name' would fail if the 'terms' parameter
contained characters (like spaces) that were improperly removed by
`sanitize_title_for_query()`.

Fixes #27810.
Built from https://develop.svn.wordpress.org/trunk@31346


git-svn-id: http://core.svn.wordpress.org/trunk@31327 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-06 02:02:23 +00:00
Boone Gorges
abce542e5f Introduce 'show_in_quick_edit' parameter for register_taxonomy().
Setting 'show_in_quick_edit' to false when registering a custom taxonomy will
hide the taxonomy when editing posts using Quick Edit.

The new 'quick_edit_show_taxonomy' filter allows this behavior to be filtered
on a finer scale, as when you want a given taxonomy to be hidden for one post
type but not for others.

Props hlashbrooke.
Fixes #26948.
Built from https://develop.svn.wordpress.org/trunk@31307


git-svn-id: http://core.svn.wordpress.org/trunk@31288 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-30 19:18:23 +00:00
Boone Gorges
dcca015ffc Don't use term IDs for array indexes when caching object terms.
Uncached results pulled from `wp_get_object_terms()` are zero-indexed (ie 0,
1, 2...). As a result, `get_the_terms()` was returning a strictly different
array when pulling from the cache and when the cache was empty.

Props joshlevinson.
Fixes #31086.
Built from https://develop.svn.wordpress.org/trunk@31287


git-svn-id: http://core.svn.wordpress.org/trunk@31268 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-28 20:43:23 +00:00
Boone Gorges
e199d2420f Ensure that 'hierarchical' is respected in get_terms() when multiple taxonomies are passed.
Previously, attempts to descend the family tree of each term were done using
the first taxonomy in the `$taxonomies` array, with the result that terms not
belonging to that taxonomy were not found and their children not properly
parsed. We fix this bug by fetching each term's taxonomy with the SQL query,
and then using that taxonomy to get the correct children for each term.

Fixes #31118.
Built from https://develop.svn.wordpress.org/trunk@31285


git-svn-id: http://core.svn.wordpress.org/trunk@31266 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-26 19:04:21 +00:00
Boone Gorges
af6e0f5c55 Ensure that 'pad_counts' is not discarded when the first of multiple taxonomies passed to get_terms() is non-hierarchical.
See #31118.
Built from https://develop.svn.wordpress.org/trunk@31284


git-svn-id: http://core.svn.wordpress.org/trunk@31265 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-26 18:09:22 +00:00
Boone Gorges
acef0e2dcc In get_terms(), check hierarchy for all $taxonomies before bailing early from 'parent' or 'child_of'.
There is a pre-check in `get_terms()` that prevents an unnecessary database
query if the 'parent' or 'child_of' parameter is not found in the cached term
hierarchy (since a term without an index in the hierarchy cache has no
descendants). Previously, only the first item in the `$taxonomies` array was
being checked, with the result that an empty array was being erroneously
returned in cases where the 'parent' or 'child_of' term is in a subsequent
taxonomy.

See #31118.
Built from https://develop.svn.wordpress.org/trunk@31276


git-svn-id: http://core.svn.wordpress.org/trunk@31257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-25 02:46:25 +00:00
Boone Gorges
43fceb39c0 Introduce 'childless' parameter to get_terms().
This new parameter allows developers to limit queried terms to terminal nodes -
ie, those without any descendants.

As part of the improvement, some internal logic in `get_terms()` has been
consolidated. Parameters that resolve to a NOT IN clause containing term IDs
('exclude', 'exclude_tree', and 'childless') are now parsed into a single
"exclusions" array before the SQL clause is generated.

Props theMikeD, horike.
Fixes #29839.
Built from https://develop.svn.wordpress.org/trunk@31275


git-svn-id: http://core.svn.wordpress.org/trunk@31256 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-24 18:48:23 +00:00
Boone Gorges
d45a650846 Introduce 'parent' parameter to wp_get_object_terms().
Props mikeschinkel.
Fixes #15675.
Built from https://develop.svn.wordpress.org/trunk@31270


git-svn-id: http://core.svn.wordpress.org/trunk@31251 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-23 14:57:22 +00:00
Boone Gorges
61f5f38dcd Better loop detection for _pad_term_counts().
The `$ancestors` check must be reset for each term in order for term counts
to be correct.

Fixes #20635.
Built from https://develop.svn.wordpress.org/trunk@31248


git-svn-id: http://core.svn.wordpress.org/trunk@31229 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-19 16:52:22 +00:00
Drew Jaynes
bee439858b Minor fix for inline doc syntax in a changelog entry for wp_get_object_terms().
See #28688.

Built from https://develop.svn.wordpress.org/trunk@31238


git-svn-id: http://core.svn.wordpress.org/trunk@31219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-18 19:05:22 +00:00
Boone Gorges
a639c5905e Add @since annotation for 'orderby' values introduced in [31236].
See #28688.
Built from https://develop.svn.wordpress.org/trunk@31237


git-svn-id: http://core.svn.wordpress.org/trunk@31218 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-18 19:03:24 +00:00
Boone Gorges
42ec13030c Additional 'orderby' values for wp_get_object_terms().
Adds support for ordering by 'taxonomy', 'term_taxonomy_id', and 'parent'.

Props ChriCo.
Fixes #28688.
Built from https://develop.svn.wordpress.org/trunk@31236


git-svn-id: http://core.svn.wordpress.org/trunk@31217 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-18 18:57:23 +00:00
Boone Gorges
a245838c42 Correct wp_get_object_terms() documentation.
The 'orderby' parameter accepts a number of values that have never been
properly documented.
Built from https://develop.svn.wordpress.org/trunk@31232


git-svn-id: http://core.svn.wordpress.org/trunk@31213 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-17 20:39:23 +00:00
Boone Gorges
03512a2a02 Standardize the docblock for wp_get_object_terms().
The enumeration of the `$args` parameter has been moved from the long
description to an array hash associated with the proper `@param` attribute.
Built from https://develop.svn.wordpress.org/trunk@31231


git-svn-id: http://core.svn.wordpress.org/trunk@31212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-17 20:09:47 +00:00
Scott Taylor
5458a4da21 wp_set_object_terms() takes $taxonomy as a string. Update @param.
See #30799.

Built from https://develop.svn.wordpress.org/trunk@31221


git-svn-id: http://core.svn.wordpress.org/trunk@31202 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-16 23:27:25 +00:00
Scott Taylor
eeda68bbda Fix some erroneous @param annotations.
See #30799.

Built from https://develop.svn.wordpress.org/trunk@31219


git-svn-id: http://core.svn.wordpress.org/trunk@31200 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-16 22:44:25 +00:00
Boone Gorges
35f3f7bf63 Bail out of hierarchy loops in _get_term_children().
This prevents infinite loops that lead to PHP nesting limit fatal errors.

Props boonebgorges, sgrant.
Fixes #24461.
Built from https://develop.svn.wordpress.org/trunk@31207


git-svn-id: http://core.svn.wordpress.org/trunk@31188 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-16 17:10:22 +00:00
Boone Gorges
991bfdebc1 Bail out of hierarchy loops in _pad_term_counts().
Taxonomy hierarchy loops should not occur naturally, but when they do, the
logic of `_pad_term_counts()` could result in infinite loops, leading to
timeouts. We avoid this by breaking when a loop is detected.

Fixes #20635.
Built from https://develop.svn.wordpress.org/trunk@31206


git-svn-id: http://core.svn.wordpress.org/trunk@31187 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-16 16:46:23 +00:00
Scott Taylor
fc843ce4d0 There are some random add_action() and add_filter() calls littered around some files in wp-includes/. These should be moved to wp-includes/default-filters.php with the rest of the registered hooks. It seems like this was the best practice for awhile and then we randomly stopped. This file loads way before any of the includes, so the hooks will be registered for any request that loads WordPress, even SHORTINIT - a lot of the hooks registered won't run anyways (that's already the case).
See #30947.

Built from https://develop.svn.wordpress.org/trunk@31168


git-svn-id: http://core.svn.wordpress.org/trunk@31149 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-12 16:40:23 +00:00
Scott Taylor
bc4cd01190 In wp-includes/taxonomy.php:
The keyword `elseif` should be used instead of `else if` so that all control keywords look like single words.

See #30799.

Built from https://develop.svn.wordpress.org/trunk@31087


git-svn-id: http://core.svn.wordpress.org/trunk@31068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-08 06:26:23 +00:00
Scott Taylor
190165cb32 Use the 'not_found' label when there are no items for a taxonomy in the terms list table.
Props SergeyBiryukov.
Fixes #30586.

Built from https://develop.svn.wordpress.org/trunk@31035


git-svn-id: http://core.svn.wordpress.org/trunk@31016 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-03 06:20:21 +00:00
Boone Gorges
1b63ada83d Introduce 'name' parameter for get_terms().
This enhancement requires a modification in the way that `wp_dropdown_categories()`
prepares its arguments for `get_terms()`, so that its unrelated 'name' param is
not mistaken for the new 'name' argument in `get_terms()`.

Props danielbachhuber.
Fixes #30611.
Built from https://develop.svn.wordpress.org/trunk@31024


git-svn-id: http://core.svn.wordpress.org/trunk@31005 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-02 21:34:23 +00:00
Scott Taylor
96558ac3c3 Update/fix inline docs for update_object_term_cache().
Props DrewAPicture.
Fixes #30731.

Built from https://develop.svn.wordpress.org/trunk@31012


git-svn-id: http://core.svn.wordpress.org/trunk@30993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-31 18:12:26 +00:00
Sergey Biryukov
200ca064b0 Correct $taxonomies parameter description in get_terms() filters.
props dlh.
fixes #30851.
Built from https://develop.svn.wordpress.org/trunk@30994


git-svn-id: http://core.svn.wordpress.org/trunk@30976 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-28 01:44:24 +00:00
Boone Gorges
fb54c6d7c9 Pass $resource_type to 'get_ancestors' filter.
The `$resource_type` argument was added to the `get_ancestors()` function in
[30141]. In that changeset, the documentation for the filter was updated to
indicate that it would receive `$resource_type` as a param, but the filter
itself was not updated accordingly.

Props tmatsuur, DrewAPicture.
Fixes #30843.
Built from https://develop.svn.wordpress.org/trunk@30993


git-svn-id: http://core.svn.wordpress.org/trunk@30975 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-26 21:29:22 +00:00
Boone Gorges
b806668e71 In wp_update_term(), limit duplicate slug checks to the same taxonomy as the updated term.
In 4.1 [30240], `wp_insert_term()` was modified to allow the creation of terms
with duplicate slugs, as long as the terms are in different taxonomies.
`wp_update_term()` didn't get the corresponding modification, with the result
that term updates fail when the term being updated shares a slug with an older
term, regardless of that older term's taxonomy.

Props ipm-frommen.
Fixes #30780 for trunk.
Built from https://develop.svn.wordpress.org/trunk@30985


git-svn-id: http://core.svn.wordpress.org/trunk@30971 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-22 15:33:25 +00:00
Scott Taylor
5eb5afac34 For clarity, initialize some arrays that previously were only assigned via short circuit in loops.
See #30799.

Built from https://develop.svn.wordpress.org/trunk@30982


git-svn-id: http://core.svn.wordpress.org/trunk@30968 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-20 22:47:22 +00:00
Boone Gorges
e1ebba28d4 Update individual term caches in get_terms().
This was removed in [29915] as part of the attempt to add cache support to
`get_term_by()`. When that support was removed in [30900], it was not properly
restored.

This changeset includes a unit test to verify that the cache is properly primed
for terms found in `get_terms()`, as well as tests to verify the other cache
setting that was touched by [30900].

Fixes #30749. See #21760.
Built from https://develop.svn.wordpress.org/trunk@30954


git-svn-id: http://core.svn.wordpress.org/trunk@30942 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-17 16:39:24 +00:00
Boone Gorges
6ebb326c54 Remove caching for get_term_by() calls.
The new cache group scheme causes term invalidation to be overly broad, so
that busting the cache for one term will bust the cache for all terms in the
taxonomy. We'll have another go at more focused use of the 'last_changed'
incrementor in a future release.

Reverts [29915], [30073], [30080], [30108], [30112].
See #21760.
Built from https://develop.svn.wordpress.org/trunk@30900


git-svn-id: http://core.svn.wordpress.org/trunk@30890 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-16 13:27:22 +00:00
Drew Jaynes
337dfe7111 Restore missing line in DocBlock for WP_Tax_Query::get_sql_for_clause().
Props kpdesign.
See [30622], #30469.

Built from https://develop.svn.wordpress.org/trunk@30759


git-svn-id: http://core.svn.wordpress.org/trunk@30749 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-07 00:39:24 +00:00
Sergey Biryukov
1f64435284 Fix a typo in [30546].
see #30473.
Built from https://develop.svn.wordpress.org/trunk@30727


git-svn-id: http://core.svn.wordpress.org/trunk@30717 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-03 13:55:24 +00:00
Drew Jaynes
27297bcddf Use the correct hash notation syntax for the wp_insert_term() DocBlock.
See #28298.

Built from https://develop.svn.wordpress.org/trunk@30724


git-svn-id: http://core.svn.wordpress.org/trunk@30714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-03 10:17:24 +00:00
Scott Taylor
ba914c7df1 Improve various @param docs.
See #30224.

Built from https://develop.svn.wordpress.org/trunk@30673


git-svn-id: http://core.svn.wordpress.org/trunk@30663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-30 22:56:25 +00:00
Drew Jaynes
150f71e3e5 Docs Formatting: Backtick-escape inline code for all dynamic hook docs in wp-includes/taxonomy.php.
Affects DocBlocks for the following hooks:
* `get_$taxonomy`
* `edit_term_{$field}`
* `edit_{$taxonomy}_{$field}`
* `pre_term_{$field}`
* `pre_{$taxonomy}_{$field}`
* `term_{$field}_rss`
* `{$taxonomy}_{$field}_rss`
* `term_{$field}`
* `{$taxonomy}_{$field}`
* `delete_$taxonomy`
* `create_$taxonomy`
* `edit_$taxonomy`
* `edited_$taxonomy`

See #30552.

Built from https://develop.svn.wordpress.org/trunk@30654


git-svn-id: http://core.svn.wordpress.org/trunk@30644 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-30 12:00:23 +00:00
Drew Jaynes
ea1ee4369f 4.1 Docs Audit: Improve inline documentation in DocBlocks for various WP_Tax_Query methods, the pre_delete_term hook, and get_ancestors().
See #30469.

Built from https://develop.svn.wordpress.org/trunk@30622


git-svn-id: http://core.svn.wordpress.org/trunk@30612 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-28 12:26:24 +00:00
Boone Gorges
213ecc8a07 Revert shared taxonomy term splitting for 4.1.
This is a revert of [30494], [30492], [30347], and [30334]. The latter
changeset was a revert of [30336], which was a revert of [30241].

Watch for Term Splitting, Version III in version 4.2, coming soon to a
WordPress trunk near you.

See #30335, #5809.
Built from https://develop.svn.wordpress.org/trunk@30585


git-svn-id: http://core.svn.wordpress.org/trunk@30575 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-27 00:05:22 +00:00
Drew Jaynes
4b6abbaff4 Ensure inline code is markdown-escaped as such, HTML tags are removed from summaries, and that code snippets in descriptions are properly indented.
Affects DocBlocks for the following core elements:
* Backtick-escape code snippets in the description for `get_object_taxonomies()`
* Backtick-escape inline code in a markdown-formatted unordered list in the description for `get_taxonomy_labels()`
* Remove an HTML tag from the summary for the `Walker_Category_Checklist` class
* Remove an HTML tag from the summary for `wp_category_checklist()`, various formatting
* Remove an HTML tag from the summary for `wp_terms_checklist()`
* Backtick-escape an HTML tag in the description for `wp_popular_terms_checklist()`
* Remove HTML tags from the summaries for `page_template_dropdown()`, `parent_dropdown()`, and `wp_dropdown_roles()`
* Backtick-escape HTML tags in a parameter description for `add_settings_error()`
* Various formatting in the description and summary for `settings_errors()`
* Markdown-indent code snippets in the descriptions for `wpdb::prepare()`, `wpdb::insert()`, `wpdb::replace()`, `wpdb::update()`, and `wpdb::delete()`
* Backtick-escape an HTML tag in a parameter description for `login_header()`
* Remove HTML tags from the summaries for the `lostpassword_form` and `signup_header` hooks

Props rarst.
See #30473.

Built from https://develop.svn.wordpress.org/trunk@30546


git-svn-id: http://core.svn.wordpress.org/trunk@30535 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-24 06:31:21 +00:00
Boone Gorges
57e358da63 Improve cleanup of cached term_ids after shared terms are split.
* If the split term ID is stored as 'default_category', 'default_link_category', or 'default_email_category', update it to the new ID.
* If the split term ID is associated with a nav menu item, update that piece of postmeta to the new ID.

Props mboynes.
See #30335.
Built from https://develop.svn.wordpress.org/trunk@30494


git-svn-id: http://core.svn.wordpress.org/trunk@30483 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-21 03:17:22 +00:00
Boone Gorges
14e6c301ea Pass the taxonomy of the split tt_id to the 'split_shared_term' filter.
Props mboynes.
See #30335.
Built from https://develop.svn.wordpress.org/trunk@30493


git-svn-id: http://core.svn.wordpress.org/trunk@30482 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-21 03:14:23 +00:00
Boone Gorges
6f9eaf5df5 Store data about old and new term IDs when shared terms are split.
Props mboynes.
See #30335.
Built from https://develop.svn.wordpress.org/trunk@30492


git-svn-id: http://core.svn.wordpress.org/trunk@30481 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-21 03:13:22 +00:00
Dion Hulse
ddbb5a850f Remove a stray translator comment for a non-translatable string added in [30209] See #27238
Built from https://develop.svn.wordpress.org/trunk@30365


git-svn-id: http://core.svn.wordpress.org/trunk@30364 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-17 04:36:25 +00:00
Boone Gorges
866cfdf19b Flush cache for newly created term in _split_shared_term().
The term itself does not have any cached values yet, but in some cases the new
term's taxonomy may need its cached hierarchy to be refreshed as a result of
the term splitting.

Props jorbin.
See #30335.
Built from https://develop.svn.wordpress.org/trunk@30347


git-svn-id: http://core.svn.wordpress.org/trunk@30346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-14 21:53:22 +00:00
Boone Gorges
c5bb06dafe Reinstate term splitting on term update.
Originally introduced in [30241] and reverted in [30336], term splitting is
back and better than ever. Now with *more unit tests* and *improved treatment
of child terms*!

See #30335.
Built from https://develop.svn.wordpress.org/trunk@30344


git-svn-id: http://core.svn.wordpress.org/trunk@30343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-14 21:27:24 +00:00
Boone Gorges
eb8f89bb13 Don't split shared terms on term update.
Splitting shared terms means assigning a new term_id to a given term_taxonomy_id.
It was uncovered that this change could cause problems for sites that have
cached the original term_id somehow - say, in postmeta - since future lookups
using that term_id will now fail.

Removing for 4.1-beta1. We'll look at improvements to backward compatibility
to try to get this back into a later beta.

Props mboynes.
See #30335.
Built from https://develop.svn.wordpress.org/trunk@30336


git-svn-id: http://core.svn.wordpress.org/trunk@30335 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-13 20:05:24 +00:00
Boone Gorges
c357de63ef Don't force child_of=0 for non-hierarchical taxonomies in get_terms().
This forcing appears to have been introduced to save unnecessary queries, but
(a) in some cases it appeared to be causing *more* queries, and (b) it caused
incorrect results when the 'exclude_tree' param of `get_terms()` called
`get_terms()` on each item in the tree using the 'child_of' param.

Fixes #30275.
Built from https://develop.svn.wordpress.org/trunk@30265


git-svn-id: http://core.svn.wordpress.org/trunk@30265 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-06 21:47:23 +00:00
Boone Gorges
3706590afb Split shared taxonomy terms during term update.
When updating an existing taxonomy term that shares its `term_id` with
another term, we generate a new row in `wp_terms` and associate the updated
term_taxonomy_id with the new term. This separates the terms, such that
updating the name of one term does not change the name of any others.

Note that this term splitting only occurs on installations whose database
schemas have been upgraded to version 30133 or higher. Note also that shared
terms are only split when run through `wp_update_term()`, as on edit-tags.php;
we will wait until a future release of WordPress to force the splitting of all
shared taxonomy terms.

Props boonebgorges, rmccue, greuben, garyc40, wonderboymusic, imath, jesin.
Fixes #5809.
Built from https://develop.svn.wordpress.org/trunk@30241


git-svn-id: http://core.svn.wordpress.org/trunk@30241 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-05 02:03:23 +00:00
Boone Gorges
32db3d1fe5 Do not create shared taxonomy terms.
A "shared" term occurs when two entries in the `wp_term_taxonomy` table share a
single `term_id`, and thereby correspond to the same row in `wp_terms`. This
changeset stops the practice of creating shared terms: each new row in
`wp_term_taxonomy` will receive its own row in `wp_terms`. The new strategy
for term creation depends on whether the installation's database schema is up
to date for 4.1:

* If so, terms are allowed to be created with the same slug as an existing term, as long as they are in different taxonomies and do not share a parent. Thus, a new tag with the slug 'wordpress' can exist alongside a category with the slug 'wordpress'.
* If not, new terms will be forced to have unique slugs. Thus, on an installation containing a category with the slug 'wordpress', a new tag 'WordPress' will get the slug 'wordpress-2'.

Fixes #21950. See #5809.
Built from https://develop.svn.wordpress.org/trunk@30240


git-svn-id: http://core.svn.wordpress.org/trunk@30240 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-05 01:42:22 +00:00
Boone Gorges
ef13be6f27 Enforce ORDER BY and LIMIT clauses in term_exists() queries.
In case of edge cases where a duplicate term might exist in a replicated
database for a split second, these explicit query clauses ensure that
`term_exists()` will always recognize the oldest matched term as the
canonical one. See [30238] for background.

Props pento.
See #22023, #5809.
Built from https://develop.svn.wordpress.org/trunk@30239


git-svn-id: http://core.svn.wordpress.org/trunk@30239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-05 01:09:21 +00:00
Boone Gorges
4ce9db9ce8 In wp_insert_term(), clean up accidental duplicate terms after insert.
In [30056], the UNIQUE index was removed from the 'slug' column of `wp_terms`.
While we have numerous checks in place to avoid the creation of unwanted
duplicate term+term_taxonomy pairs, it's possible that in certain edge cases -
such as during the lag caused by database replication, or a race condition
involving near-simultaneous creation of more than one term - we'll end up
unwittingly inserting two identical rows.

The current changeset minimizes this risk by introducing a failsafe mechanism
into `wp_insert_term()`. After a term and term_taxonomy are INSERTed, we check
to see whether the term just created is a duplicate of an existing term; if so,
we delete the new one and keep the old one. This prevents problems caused by
replication lag, because SELECT queries that take place after an INSERT will
hit the master database; it mitigates race conditions by enforcing that the
term that was created first (ie, the one with the lowest `term_id`) is
always the "canonical" one.

Props nacin, markjaquith.
See #22023, #5809.
Built from https://develop.svn.wordpress.org/trunk@30238


git-svn-id: http://core.svn.wordpress.org/trunk@30238 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-05 01:00:24 +00:00
Boone Gorges
7919a6d812 Improve docblocks for get_the_taxonomies() and the_taxonomies().
* In `the_taxonomies()`, only document those arguments that are specific to the function. Arguments shared with `get_the_taxonomies()` should be documented in the later function's docblock.
* Add $args hash documentation to `get_the_taxonomies()`.
* Remove the redundant default argument definition in `the_taxonomies()`.

Fixes #27238.
Built from https://develop.svn.wordpress.org/trunk@30210


git-svn-id: http://core.svn.wordpress.org/trunk@30210 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-03 18:49:45 +00:00