Make WordPress Core

Changeset 4961 for trunk/xmlrpc.php


Ignore:
Timestamp:
03/03/2007 04:56:46 PM (20 years ago)
Author:
ryan
Message:

xmlrpc updates from Joseph Scott.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xmlrpc.php

    r4953 r4961  
    150150                global $wpdb;
    151151
    152                 if(is_string($array)) {
     152                if(!is_array($array)) {
    153153                        return($wpdb->escape($array));
    154154                }
    … …  
    11011101
    11021102                // Only set a post parent if one was given.
    1103                 if(!empty($content_struct["wp_page_parent_id"])) {
     1103                if(isset($content_struct["wp_page_parent_id"])) {
    11041104                        $post_parent = $content_struct["wp_page_parent_id"];
    11051105                }
    … …  
    11671167          if ( is_array($to_ping) )
    11681168                $to_ping = implode(' ', $to_ping);
     1169
     1170      if(isset($content_struct["mt_allow_comments"])) {
     1171                $comment_status = $content_struct["mt_allow_comments"];
     1172      }
    11691173         
    1170           $comment_status = (!isset($content_struct['mt_allow_comments'])) ?
    1171             get_option('default_comment_status')
    1172             : $content_struct['mt_allow_comments'];
    1173 
    11741174          // Do some timestamp voodoo
    11751175          $dateCreatedd = $content_struct['dateCreated'];
    … …  
    13881388                if(!empty($data["overwrite"]) && ($data["overwrite"] == true)) {
    13891389                        $overwrite = true;
     1390
     1391                        // If the file isn't writable then error out now.
     1392                        if(!is_writable($data["name"])) {
     1393                                return(new IXR_Error(500, "File is not writable, over write failed."));
     1394                        }
     1395
     1396                        // We now know the file is good so don't use the sanitized name.
     1397                        $name = $data["name"];
     1398
     1399                        // Get postmeta info on the object.
     1400                        $old_meta = $wpdb->get_row("
     1401                                SELECT *
     1402                                FROM {$wpdb->postmeta}
     1403                                WHERE meta_key = '_wp_attached_file'
     1404                                        AND meta_value = '{$name}'
     1405                        ");
     1406
     1407                        // Get post info on the object.
     1408                        $old_post = get_post($old_meta->post_id);
    13901409                }
    13911410
    … …  
    14221441                );
    14231442
    1424                 // Only make a database entry if this is a new file.
    1425                 if(!$overwrite) {
    1426                         // Save the data
    1427                         $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id );
    1428                         wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
    1429                 }
     1443                // If we are over writing then set the correct post_id and URL
     1444                // instead of getting new ones.
     1445                if($overwrite) {
     1446                        $post_id                                        = $old_meta->post_id;
     1447                        $attachment["post_parent"]      = $old_meta->post_id;
     1448                        $attachment["ID"]                       = $old_meta->post_id;
     1449
     1450                        $upload["url"]                          = $old_post->guid;
     1451                        $attachment["guid"]                     = $old_post->guid;
     1452                }
     1453
     1454                // Save the data
     1455                $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id );
     1456                wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
    14301457
    14311458                return apply_filters( 'wp_handle_upload', array( 'file' => $upload[ 'file' ], 'url' => $upload[ 'url' ], 'type' => $type ) );
Note: See TracChangeset for help on using the changeset viewer.