Make WordPress Core

Changeset 34578


Ignore:
Timestamp:
09/26/2015 05:02:24 AM (11 years ago)
Author:
wonderboymusic
Message:

XML-RPC: move the malfunctioning 'overwrite' code from wp_xmlrpc_server::mw_newMediaObject(). This was suggested 3 years ago.

Props markoheijnen.
Fixes #17604.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r34575 r34578  
    57355735                }
    57365736
    5737                 if ( !empty($data['overwrite']) && ($data['overwrite'] == true) ) {
    5738                         // Get postmeta info on the object.
    5739                         $old_file = $wpdb->get_row("
    5740                                 SELECT ID
    5741                                 FROM {$wpdb->posts}
    5742                                 WHERE post_title = '{$name}'
    5743                                         AND post_type = 'attachment'
    5744                         ");
    5745 
    5746                         // Delete previous file.
    5747                         wp_delete_attachment($old_file->ID);
    5748 
    5749                         // Make sure the new name is different by pre-pending the
    5750                         // previous post id.
    5751                         $filename = preg_replace('/^wpid\d+-/', '', $name);
    5752                         $name = "wpid{$old_file->ID}-{$filename}";
    5753                 }
    5754 
    57555737                $upload = wp_upload_bits($name, null, $bits);
    57565738                if ( ! empty($upload['error']) ) {
Note: See TracChangeset for help on using the changeset viewer.