diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-01-02 16:00:05 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-01-02 16:00:05 +0000 |
commit | 1503e05616c295e6f980134dc341fa1a66dc9672 (patch) | |
tree | b0a7dc356affec0059670603f1cb990da7dbc026 /wp-includes | |
parent | c65d51fec1d641efd1ec8a44c046cd54d588fe3b (diff) | |
download | wordpress-mu-1503e05616c295e6f980134dc341fa1a66dc9672.tar.gz wordpress-mu-1503e05616c295e6f980134dc341fa1a66dc9672.tar.xz wordpress-mu-1503e05616c295e6f980134dc341fa1a66dc9672.zip |
Merge with WP 2.3.2
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1172 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes')
-rw-r--r-- | wp-includes/formatting.php | 35 | ||||
-rw-r--r-- | wp-includes/functions.php | 48 | ||||
-rw-r--r-- | wp-includes/pluggable.php | 4 | ||||
-rw-r--r-- | wp-includes/post.php | 5 | ||||
-rw-r--r-- | wp-includes/query.php | 8 | ||||
-rw-r--r-- | wp-includes/taxonomy.php | 8 | ||||
-rw-r--r-- | wp-includes/version.php | 4 | ||||
-rw-r--r-- | wp-includes/wp-db.php | 29 |
8 files changed, 110 insertions, 31 deletions
diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 2c95dbe..76f41d8 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -622,18 +622,35 @@ function antispambot($emailaddy, $mailto=0) { return $emailNOSPAMaddy; } +function _make_url_clickable_cb($matches) { + $url = $matches[2]; + $url = clean_url($url); + if ( empty($url) ) + return $matches[0]; + return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>"; +} + +function _make_web_ftp_clickable_cb($matches) { + $dest = $matches[2]; + $dest = 'http://' . $dest; + $dest = clean_url($dest); + if ( empty($dest) ) + return $matches[0]; + + return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>"; +} + +function _make_email_clickable_cb($matches) { + $email = $matches[2] . '@' . $matches[3]; + return $matches[1] . "<a href=\"mailto:$email\">$email</a>"; +} + function make_clickable($ret) { $ret = ' ' . $ret; // in testing, using arrays here was found to be faster - $ret = preg_replace( - array( - '#([\s>])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', - '#([\s>])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', - '#([\s>])([a-z0-9\-_.]+)@([^,< \n\r]+)#i'), - array( - '$1<a href="$2" rel="nofollow">$2</a>', - '$1<a href="http://$2" rel="nofollow">$2</a>', - '$1<a href="mailto:$2@$3">$2@$3</a>'),$ret); + $ret = preg_replace_callback('#([\s>])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_url_clickable_cb', $ret); + $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_web_ftp_clickable_cb', $ret); + $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret); // this one is not in an array because we need it to run last, for cleanup of accidental links within links $ret = preg_replace("#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i", "$1$3</a>", $ret); $ret = trim($ret); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index bd89231..a067a8a 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -204,10 +204,10 @@ function get_option($setting) { if ( false === $value ) { if ( defined('WP_INSTALLING') ) - $wpdb->hide_errors(); + $show = $wpdb->hide_errors(); $row = $wpdb->get_row("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1"); if ( defined('WP_INSTALLING') ) - $wpdb->show_errors(); + $wpdb->show_errors($show); if( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values $value = $row->option_value; @@ -242,11 +242,11 @@ function form_option($option) { function get_alloptions() { global $wpdb, $wp_queries; - $wpdb->hide_errors(); + $show = $wpdb->hide_errors(); if ( !$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'") ) { $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options"); } - $wpdb->show_errors(); + $wpdb->show_errors($show); foreach ($options as $option) { // "When trying to design a foolproof system, @@ -269,10 +269,10 @@ function wp_load_alloptions() { $alloptions = wp_cache_get('alloptions', 'options'); if ( !$alloptions ) { - $wpdb->hide_errors(); + $show = $wpdb->hide_errors(); if ( !$alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'") ) $alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options"); - $wpdb->show_errors(); + $wpdb->show_errors($show); $alloptions = array(); foreach ( (array) $alloptions_db as $o ) $alloptions[$o->option_name] = $o->option_value; @@ -899,9 +899,9 @@ function do_robots() { function is_blog_installed() { global $wpdb; - $wpdb->hide_errors(); + $show = $wpdb->hide_errors(); $installed = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'"); - $wpdb->show_errors(); + $wpdb->show_errors($show); $install_status = !empty( $installed ) ? TRUE : FALSE; return $install_status; @@ -1426,4 +1426,36 @@ function wp_ob_end_flush_all() while ( @ob_end_flush() ); } +function dead_db() { + global $wpdb; + + // Load custom DB error template, if present. + if ( file_exists( ABSPATH . 'wp-content/db-error.php' ) ) { + require_once( ABSPATH . 'wp-content/db-error.php' ); + die(); + } + + // If installing or in the admin, provide the verbose message. + if ( defined('WP_INSTALLING') || defined('WP_ADMIN') ) + wp_die($wpdb->error); + + // Otherwise, be terse. + status_header( 500 ); + nocache_headers(); + header( 'Content-Type: text/html; charset=utf-8' ); +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>> +<head> + <title>Database Error</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +</head> +<body> + <h1>Error establishing a database connection</h1> +</body> +</html> +<?php + die(); +} + ?> diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 8ce2985..d9dae0f 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -79,9 +79,9 @@ function get_userdata( $user_id ) { if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = '$user_id' LIMIT 1") ) return false; - $wpdb->hide_errors(); + $show = $wpdb->hide_errors(); $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id'"); - $wpdb->show_errors(); + $wpdb->show_errors($show); if ($metavalues) { foreach ( $metavalues as $meta ) { diff --git a/wp-includes/post.php b/wp-includes/post.php index ea41d62..6c62224 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -428,6 +428,10 @@ function get_post_custom_values( $key = '', $post_id = 0 ) { } function sanitize_post($post, $context = 'display') { + + if ( 'raw' == $context ) + return $post; + // TODO: Use array keys instead of hard coded list $fields = array('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_date', 'post_date_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'post_category'); @@ -1139,6 +1143,7 @@ function &get_pages($args = '') { $exclude = ''; $meta_key = ''; $meta_value = ''; + $hierarchical = false; $incpages = preg_split('/[\s,]+/',$include); if ( count($incpages) ) { foreach ( $incpages as $incpage ) { diff --git a/wp-includes/query.php b/wp-includes/query.php index 61a78f6..82f0807 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -32,9 +32,9 @@ function wp_reset_query() { */
function is_admin () {
- global $wp_query;
-
- return ($wp_query->is_admin || (stripos($_SERVER['REQUEST_URI'], 'wp-admin/') !== false));
+ if ( defined('WP_ADMIN') )
+ return WP_ADMIN;
+ return false;
}
function is_archive () {
@@ -642,7 +642,7 @@ class WP_Query { if ('' != $qv['preview'])
$this->is_preview = true;
- if ( strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false )
+ if ( is_admin() )
$this->is_admin = true;
if ( false !== strpos($qv['feed'], 'comments-') ) {
diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index ea9fae6..92ebdda 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -663,6 +663,10 @@ function is_term($term, $taxonomy = '') { * @return array|object Term with all fields sanitized */ function sanitize_term($term, $taxonomy, $context = 'display') { + + if ( 'raw' == $context ) + return $term; + $fields = array('term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group'); $do_object = false; @@ -933,8 +937,8 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) { $term_group = $alias->term_group; } else { // The alias isn't in a group, so let's create a new one and firstly add the alias term to it. - $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; - $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $alias->term_id ) ); + $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1; + $wpdb->query("UPDATE $wpdb->terms SET term_group = $term_group WHERE term_id = $alias->term_id"); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index e2814c1..7a78e44 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -2,8 +2,8 @@ // This holds the version number in a separate file so we can bump it without cluttering the SVN -$wp_version = '2.3.1'; -$wpmu_version = '1.3'; +$wp_version = '2.3.2'; +$wpmu_version = '1.3.1'; $wp_db_version = 6124; ?> diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index ef1070e..adadc31 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -15,11 +15,12 @@ if (!defined('SAVEQUERIES')) class wpdb { - var $show_errors = true; + var $show_errors = false; var $num_queries = 0; var $last_query; var $col_info; var $queries; + var $ready = false; // Our tables var $posts; @@ -58,6 +59,9 @@ class wpdb { function __construct($dbuser, $dbpassword, $dbname, $dbhost) { register_shutdown_function(array(&$this, "__destruct")); + if ( defined('WP_DEBUG') and WP_DEBUG == true ) + $this->show_errors(); + $this->charset = 'utf8'; $this->collete = 'utf8'; @@ -79,8 +83,11 @@ class wpdb { </ul> <p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p> "); + return; } + $this->ready = true; + if ( !empty($this->charset) && version_compare(mysql_get_server_info(), '4.1.0', '>=') ) $this->query("SET NAMES '$this->charset'"); @@ -97,6 +104,7 @@ class wpdb { */ function select($db, &$dbh) { if (!@mysql_select_db($db, $dbh)) { + $this->ready = false; $this->bail(" <h1>Can’t select database</h1> <p>We were able to connect to the database server (which means your username and password is okay) but not able to select the <code>$db</code> database.</p> @@ -105,6 +113,7 @@ class wpdb { <li>On some systems the name of your database is prefixed with your username, so it would be like username_wordpress. Could that be the problem?</li> </ul> <p>If you don't know how to setup a database you should <strong>contact your host</strong>. If all else fails you may find help at the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>"); + return; } } @@ -174,12 +183,16 @@ class wpdb { // ================================================================== // Turn error handling on or off.. - function show_errors() { - $this->show_errors = true; + function show_errors( $show = true ) { + $errors = $this->show_errors; + $this->show_errors = $show; + return $errors; } function hide_errors() { + $show = $this->show_errors; $this->show_errors = false; + return $show; } // ================================================================== @@ -231,6 +244,9 @@ class wpdb { // Basic Query - see docs for more detail function query($query) { + if ( ! $this->ready ) + return false; + // filter the query, if filters are available // NOTE: some queries are made before the plugins have been loaded, and thus cannot be filtered with this method if ( function_exists('apply_filters') ) @@ -470,8 +486,13 @@ class wpdb { * @param string $message */ function bail($message) { // Just wraps errors in a nice header and footer - if ( !$this->show_errors ) + if ( !$this->show_errors ) { + if ( class_exists('WP_Error') ) + $this->error = new WP_Error('500', $message); + else + $this->error = $message; return false; + } wp_die($message); } } |