Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#14649 closed defect (bug) (duplicate)

Throw error when registering a Post Type longer than 20 chars

Reported by: batmoo's profile batmoo Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

From stephdau's blog post:

When dealing with WordPress custom post types, be sure that the namespace/value you use as an identifier for your post_type is less then or equal to 20 characters. The DB column which holds the said value is a varchar(20).

WordPress should throw either a PHP Notice or an admin_notices error warning that the post type name cannot be longer than 20 characters and fail to register the post type.

Also applies to register_post_status.

Change History (4)

#1 @hakre
14 years ago

  • Keywords reporter-feedback added

Are you adding the post type via the admin UI? If so, please provide the URL of the page in Admin where you do this.

Even better please provide some simple steps on how to reproduce the problem.

#2 @stephdau
14 years ago

register_post_type( 'a_really_long_post_type_namespace', ... );

The above will end up having "a_really_long_post_" only in the DB in post_type.

#3 @batmoo
14 years ago

  • Keywords needs-patch added; reporter-feedback removed

Related #11959 and #15058

#4 @dd32
14 years ago

  • Keywords needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

See [16670] - Throw WP_Error if post_type passed to register_post_type() is longer than schema allows. props phrostypoison. fixes #13709

Note: See TracTickets for help on using tickets.