Make WordPress Core

Changeset 10508


Ignore:
Timestamp:
02/05/2009 08:47:30 PM (16 years ago)
Author:
ryan
Message:

Revert 10507. Had extra bits in. see #8702

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r10507 r10508  
    623623    }
    624624    return true;
    625 }
    626 
    627 /**
    628  * Delete a transient
    629  *
    630  * @since 2.8.0
    631  * @package WordPress
    632  * @subpackage Transient
    633  *
    634  * @param string $transient Transient name. Expected to not be SQL-escaped
    635  * @return bool true if successful, false otherwise
    636  */
    637 function delete_transient($transient) {
    638     global $_wp_using_ext_object_cache, $wpdb;
    639 
    640     if ( $_wp_using_ext_object_cache ) {
    641         return wp_cache_delete($transient, 'transient');
    642     } else {
    643         $transient = $wpdb->escape($transient);
    644         return delete_option($transient);
    645     }
    646 }
    647 
    648 /**
    649  * Get the value of a transient
    650  *
    651  * If the transient does not exist or does not have a value, then the return value
    652  * will be false.
    653  *
    654  * @since 2.8.0
    655  * @package WordPress
    656  * @subpackage Transient
    657  *
    658  * @param string $transient Transient name. Expected to not be SQL-escaped
    659  * @return mixed Value of transient
    660  */
    661 function get_transient($transient) {
    662     global $_wp_using_ext_object_cache, $wpdb;
    663 
    664     if ( $_wp_using_ext_object_cache ) {
    665         return wp_cache_get($transient, 'transient');
    666     } else {
    667         $transient = $wpdb->escape($transient);
    668         return get_option($transient);
    669     }
    670 }
    671 
    672 /**
    673  * Set/update the value of a transient
    674  *
    675  * You do not need to serialize values, if the value needs to be serialize, then
    676  * it will be serialized before it is set.
    677  *
    678  * @since 2.8.0
    679  * @package WordPress
    680  * @subpackage Transient
    681  *
    682  * @param string $transient Transient name. Expected to not be SQL-escaped
    683  * @param mixed $value Transient value.
    684  * @return bool False if value was not set and true if value was set.
    685  */
    686 function set_transient($transient, $value) {
    687     global $_wp_using_ext_object_cache, $wpdb;
    688 
    689     if ( $_wp_using_ext_object_cache ) {
    690         return wp_cache_set($transient, $value, 'transient');
    691     } else {
    692         $safe_transient = $wpdb->escape($transient);
    693         if ( false === get_option( $safe_transient ) )
    694             return add_option($transient, $value, '', 'no');
    695         else
    696             return update_option($transient, $value);
    697     }
    698625}
    699626
  • trunk/wp-includes/http.php

    r10507 r10508  
    238238                $working_transport['streams'] = new WP_Http_Streams();
    239239                $blocking_transport[] = &$working_transport['streams'];
    240             } else if ( true === WP_Http_Fopen::test() && apply_filters('use_fopen_transport', true) && ( isset($args['ssl']) && !$args['ssl'] ) ) {
     240            } else if ( true === WP_Http_Fopen::test() && apply_filters('use_fopen_transport', true) ) {
    241241                $working_transport['fopen'] = new WP_Http_Fopen();
    242242                $blocking_transport[] = &$working_transport['fopen'];
    243             } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) && ( isset($args['ssl']) && !$args['ssl'] ) ) {
     243            } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) {
    244244                $working_transport['fsockopen'] = new WP_Http_Fsockopen();
    245245                $blocking_transport[] = &$working_transport['fsockopen'];
     
    283283                $working_transport['exthttp'] = new WP_Http_ExtHttp();
    284284                $blocking_transport[] = &$working_transport['exthttp'];
    285             } else if ( true === WP_Http_Curl::test() && apply_filters('use_curl_transport', true) ) {
    286                 $working_transport['curl'] = new WP_Http_Curl();
    287                 $blocking_transport[] = &$working_transport['curl'];
    288285            } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) {
    289286                $working_transport['streams'] = new WP_Http_Streams();
    290287                $blocking_transport[] = &$working_transport['streams'];
    291             } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) && ( isset($args['ssl']) && !$args['ssl'] ) ) {
     288            } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) {
    292289                $working_transport['fsockopen'] = new WP_Http_Fsockopen();
    293290                $blocking_transport[] = &$working_transport['fsockopen'];
    294291            }
    295292
    296             foreach ( array('curl', 'streams', 'fsockopen', 'exthttp') as $transport ) {
     293            foreach ( array('streams', 'fsockopen', 'exthttp') as $transport ) {
    297294                if ( isset($working_transport[$transport]) )
    298295                    $nonblocking_transport[] = &$working_transport[$transport];
     
    362359            'redirection' => apply_filters( 'http_request_redirection_count', 5),
    363360            'httpversion' => apply_filters( 'http_request_version', '1.0'),
    364             'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )  ),
     361            'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version ),
    365362            'blocking' => true,
    366363            'headers' => array(),
    367364            'body' => null,
    368365            'compress' => false,
    369             'decompress' => true,
    370             'sslverify' => true
     366            'decompress' => true
    371367        );
    372368
    373369        $r = wp_parse_args( $args, $defaults );
    374370        $r = apply_filters( 'http_request_args', $r, $url );
    375 
    376         $arrURL = parse_url($url);
    377 
    378         // Determine if this is a https call and pass that on to the transport functions
    379         // so that we can blacklist the transports that do not support ssl verification
    380         if ( $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl' )
    381             $r['ssl'] = true;
    382         else
    383             $r['ssl'] = false;
    384371
    385372        if ( is_null( $r['headers'] ) )
     
    941928                'protocol_version' => (float) $r['httpversion'],
    942929                'header' => $strHeaders,
    943                 'timeout' => $r['timeout'],
    944                 'ssl' => array(
    945                                     'verify_peer' => apply_filters('https_ssl_verify', $r['sslverify']),
    946                                     'verify_host' => apply_filters('https_ssl_verify', $r['sslverify'])
    947                             )
     930                'timeout' => $r['timeout']
    948931            )
    949932        );
     
    10781061            'useragent' => $r['user-agent'],
    10791062            'headers' => $r['headers'],
    1080             'ssl' => array(
    1081                 'verifypeer' => apply_filters('https_ssl_verify', $r['sslverify']),
    1082                 'verifyhost' => apply_filters('https_ssl_verify', $r['sslverify'])
    1083             )
    10841063        );
    10851064
     
    11751154
    11761155        $handle = curl_init();
    1177 
    11781156        curl_setopt( $handle, CURLOPT_URL, $url);
    1179         curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true );
    1180         curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, apply_filters('https_ssl_verify', $r['sslverify']) );
    1181         curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, apply_filters('https_ssl_verify', $r['sslverify']) );
     1157
     1158        // The cURL extension requires that the option be set for the HEAD to
     1159        // work properly.
     1160        if ( 'HEAD' === $r['method'] ) {
     1161            curl_setopt( $handle, CURLOPT_NOBODY, true );
     1162        }
     1163
     1164        if ( true === $r['blocking'] ) {
     1165            curl_setopt( $handle, CURLOPT_HEADER, true );
     1166            curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 );
     1167        } else {
     1168            curl_setopt( $handle, CURLOPT_HEADER, false );
     1169            curl_setopt( $handle, CURLOPT_NOBODY, true );
     1170            curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 0 );
     1171        }
     1172
    11821173        curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] );
    1183         curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $r['timeout'] );
     1174        curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 1 );
    11841175        curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] );
    11851176        curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] );
    1186 
    1187         switch ( $r['method'] ) {
    1188             case 'HEAD':
    1189                 curl_setopt( $handle, CURLOPT_NOBODY, true );
    1190                 break;
    1191             case 'POST':
    1192                 curl_setopt( $handle, CURLOPT_POST, true );
    1193                 curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] );
    1194                 break;
    1195         }
    1196 
    1197         if ( true === $r['blocking'] )
    1198             curl_setopt( $handle, CURLOPT_HEADER, true );
    1199         else
    1200             curl_setopt( $handle, CURLOPT_HEADER, false );
    12011177
    12021178        // The option doesn't work with safe mode or when open_basedir is set.
  • trunk/wp-includes/rewrite.php

    r10507 r10508  
    15971597     */
    15981598    function wp_rewrite_rules() {
    1599         $this->rules = get_transient('rewrite_rules');
     1599        $this->rules = get_option('rewrite_rules');
    16001600        if ( empty($this->rules) ) {
    16011601            $this->matches = 'matches';
    16021602            $this->rewrite_rules();
    1603             set_transient('rewrite_rules', $this->rules);
     1603            update_option('rewrite_rules', $this->rules);
    16041604        }
    16051605
     
    17841784     */
    17851785    function flush_rules() {
    1786         delete_transient('rewrite_rules');
     1786        delete_option('rewrite_rules');
    17871787        $this->wp_rewrite_rules();
    17881788        if ( function_exists('save_mod_rewrite_rules') )
  • trunk/wp-includes/rss.php

    r10507 r10508  
    715715        $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
    716716
    717         set_transient($cache_option, $rss);
    718         set_transient($cache_timestamp, time() );
     717        // shouldn't these be using get_option() ?
     718        if ( !$wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name = %s", $cache_option ) ) )
     719            add_option($cache_option, '', '', 'no');
     720        if ( !$wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name = %s", $cache_timestamp ) ) )
     721            add_option($cache_timestamp, '', '', 'no');
     722
     723        update_option($cache_option, $rss);
     724        update_option($cache_timestamp, time() );
    719725
    720726        return $cache_option;
     
    731737        $cache_option = 'rss_' . $this->file_name( $url );
    732738
    733         if ( ! $rss = get_transient( $cache_option ) ) {
     739        if ( ! get_option( $cache_option ) ) {
    734740            $this->debug(
    735741                "Cache doesn't contain: $url (cache option: $cache_option)"
     
    737743            return 0;
    738744        }
     745
     746        $rss = get_option( $cache_option );
    739747
    740748        return $rss;
     
    753761        $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
    754762
    755         if ( $mtime = get_transient($cache_timestamp) ) {
     763        if ( $mtime = get_option($cache_timestamp) ) {
    756764            // find how long ago the file was added to the cache
    757765            // and whether that is longer then MAX_AGE
  • trunk/wp-settings.php

    r10507 r10508  
    258258    wp_die(/*WP_I18N_BAD_PREFIX*/'<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/);
    259259
    260 if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') ) {
     260if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') )
    261261    require_once (WP_CONTENT_DIR . '/object-cache.php');
    262     $_wp_using_ext_object_cache = true;
    263 } else {
     262else
    264263    require_once (ABSPATH . WPINC . '/cache.php');
    265     $_wp_using_ext_object_cache = false;
    266 }
    267264
    268265wp_cache_init();
Note: See TracChangeset for help on using the changeset viewer.