Skip to content

Commit 3da0865

Browse files
committed
Fix term insertion when auto-generated slug exceeds 200 chars to avoid db insert errors (Ticket #46010)
Update 46010.diff after indentation fix and rebase Fix coding standards in taxonomy.php and update PHPUnit workflow
1 parent 8ec91a4 commit 3da0865

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

.github/workflows/reusable-phpunit-tests-v3.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,20 @@ jobs:
124124
permissions:
125125
contents: read
126126

127+
services:
128+
mysql:
129+
image: mysql:8.0
130+
ports:
131+
- 3306:3306
132+
env:
133+
MYSQL_ROOT_PASSWORD: password
134+
MYSQL_DATABASE: wordpress_develop
135+
options: >-
136+
--health-cmd="mysqladmin ping --silent"
137+
--health-interval=10s
138+
--health-timeout=5s
139+
--health-retries=5
140+
127141
steps:
128142
- name: Configure environment variables
129143
run: |

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)