From 091b7a876be7e828b5db8d95a05ec199106a7f25 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 5 Feb 2009 20:47:30 +0000 Subject: [PATCH] Revert 10507. Had extra bits in. see #8702 git-svn-id: http://svn.automattic.com/wordpress/trunk@10508 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 73 --------------------------------------- wp-includes/http.php | 68 ++++++++++++------------------------ wp-includes/rewrite.php | 6 ++-- wp-includes/rss.php | 16 ++++++--- wp-settings.php | 7 ++-- 5 files changed, 39 insertions(+), 131 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 4838b84bb2..6bcc79061c 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -624,79 +624,6 @@ function delete_option( $name ) { return true; } -/** - * Delete a transient - * - * @since 2.8.0 - * @package WordPress - * @subpackage Transient - * - * @param string $transient Transient name. Expected to not be SQL-escaped - * @return bool true if successful, false otherwise - */ -function delete_transient($transient) { - global $_wp_using_ext_object_cache, $wpdb; - - if ( $_wp_using_ext_object_cache ) { - return wp_cache_delete($transient, 'transient'); - } else { - $transient = $wpdb->escape($transient); - return delete_option($transient); - } -} - -/** - * Get the value of a transient - * - * If the transient does not exist or does not have a value, then the return value - * will be false. - * - * @since 2.8.0 - * @package WordPress - * @subpackage Transient - * - * @param string $transient Transient name. Expected to not be SQL-escaped - * @return mixed Value of transient - */ -function get_transient($transient) { - global $_wp_using_ext_object_cache, $wpdb; - - if ( $_wp_using_ext_object_cache ) { - return wp_cache_get($transient, 'transient'); - } else { - $transient = $wpdb->escape($transient); - return get_option($transient); - } -} - -/** - * Set/update the value of a transient - * - * You do not need to serialize values, if the value needs to be serialize, then - * it will be serialized before it is set. - * - * @since 2.8.0 - * @package WordPress - * @subpackage Transient - * - * @param string $transient Transient name. Expected to not be SQL-escaped - * @param mixed $value Transient value. - * @return bool False if value was not set and true if value was set. - */ -function set_transient($transient, $value) { - global $_wp_using_ext_object_cache, $wpdb; - - if ( $_wp_using_ext_object_cache ) { - return wp_cache_set($transient, $value, 'transient'); - } else { - $safe_transient = $wpdb->escape($transient); - if ( false === get_option( $safe_transient ) ) - return add_option($transient, $value, '', 'no'); - else - return update_option($transient, $value); - } -} - /** * Saves and restores user interface settings stored in a cookie. * diff --git a/wp-includes/http.php b/wp-includes/http.php index a832e1748a..b16008ccca 100644 --- a/wp-includes/http.php +++ b/wp-includes/http.php @@ -237,10 +237,10 @@ class WP_Http { } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) { $working_transport['streams'] = new WP_Http_Streams(); $blocking_transport[] = &$working_transport['streams']; - } else if ( true === WP_Http_Fopen::test() && apply_filters('use_fopen_transport', true) && ( isset($args['ssl']) && !$args['ssl'] ) ) { + } else if ( true === WP_Http_Fopen::test() && apply_filters('use_fopen_transport', true) ) { $working_transport['fopen'] = new WP_Http_Fopen(); $blocking_transport[] = &$working_transport['fopen']; - } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) && ( isset($args['ssl']) && !$args['ssl'] ) ) { + } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) { $working_transport['fsockopen'] = new WP_Http_Fsockopen(); $blocking_transport[] = &$working_transport['fsockopen']; } @@ -282,18 +282,15 @@ class WP_Http { if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) { $working_transport['exthttp'] = new WP_Http_ExtHttp(); $blocking_transport[] = &$working_transport['exthttp']; - } else if ( true === WP_Http_Curl::test() && apply_filters('use_curl_transport', true) ) { - $working_transport['curl'] = new WP_Http_Curl(); - $blocking_transport[] = &$working_transport['curl']; } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) { $working_transport['streams'] = new WP_Http_Streams(); $blocking_transport[] = &$working_transport['streams']; - } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) && ( isset($args['ssl']) && !$args['ssl'] ) ) { + } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) { $working_transport['fsockopen'] = new WP_Http_Fsockopen(); $blocking_transport[] = &$working_transport['fsockopen']; } - foreach ( array('curl', 'streams', 'fsockopen', 'exthttp') as $transport ) { + foreach ( array('streams', 'fsockopen', 'exthttp') as $transport ) { if ( isset($working_transport[$transport]) ) $nonblocking_transport[] = &$working_transport[$transport]; } @@ -361,27 +358,17 @@ class WP_Http { 'timeout' => apply_filters( 'http_request_timeout', 5), 'redirection' => apply_filters( 'http_request_redirection_count', 5), 'httpversion' => apply_filters( 'http_request_version', '1.0'), - 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ), + 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version ), 'blocking' => true, 'headers' => array(), 'body' => null, 'compress' => false, - 'decompress' => true, - 'sslverify' => true + 'decompress' => true ); $r = wp_parse_args( $args, $defaults ); $r = apply_filters( 'http_request_args', $r, $url ); - $arrURL = parse_url($url); - - // Determine if this is a https call and pass that on to the transport functions - // so that we can blacklist the transports that do not support ssl verification - if ( $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl' ) - $r['ssl'] = true; - else - $r['ssl'] = false; - if ( is_null( $r['headers'] ) ) $r['headers'] = array(); @@ -940,11 +927,7 @@ class WP_Http_Streams { 'max_redirects' => $r['redirection'], 'protocol_version' => (float) $r['httpversion'], 'header' => $strHeaders, - 'timeout' => $r['timeout'], - 'ssl' => array( - 'verify_peer' => apply_filters('https_ssl_verify', $r['sslverify']), - 'verify_host' => apply_filters('https_ssl_verify', $r['sslverify']) - ) + 'timeout' => $r['timeout'] ) ); @@ -1077,10 +1060,6 @@ class WP_Http_ExtHTTP { 'redirect' => $r['redirection'], 'useragent' => $r['user-agent'], 'headers' => $r['headers'], - 'ssl' => array( - 'verifypeer' => apply_filters('https_ssl_verify', $r['sslverify']), - 'verifyhost' => apply_filters('https_ssl_verify', $r['sslverify']) - ) ); if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) //Emits warning level notices for max redirects and timeouts @@ -1174,30 +1153,27 @@ class WP_Http_Curl { $r['timeout'] = 1; $handle = curl_init(); - curl_setopt( $handle, CURLOPT_URL, $url); - curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true ); - curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, apply_filters('https_ssl_verify', $r['sslverify']) ); - curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, apply_filters('https_ssl_verify', $r['sslverify']) ); - curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); - curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $r['timeout'] ); - curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] ); - curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); - switch ( $r['method'] ) { - case 'HEAD': - curl_setopt( $handle, CURLOPT_NOBODY, true ); - break; - case 'POST': - curl_setopt( $handle, CURLOPT_POST, true ); - curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); - break; + // The cURL extension requires that the option be set for the HEAD to + // work properly. + if ( 'HEAD' === $r['method'] ) { + curl_setopt( $handle, CURLOPT_NOBODY, true ); } - if ( true === $r['blocking'] ) + if ( true === $r['blocking'] ) { curl_setopt( $handle, CURLOPT_HEADER, true ); - else + curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 ); + } else { curl_setopt( $handle, CURLOPT_HEADER, false ); + curl_setopt( $handle, CURLOPT_NOBODY, true ); + curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 0 ); + } + + curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); + curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 1 ); + curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] ); + curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); // The option doesn't work with safe mode or when open_basedir is set. if ( !ini_get('safe_mode') && !ini_get('open_basedir') ) diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 7efb96ef8f..04e94971e5 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -1596,11 +1596,11 @@ class WP_Rewrite { * @return array Rewrite rules. */ function wp_rewrite_rules() { - $this->rules = get_transient('rewrite_rules'); + $this->rules = get_option('rewrite_rules'); if ( empty($this->rules) ) { $this->matches = 'matches'; $this->rewrite_rules(); - set_transient('rewrite_rules', $this->rules); + update_option('rewrite_rules', $this->rules); } return $this->rules; @@ -1783,7 +1783,7 @@ class WP_Rewrite { * @access public */ function flush_rules() { - delete_transient('rewrite_rules'); + delete_option('rewrite_rules'); $this->wp_rewrite_rules(); if ( function_exists('save_mod_rewrite_rules') ) save_mod_rewrite_rules(); diff --git a/wp-includes/rss.php b/wp-includes/rss.php index a33c3a7dc8..9962773486 100644 --- a/wp-includes/rss.php +++ b/wp-includes/rss.php @@ -714,8 +714,14 @@ class RSSCache { $cache_option = 'rss_' . $this->file_name( $url ); $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts'; - set_transient($cache_option, $rss); - set_transient($cache_timestamp, time() ); + // shouldn't these be using get_option() ? + if ( !$wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name = %s", $cache_option ) ) ) + add_option($cache_option, '', '', 'no'); + if ( !$wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name = %s", $cache_timestamp ) ) ) + add_option($cache_timestamp, '', '', 'no'); + + update_option($cache_option, $rss); + update_option($cache_timestamp, time() ); return $cache_option; } @@ -730,13 +736,15 @@ class RSSCache { $this->ERROR = ""; $cache_option = 'rss_' . $this->file_name( $url ); - if ( ! $rss = get_transient( $cache_option ) ) { + if ( ! get_option( $cache_option ) ) { $this->debug( "Cache doesn't contain: $url (cache option: $cache_option)" ); return 0; } + $rss = get_option( $cache_option ); + return $rss; } @@ -752,7 +760,7 @@ class RSSCache { $cache_option = $this->file_name( $url ); $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts'; - if ( $mtime = get_transient($cache_timestamp) ) { + if ( $mtime = get_option($cache_timestamp) ) { // find how long ago the file was added to the cache // and whether that is longer then MAX_AGE $age = time() - $mtime; diff --git a/wp-settings.php b/wp-settings.php index 4a35fb8761..553c67d4b7 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -257,13 +257,10 @@ $prefix = $wpdb->set_prefix($table_prefix); if ( is_wp_error($prefix) ) wp_die(/*WP_I18N_BAD_PREFIX*/'ERROR: $table_prefix in wp-config.php can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/); -if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') ) { +if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') ) require_once (WP_CONTENT_DIR . '/object-cache.php'); - $_wp_using_ext_object_cache = true; -} else { +else require_once (ABSPATH . WPINC . '/cache.php'); - $_wp_using_ext_object_cache = false; -} wp_cache_init(); if ( function_exists('wp_cache_add_global_groups') ) {