Make WordPress Core

Ticket #54147: xmlrpc-terms-names-fix.diff

File xmlrpc-terms-names-fix.diff, 1.3 KB (added by redsweater, 4 years ago)

Patch to fix the described the bug

  • src/wp-includes/class-wp-xmlrpc-server.php

    From 2147ec804b33bc1b9db2f4b84767990d28227a58 Mon Sep 17 00:00:00 2001
    From: Daniel Jalkut <jalkut@red-sweater.com>
    Date: Mon, 20 Sep 2021 13:43:19 -0400
    Subject: [PATCH] When an empty terms_names array is provided, see that it
     effectively overwrites any existing tags on the entry being updated.
    
    ---
     src/wp-includes/class-wp-xmlrpc-server.php | 6 ++++++
     1 file changed, 6 insertions(+)
    
    diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php
    index 93809422d5..d712495087 100644
    a b class wp_xmlrpc_server extends IXR_Server { 
    15911591                                $taxonomies = array_keys( $post_data['terms_names'] );
    15921592
    15931593                                foreach ( $taxonomies as $taxonomy ) {
     1594                                        // In case an empty array was specified with terms_names, and no terms were specified by ID above,
     1595                                        // we need to ensure an empty array is set to start for this taxonomy, so that existing terms will be removed.
     1596                                        if ( ! array_key_exists( $taxonomy, $terms ) ) {
     1597                                                $terms[ $taxonomy ] = array();
     1598                                        }
     1599
    15941600                                        if ( ! array_key_exists( $taxonomy, $post_type_taxonomies ) ) {
    15951601                                                return new IXR_Error( 401, __( 'Sorry, one of the given taxonomies is not supported by the post type.' ) );
    15961602                                        }