Make WordPress Core

Ticket #7773: 7773.diff

File 7773.diff, 1.8 KB (added by Otto42, 17 years ago)

First attempt at a patch

  • xmlrpc.php

     
    21702170                // Handle enclosures
    21712171                $enclosure = $content_struct['enclosure'];
    21722172                if( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
    2173                         add_post_meta( $post_ID, 'enclosure', $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] );
     2173               
     2174                        $encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'];
     2175                        $found = false;
     2176                        foreach ( (array) get_post_custom($post_ID) as $key => $val) {
     2177                                if ($key == 'enclosure') {
     2178                                        foreach ( (array) $val as $enc ) {
     2179                                                if ($enc == $encstring) {
     2180                                                        $found = true;
     2181                                                        break 2;
     2182                                                }
     2183                                        }
     2184                                }
     2185                        }
     2186                        if (!found) {
     2187                                add_post_meta( $post_ID, 'enclosure', $encstring );
     2188                        }
    21742189                }
    21752190
    21762191                $this->attach_uploads( $post_ID, $post_content );
     
    24532468                // Handle enclosures
    24542469                $enclosure = $content_struct['enclosure'];
    24552470                if( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
    2456                         add_post_meta( $post_ID, 'enclosure', $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] );
     2471               
     2472                        $encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'];
     2473                        $found = false;
     2474                        foreach ( (array) get_post_custom($post_ID) as $key => $val) {
     2475                                if ($key == 'enclosure') {
     2476                                        foreach ( (array) $val as $enc ) {
     2477                                                if ($enc == $encstring) {
     2478                                                        $found = true;
     2479                                                        break 2;
     2480                                                }
     2481                                        }
     2482                                }
     2483                        }
     2484                        if (!found) {
     2485                                add_post_meta( $post_ID, 'enclosure', $encstring );
     2486                        }
    24572487                }
    24582488
    24592489                $this->attach_uploads( $ID, $post_content );