Skip to content

Core Data uses hardcoded baseURL prefix for taxonomies and post types  #33420

Closed

Description

@swissspidy

Description

loadTaxonomyEntities and loadPostTypeEntities fetch wp/v2/taxonomies / wp/v2/types to get information about existing taxonomies and post types for later use.

Unfortunately, when doing so they assume every baseURL starts with wp/v2:

baseURL: '/wp/v2/' + taxonomy.rest_base,

baseURL: '/wp/v2/' + postType.rest_base,

This is incorrect, because a post type in WordPress can potentially have a different REST controller forcing a different namespace or REST base.

It would be better to derive this from the wp:items link in _links

Aside: technically WP_REST_Post_Types_Controller has a hardcoded wp/v2 prefix as well, but that should be fixed in core: https://core.trac.wordpress.org/ticket/53656

Step-by-step reproduction instructions

Expected behaviour

Actual behaviour

Screenshots or screen recording (optional)

Code snippet (optional)

WordPress information

  • WordPress version:
  • Gutenberg version:
  • Are all plugins except Gutenberg deactivated?
  • Are you using a default theme (e.g. Twenty Twenty-One)?

Device information

  • Device:
  • Operating system:
  • Browser:

Activity

  1. added
    [Type] Bug
    [Package] Core data
    on Jul 14, 2021
  2. spacedmonkey commented on Oct 11, 2021

    @spacedmonkey
    Member

    Cross posting #53656.

    This issue maybe fixed in core first. The plan would be add the namespace into the post type endpoint, so it doesn't have to be hardcoded here.

  3. swissspidy commented on Oct 11, 2021

    @swissspidy
    MemberAuthor

    AFAICT the namespace is already available from the post type endpoint via the wp:items link, which is the solution I proposed above.

  4. added
    [Status] In Progress
    on Oct 21, 2021
  5. spacedmonkey commented on Oct 21, 2021

    @spacedmonkey
    Member

    I have a PR to fix this ticket at #35850. It requires upstream changed to be merged into core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Package] Core data[Status] In Progress[Type] Bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions