[wp-trac] [WordPress Trac] #56171: Unexpected behaviour and data loss with a post type called 'link' and Link Manager plugin active
WordPress Trac
noreply at wordpress.org
Fri Jul 8 03:07:40 UTC 2022
#56171: Unexpected behaviour and data loss with a post type called 'link' and Link
Manager plugin active
--------------------------+------------------------------
Reporter: manfcarlo | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version:
Severity: critical | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Description changed by sabernhardt:
Old description:
> Steps to reproduce:
>
> 0. Install a fresh site (this will be easier to reproduce if the posts
> table has a low `auto_increment` value)
> 1. Install the Link Manager plugin (prior to version 3.5 this plugin was
> not required)
> 2. Register a post type called `link` (you can use the default args)
> **3. Observe that "Link Categories" is added under the newly registered
> post type in the admin menu**
> 4. Publish a post through the `link` post type and take note of its
> numeric ID
> 5. Add enough links through the Link Manager until you reach the same
> numeric ID observed in step 4
> 6. Assign a link category to the link with the same numeric ID observed
> in step 4 (if it's a fresh site it shouldn't be too many)
> **7. Go back to the `link` post type and observe that the published post
> has received the link category that was assigned to the link in step 6**
> 8. Now delete the post permanently
> **9. Go back to the Link Manager and observe that the link has lost its
> category that was assigned in step 6**
>
> This bug is caused because the taxonomy `link_category` is registered for
> the string `link`. [https://github.com/WordPress/WordPress/blob/6.0/wp-
> includes/taxonomy.php#L136 (See code)]
>
> Interestingly, the function `register_taxonomy_for_object_type`
> [https://github.com/WordPress/WordPress/blob/6.0/wp-
> includes/taxonomy.php#L734 rejects any string that is not registered as a
> post type.] Of course, if the same check were included for immediate
> registration through `register_taxonomy`, link categories could not exist
> at all.
>
> I discovered this while trying to get a clear answer on whether
> taxonomies were actually supported for non-post entities. I was nearly
> convinced they were not, until I noticed that link categories exist, and
> now it looks to me that no one knows the answer.
New description:
Steps to reproduce:
0. Install a fresh site (this will be easier to reproduce if the posts
table has a low `auto_increment` value)
1. Install the Link Manager plugin (prior to version 3.5 this plugin was
not required)
2. Register a post type called `link` (you can use the default args)
**3. Observe that "Link Categories" is added under the newly registered
post type in the admin menu**
4. Publish a post through the `link` post type and take note of its
numeric ID
5. Add enough links through the Link Manager until you reach the same
numeric ID observed in step 4 (if it's a fresh site it shouldn't be too
many)
6. Assign a link category to the link with the same numeric ID observed in
step 4
**7. Go back to the `link` post type and observe that the published post
has received the link category that was assigned to the link in step 6**
8. Now delete the post permanently
**9. Go back to the Link Manager and observe that the link has lost its
category that was assigned in step 6**
This bug is caused because the taxonomy `link_category` is registered for
the string `link`. [https://github.com/WordPress/WordPress/blob/6.0/wp-
includes/taxonomy.php#L136 (See code)]
Interestingly, the function `register_taxonomy_for_object_type`
[https://github.com/WordPress/WordPress/blob/6.0/wp-
includes/taxonomy.php#L734 rejects any string that is not registered as a
post type.] Of course, if the same check were included for immediate
registration through `register_taxonomy`, link categories could not exist
at all.
I discovered this while trying to get a clear answer on whether taxonomies
were actually supported for non-post entities. I was nearly convinced they
were not, until I noticed that link categories exist, and now it looks to
me that no one knows the answer.
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56171#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list