Make WordPress Core

Ticket #50447: patch.diff

File patch.diff, 1.2 KB (added by hughie.molloy, 6 years ago)

git patch file to fix the issue

  • wp-includes/post.php

    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 ) { 
    43184318/**
    43194319 * Publish a post by transitioning the post status.
    43204320 *
     4321 * Makes sure the new permalink is unique.
     4322 *
    43214323 * @since 2.1.0
    43224324 *
    43234325 * @global wpdb $wpdb WordPress database abstraction object.
    function wp_publish_post( $post ) { 
    43364338                return;
    43374339        }
    43384340
    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 ) );
    43404344
    43414345        clean_post_cache( $post->ID );
    43424346