Skip to content

Commit 4e81b8e

Browse files
committed
Fix term insertion when auto-generated slug exceeds 200 chars to avoid db insert errors (Ticket #46010)
1 parent 83b0df6 commit 4e81b8e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/wp-includes/taxonomy.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,6 +2574,11 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
25742574

25752575
$slug = wp_unique_term_slug( $slug, (object) $args );
25762576

2577+
// Truncate the slug if it's longer than 200 characters to avoid DB errors (see #46010).
2578+
if ( strlen( $slug ) > 200 ) {
2579+
$slug = substr( $slug, 0, 200 );
2580+
}
2581+
25772582
$data = compact( 'name', 'slug', 'term_group' );
25782583

25792584
/**

0 commit comments

Comments
 (0)