From 395831fc10c39eb74937c4fb2eb896c89743ee24 Mon Sep 17 00:00:00 2001
From: hughie molloy <hughie.molloy@kaldorgroup.com>
Date: Mon, 22 Jun 2020 17:49:45 +0100
Subject: [PATCH] Fixing an error with non unique post names when transitioning
a post to publish in wp_publish_post
---
wp-includes/post.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/wp-includes/post.php b/wp-includes/post.php
index c123ff47ac..e4ff64feed 100644
|
a
|
b
|
function wp_update_post( $postarr = array(), $wp_error = false ) { |
| 4318 | 4318 | /** |
| 4319 | 4319 | * Publish a post by transitioning the post status. |
| 4320 | 4320 | * |
| | 4321 | * Makes sure the new permalink is unique. |
| | 4322 | * |
| 4321 | 4323 | * @since 2.1.0 |
| 4322 | 4324 | * |
| 4323 | 4325 | * @global wpdb $wpdb WordPress database abstraction object. |
| … |
… |
function wp_publish_post( $post ) { |
| 4336 | 4338 | return; |
| 4337 | 4339 | } |
| 4338 | 4340 | |
| 4339 | | $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) ); |
| | 4341 | $post_name = wp_unique_post_slug( $post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent ); |
| | 4342 | |
| | 4343 | $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish', 'post_name' => $post_name ), array( 'ID' => $post->ID ) ); |
| 4340 | 4344 | |
| 4341 | 4345 | clean_post_cache( $post->ID ); |
| 4342 | 4346 | |