[wp-cvs] wordpress/wp-includes functions-post.php, 1.1, 1.2 functions.php, 1.103, 1.104 links-update-xml.php, 1.5, 1.6 links.php, 1.12, 1.13 template-functions-author.php, 1.8, 1.9 template-functions-category.php, 1.28, 1.29 template-functions-comment.php, 1.20, 1.21 template-functions-general.php, 1.29, 1.30 template-functions-links.php, 1.11, 1.12 template-functions-post.php, 1.22, 1.23 wp-db.php, 1.11, 1.12

Matthew Mullenweg saxmatt at users.sourceforge.net
Mon May 24 03:22:21 CDT 2004


Update of /cvsroot/cafelog/wordpress/wp-includes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19270/wp-includes

Modified Files:
	functions-post.php functions.php links-update-xml.php 
	links.php template-functions-author.php 
	template-functions-category.php template-functions-comment.php 
	template-functions-general.php template-functions-links.php 
	template-functions-post.php wp-db.php 
Log Message:
Giant commit, sorry mailing list people. Move all table names to new $wpdb versions. Works but the whole app needs thorough testing now.

Index: functions.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/functions.php,v
retrieving revision 1.103
retrieving revision 1.104
diff -C2 -d -r1.103 -r1.104
*** functions.php	24 May 2004 02:55:39 -0000	1.103
--- functions.php	24 May 2004 08:22:18 -0000	1.104
***************
*** 96,100 ****
  
  function get_lastpostdate($timezone = 'server') {
! 	global $tableposts, $cache_lastpostdate, $pagenow, $wpdb;
  	$add_seconds_blog = get_settings('gmt_offset') * 3600;
  	$add_seconds_server = date('Z');
--- 96,100 ----
  
  function get_lastpostdate($timezone = 'server') {
! 	global $cache_lastpostdate, $pagenow, $wpdb;
  	$add_seconds_blog = get_settings('gmt_offset') * 3600;
  	$add_seconds_server = date('Z');
***************
*** 103,113 ****
  		switch(strtolower($timezone)) {
  			case 'gmt':
! 				$lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $tableposts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
  				break;
  			case 'blog':
! 				$lastpostdate = $wpdb->get_var("SELECT post_date FROM $tableposts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
  				break;
  			case 'server':
! 				$lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $tableposts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
  				break;
  		}
--- 103,113 ----
  		switch(strtolower($timezone)) {
  			case 'gmt':
! 				$lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
  				break;
  			case 'blog':
! 				$lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
  				break;
  			case 'server':
! 				$lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
  				break;
  		}
***************
*** 120,124 ****
  
  function get_lastpostmodified($timezone = 'server') {
! 	global $tableposts, $cache_lastpostmodified, $pagenow, $wpdb;
  	$add_seconds_blog = get_settings('gmt_offset') * 3600;
  	$add_seconds_server = date('Z');
--- 120,124 ----
  
  function get_lastpostmodified($timezone = 'server') {
! 	global $cache_lastpostmodified, $pagenow, $wpdb;
  	$add_seconds_blog = get_settings('gmt_offset') * 3600;
  	$add_seconds_server = date('Z');
***************
*** 127,137 ****
  		switch(strtolower($timezone)) {
  			case 'gmt':
! 				$lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $tableposts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
  				break;
  			case 'blog':
! 				$lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $tableposts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
  				break;
  			case 'server':
! 				$lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $tableposts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
  				break;
  		}
--- 127,137 ----
  		switch(strtolower($timezone)) {
  			case 'gmt':
! 				$lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
  				break;
  			case 'blog':
! 				$lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
  				break;
  			case 'server':
! 				$lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
  				break;
  		}
***************
*** 173,179 ****
  
  function get_userdata($userid) {
! 	global $wpdb, $cache_userdata, $tableusers;
  	if ( empty($cache_userdata[$userid]) ) {
! 		$user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID = '$userid'");
  		$user->user_nickname = stripslashes($user->user_nickname);
  		$user->user_firstname = stripslashes($user->user_firstname);
--- 173,179 ----
  
  function get_userdata($userid) {
! 	global $wpdb, $cache_userdata;
  	if ( empty($cache_userdata[$userid]) ) {
! 		$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = '$userid'");
  		$user->user_nickname = stripslashes($user->user_nickname);
  		$user->user_firstname = stripslashes($user->user_firstname);
***************
*** 188,194 ****
  
  function get_userdatabylogin($user_login) {
! 	global $tableusers, $cache_userdata, $wpdb;
  	if ( empty($cache_userdata["$user_login"]) ) {
! 		$user = $wpdb->get_row("SELECT * FROM $tableusers WHERE user_login = '$user_login'");
  		$cache_userdata["$user_login"] = $user;
  	} else {
--- 188,194 ----
  
  function get_userdatabylogin($user_login) {
! 	global $cache_userdata, $wpdb;
  	if ( empty($cache_userdata["$user_login"]) ) {
! 		$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'");
  		$cache_userdata["$user_login"] = $user;
  	} else {
***************
*** 199,205 ****
  
  function get_userid($user_login) {
! 	global $tableusers, $cache_userdata, $wpdb;
  	if ( empty($cache_userdata["$user_login"]) ) {
! 		$user_id = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_login = '$user_login'");
  
  		$cache_userdata["$user_login"] = $user_id;
--- 199,205 ----
  
  function get_userid($user_login) {
! 	global $cache_userdata, $wpdb;
  	if ( empty($cache_userdata["$user_login"]) ) {
! 		$user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$user_login'");
  
  		$cache_userdata["$user_login"] = $user_id;
***************
*** 211,216 ****
  
  function get_usernumposts($userid) {
! 	global $tableposts, $tablecomments, $wpdb;
! 	return $wpdb->get_var("SELECT COUNT(*) FROM $tableposts WHERE post_author = '$userid'");
  }
  
--- 211,216 ----
  
  function get_usernumposts($userid) {
! 	global $wpdb;
! 	return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid'");
  }
  
***************
*** 218,222 ****
  // determine the post ID it represents.
  function url_to_postid($url = '') {
! 	global $wpdb, $tableposts;
  
  	$siteurl = get_settings('home');
--- 218,222 ----
  // determine the post ID it represents.
  function url_to_postid($url = '') {
! 	global $wpdb;
  
  	$siteurl = get_settings('home');
***************
*** 291,295 ****
  
  	// Run the query to get the post ID:
! 	$id = intval($wpdb->get_var("SELECT ID FROM $tableposts WHERE 1 = 1 " . $where));
  
  	return $id;
--- 291,295 ----
  
  	// Run the query to get the post ID:
! 	$id = intval($wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE 1 = 1 " . $where));
  
  	return $id;
***************
*** 322,327 ****
  
  function get_alloptions() {
! 	global $tableoptions, $wpdb;
! 	$options = $wpdb->get_results("SELECT option_name, option_value FROM $tableoptions");
  	if ($options) {
  		foreach ($options as $option) {
--- 322,327 ----
  
  function get_alloptions() {
! 	global $wpdb;
! 	$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options");
  	if ($options) {
  		foreach ($options as $option) {
***************
*** 339,347 ****
  
  function update_option($option_name, $newvalue) {
! 	global $wpdb, $tableoptions, $cache_settings;
  	$newvalue = stripslashes($newvalue);
  	$newvalue = trim($newvalue); // I can't think of any situation we wouldn't want to trim
  	$newvalue = $wpdb->escape($newvalue);
! 	$wpdb->query("UPDATE $tableoptions SET option_value = '$newvalue' WHERE option_name = '$option_name'");
  	$cache_settings = get_alloptions(); // Re cache settings
  	return true;
--- 339,347 ----
  
  function update_option($option_name, $newvalue) {
! 	global $wpdb, $cache_settings;
  	$newvalue = stripslashes($newvalue);
  	$newvalue = trim($newvalue); // I can't think of any situation we wouldn't want to trim
  	$newvalue = $wpdb->escape($newvalue);
! 	$wpdb->query("UPDATE $wpdb->options SET option_value = '$newvalue' WHERE option_name = '$option_name'");
  	$cache_settings = get_alloptions(); // Re cache settings
  	return true;
***************
*** 352,360 ****
  function add_option($name, $value='') {
  	// Adds an option if it doesn't already exist
! 	global $wpdb, $tableoptions;
  	if(!get_settings($name)) {
  		$name = $wpdb->escape($name);
  		$value = $wpdb->escape($value);
! 		$wpdb->query("INSERT INTO $tableoptions (option_name, option_value) VALUES ('$name', '$value')");
  
  		if($wpdb->insert_id) {
--- 352,360 ----
  function add_option($name, $value='') {
  	// Adds an option if it doesn't already exist
! 	global $wpdb;
  	if(!get_settings($name)) {
  		$name = $wpdb->escape($name);
  		$value = $wpdb->escape($value);
! 		$wpdb->query("INSERT INTO $wpdb->options (option_name, option_value) VALUES ('$name', '$value')");
  
  		if($wpdb->insert_id) {
***************
*** 367,383 ****
  
  function delete_option($name) {
! 	global $wpdb, $tableoptions, $tableoptiongroup_options;
  	// Get the ID, if no ID then return
! 	$option_id = $wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = '$name'");
  	if (!$option_id) return false;
! 	$wpdb->query("DELETE FROM $tableoptiongroup_options WHERE option_id = '$option_id'");
! 	$wpdb->query("DELETE FROM $tableoptions WHERE option_name = '$name'");
  	return true;
  }
  
  function get_postdata($postid) {
! 	global $post, $tableposts, $wpdb;
  
! 	$post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID = '$postid'");
  	
  	$postdata = array (
--- 367,383 ----
  
  function delete_option($name) {
! 	global $wpdb;
  	// Get the ID, if no ID then return
! 	$option_id = $wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = '$name'");
  	if (!$option_id) return false;
! 	$wpdb->query("DELETE FROM $wpdb->optiongroup_options WHERE option_id = '$option_id'");
! 	$wpdb->query("DELETE FROM $wpdb->options WHERE option_name = '$name'");
  	return true;
  }
  
  function get_postdata($postid) {
! 	global $post, $wpdb;
  
! 	$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$postid'");
  	
  	$postdata = array (
***************
*** 403,409 ****
  
  function get_commentdata($comment_ID,$no_cache=0,$include_unapproved=false) { // less flexible, but saves DB queries
! 	global $postc,$id,$commentdata,$tablecomments, $wpdb;
  	if ($no_cache) {
! 		$query = "SELECT * FROM $tablecomments WHERE comment_ID = '$comment_ID'";
  		if (false == $include_unapproved) {
  		    $query .= " AND comment_approved = '1'";
--- 403,409 ----
  
  function get_commentdata($comment_ID,$no_cache=0,$include_unapproved=false) { // less flexible, but saves DB queries
! 	global $postc,$id,$commentdata, $wpdb;
  	if ($no_cache) {
! 		$query = "SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_ID'";
  		if (false == $include_unapproved) {
  		    $query .= " AND comment_approved = '1'";
***************
*** 432,438 ****
  
  function get_catname($cat_ID) {
! 	global $tablecategories, $cache_catnames, $wpdb;
  	if ( !$cache_catnames ) {
!         $results = $wpdb->get_results("SELECT * FROM $tablecategories") or die('Oops, couldn\'t query the db for categories.');
  		foreach ($results as $post) {
  			$cache_catnames[$post->cat_ID] = $post->cat_name;
--- 432,438 ----
  
  function get_catname($cat_ID) {
! 	global $cache_catnames, $wpdb;
  	if ( !$cache_catnames ) {
!         $results = $wpdb->get_results("SELECT * FROM $wpdb->categories") or die('Oops, couldn\'t query the db for categories.');
  		foreach ($results as $post) {
  			$cache_catnames[$post->cat_ID] = $post->cat_name;
***************
*** 545,549 ****
  // Send a Trackback
  function trackback($trackback_url, $title, $excerpt, $ID) {
! 	global $wpdb, $tableposts;
  	$title = urlencode(stripslashes($title));
  	$excerpt = urlencode(stripslashes($excerpt));
--- 545,549 ----
  // Send a Trackback
  function trackback($trackback_url, $title, $excerpt, $ID) {
! 	global $wpdb;
  	$title = urlencode(stripslashes($title));
  	$excerpt = urlencode(stripslashes($excerpt));
***************
*** 573,578 ****
  	@fclose($fs);
  
! 	$wpdb->query("UPDATE $tableposts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = '$ID'");
! 	$wpdb->query("UPDATE $tableposts SET to_ping = REPLACE(to_ping, '$tb_url', '') WHERE ID = '$ID'");
  	return $result;
  }
--- 573,578 ----
  	@fclose($fs);
  
! 	$wpdb->query("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = '$ID'");
! 	$wpdb->query("UPDATE $wpdb->posts SET to_ping = REPLACE(to_ping, '$tb_url', '') WHERE ID = '$ID'");
  	return $result;
  }
***************
*** 899,913 ****
   */
  function wp_set_comment_status($comment_id, $comment_status) {
!     global $wpdb, $tablecomments;
  
      switch($comment_status) {
  		case 'hold':
! 			$query = "UPDATE $tablecomments SET comment_approved='0' WHERE comment_ID='$comment_id' LIMIT 1";
  		break;
  		case 'approve':
! 			$query = "UPDATE $tablecomments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1";
  		break;
  		case 'delete':
! 			$query = "DELETE FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1";
  		break;
  		default:
--- 899,913 ----
   */
  function wp_set_comment_status($comment_id, $comment_status) {
!     global $wpdb;
  
      switch($comment_status) {
  		case 'hold':
! 			$query = "UPDATE $wpdb->comments SET comment_approved='0' WHERE comment_ID='$comment_id' LIMIT 1";
  		break;
  		case 'approve':
! 			$query = "UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1";
  		break;
  		case 'delete':
! 			$query = "DELETE FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1";
  		break;
  		default:
***************
*** 935,941 ****
   */
  function wp_get_comment_status($comment_id) {
!     global $wpdb, $tablecomments;
      
!     $result = $wpdb->get_var("SELECT comment_approved FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1");
      if ($result == NULL) {
          return "deleted";
--- 935,941 ----
   */
  function wp_get_comment_status($comment_id) {
!     global $wpdb;
      
!     $result = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
      if ($result == NULL) {
          return "deleted";
***************
*** 950,959 ****
  
  function wp_notify_postauthor($comment_id, $comment_type='comment') {
!     global $wpdb, $tablecomments, $tableposts, $tableusers;
      global $querystring_start, $querystring_equal, $querystring_separator;
      
!     $comment = $wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1");
!     $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID='$comment->comment_post_ID' LIMIT 1");
!     $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID='$post->post_author' LIMIT 1");
  
      if ('' == $user->user_email) return false; // If there's no email to send the comment to
--- 950,959 ----
  
  function wp_notify_postauthor($comment_id, $comment_type='comment') {
!     global $wpdb;
      global $querystring_start, $querystring_equal, $querystring_separator;
      
!     $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
!     $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1");
!     $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1");
  
      if ('' == $user->user_email) return false; // If there's no email to send the comment to
***************
*** 1010,1022 ****
   */
  function wp_notify_moderator($comment_id) {
!     global $wpdb, $tablecomments, $tableposts, $tableusers;
      global $querystring_start, $querystring_equal, $querystring_separator;
      
!     $comment = $wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1");
!     $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID='$comment->comment_post_ID' LIMIT 1");
!     $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID='$post->post_author' LIMIT 1");
  
      $comment_author_domain = gethostbyaddr($comment->comment_author_IP);
!     $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $tablecomments WHERE comment_approved = '0'");
  
      $notify_message  = "A new comment on the post #$comment->comment_post_ID \"".stripslashes($post->post_title)."\" is waiting for your approval\r\n\r\n";
--- 1010,1022 ----
   */
  function wp_notify_moderator($comment_id) {
!     global $wpdb;
      global $querystring_start, $querystring_equal, $querystring_separator;
      
!     $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
!     $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1");
!     $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1");
  
      $comment_author_domain = gethostbyaddr($comment->comment_author_IP);
!     $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");
  
      $notify_message  = "A new comment on the post #$comment->comment_post_ID \"".stripslashes($post->post_title)."\" is waiting for your approval\r\n\r\n";
***************
*** 1317,1321 ****
  
  function get_posts($args) {
! 	global $wpdb, $tableposts;
  	parse_str($args, $r);
  	if (!isset($r['numberposts'])) $r['numberposts'] = 5;
--- 1317,1321 ----
  
  function get_posts($args) {
! 	global $wpdb;
  	parse_str($args, $r);
  	if (!isset($r['numberposts'])) $r['numberposts'] = 5;
***************
*** 1328,1332 ****
  	$now = current_time('mysql');
  
! 	$posts = $wpdb->get_results("SELECT DISTINCT * FROM $tableposts WHERE post_date <= '$now' AND (post_status = 'publish') GROUP BY $tableposts.ID ORDER BY post_date DESC LIMIT " . $r['offset'] . ',' . $r['numberposts']);
  	
  	return $posts;
--- 1328,1332 ----
  	$now = current_time('mysql');
  
! 	$posts = $wpdb->get_results("SELECT DISTINCT * FROM $wpdb->posts WHERE post_date <= '$now' AND (post_status = 'publish') GROUP BY $wpdb->posts.ID ORDER BY post_date DESC LIMIT " . $r['offset'] . ',' . $r['numberposts']);
  	
  	return $posts;
***************
*** 1355,1359 ****
  
  function query_posts($query) {
!     global $wpdb, $tablepost2cat, $tableposts, $tablecategories, $tableusers,
          $pagenow;
  
--- 1355,1359 ----
  
  function query_posts($query) {
!     global $wpdb,
          $pagenow;
  
***************
*** 1486,1490 ****
              $andor = 'OR';
          }
!         $join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) ";
          $cat_array = explode(' ',$cat);
          $whichcat .= ' AND (category_id '.$eq.' '.intval($cat_array[0]);
--- 1486,1490 ----
              $andor = 'OR';
          }
!         $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) ";
          $cat_array = explode(' ',$cat);
          $whichcat .= ' AND (category_id '.$eq.' '.intval($cat_array[0]);
***************
*** 1512,1519 ****
          }
          $category_name = preg_replace('|[^a-z0-9-_]|i', '', $category_name);
!         $tables = ", $tablepost2cat, $tablecategories";
!         $join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) LEFT JOIN $tablecategories ON ($tablepost2cat.category_id = $tablecategories.cat_ID) ";
          $whichcat = " AND (category_nicename = '$category_name'";
!         $cat = $wpdb->get_var("SELECT cat_ID FROM $tablecategories WHERE category_nicename = '$category_name'");
          $whichcat .= get_category_children($cat, " OR category_id = ");
          $whichcat .= ")";
--- 1512,1519 ----
          }
          $category_name = preg_replace('|[^a-z0-9-_]|i', '', $category_name);
!         $tables = ", $wpdb->post2cat, $wpdb->categories";
!         $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
          $whichcat = " AND (category_nicename = '$category_name'";
!         $cat = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_name'");
          $whichcat .= get_category_children($cat, " OR category_id = ");
          $whichcat .= ")";
***************
*** 1556,1560 ****
          }
          $author_name = preg_replace('|[^a-z0-9-_]|', '', strtolower($author_name));
!         $author = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_nicename='".$author_name."'");
          $whichauthor .= ' AND (post_author = '.intval($author).')';
      }
--- 1556,1560 ----
          }
          $author_name = preg_replace('|[^a-z0-9-_]|', '', strtolower($author_name));
!         $author = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$author_name."'");
          $whichauthor .= ' AND (post_author = '.intval($author).')';
      }
***************
*** 1663,1668 ****
      else
          $where .= ')';
!     $where .= " GROUP BY $tableposts.ID";
!     $request = " SELECT $distinct * FROM $tableposts $join WHERE 1=1".$where." ORDER BY post_$orderby $limits";
  
  
--- 1663,1668 ----
      else
          $where .= ')';
!     $where .= " GROUP BY $wpdb->posts.ID";
!     $request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1".$where." ORDER BY post_$orderby $limits";
  
  
***************
*** 1683,1688 ****
  function update_post_caches($posts) {
      global $category_cache, $comment_count_cache, $post_meta_cache;
!     global $tablecategories, $tablepost2cat, $tableposts, $tablecomments,
!         $tablepostmeta, $wpdb;
  
      // No point in doing all this work if we didn't match any posts.
--- 1683,1687 ----
  function update_post_caches($posts) {
      global $category_cache, $comment_count_cache, $post_meta_cache;
!     global $wpdb;
  
      // No point in doing all this work if we didn't match any posts.
***************
*** 1699,1703 ****
      $dogs = $wpdb->get_results("SELECT DISTINCT
          ID, category_id, cat_name, category_nicename, category_description, category_parent
!         FROM $tablecategories, $tablepost2cat, $tableposts
          WHERE category_id = cat_ID AND post_id = ID AND post_id IN ($post_id_list)");
          
--- 1698,1702 ----
      $dogs = $wpdb->get_results("SELECT DISTINCT
          ID, category_id, cat_name, category_nicename, category_description, category_parent
!         FROM $wpdb->categories, $wpdb->post2cat, $wpdb->posts
          WHERE category_id = cat_ID AND post_id = ID AND post_id IN ($post_id_list)");
          
***************
*** 1708,1713 ****
      // Do the same for comment numbers
      $comment_counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount
!         FROM $tableposts
!         LEFT JOIN $tablecomments ON ( comment_post_ID = ID  AND comment_approved =  '1')
          WHERE post_status =  'publish' AND ID IN ($post_id_list)
          GROUP BY ID");
--- 1707,1712 ----
      // Do the same for comment numbers
      $comment_counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount
!         FROM $wpdb->posts
!         LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID  AND comment_approved =  '1')
          WHERE post_status =  'publish' AND ID IN ($post_id_list)
          GROUP BY ID");
***************
*** 1722,1726 ****
      if ( $meta_list = $wpdb->get_results("
  			SELECT post_id,meta_key,meta_value 
! 			FROM $tablepostmeta 
  			WHERE post_id IN($post_id_list)
  			ORDER BY post_id,meta_key
--- 1721,1725 ----
      if ( $meta_list = $wpdb->get_results("
  			SELECT post_id,meta_key,meta_value 
! 			FROM $wpdb->postmeta 
  			WHERE post_id IN($post_id_list)
  			ORDER BY post_id,meta_key
***************
*** 1747,1752 ****
  
  function update_category_cache() {
!     global $cache_categories, $tablecategories, $wpdb;
!     $dogs = $wpdb->get_results("SELECT * FROM $tablecategories WHERE 1=1");
      foreach ($dogs as $catt) {
          $cache_categories[$catt->cat_ID] = $catt;
--- 1746,1751 ----
  
  function update_category_cache() {
!     global $cache_categories, $wpdb;
!     $dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE 1=1");
      foreach ($dogs as $catt) {
          $cache_categories[$catt->cat_ID] = $catt;
***************
*** 1755,1761 ****
  
  function update_user_cache() {
!     global $cache_userdata, $tableusers, $wpdb;
  
!     $users = $wpdb->get_results("SELECT * FROM $tableusers WHERE user_level > 0");
      foreach ($users as $user) {
          $cache_userdata[$user->ID] = $user;
--- 1754,1760 ----
  
  function update_user_cache() {
!     global $cache_userdata, $wpdb;
  
!     $users = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE user_level > 0");
      foreach ($users as $user) {
          $cache_userdata[$user->ID] = $user;

Index: links-update-xml.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/links-update-xml.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** links-update-xml.php	5 May 2004 06:44:59 -0000	1.5
--- links-update-xml.php	24 May 2004 08:22:18 -0000	1.6
***************
*** 20,25 ****
   **/
  function preload_links() {
! 	global $tablelinks, $all_links, $wpdb;
! 	$links = $wpdb->get_results("SELECT link_id, link_url FROM $tablelinks WHERE link_visible = 'Y' AND link_url <> ''");
  	foreach ($links as $link) {
  		$link_url = transform_url($link->link_url);
--- 20,25 ----
   **/
  function preload_links() {
! 	global $all_links, $wpdb;
! 	$links = $wpdb->get_results("SELECT link_id, link_url FROM $wpdb->links WHERE link_visible = 'Y' AND link_url <> ''");
  	foreach ($links as $link) {
  		$link_url = transform_url($link->link_url);
***************
*** 33,41 ****
   **/
  function update_links() {
! 	global $tablelinks, $all_links, $wpdb;
  	reset($all_links);
  	while (list($id, $val) = each($all_links)) {
  		if ($val[1]) {
! 			$wpdb->query("UPDATE $tablelinks SET link_updated = '$val[1]' WHERE link_id = $val[0]");
  		}
  	} // end while
--- 33,41 ----
   **/
  function update_links() {
! 	global $all_links, $wpdb;
  	reset($all_links);
  	while (list($id, $val) = each($all_links)) {
  		if ($val[1]) {
! 			$wpdb->query("UPDATE $wpdb->links SET link_updated = '$val[1]' WHERE link_id = $val[0]");
  		}
  	} // end while

Index: template-functions-links.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/template-functions-links.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** template-functions-links.php	18 May 2004 08:36:53 -0000	1.11
--- template-functions-links.php	24 May 2004 08:22:18 -0000	1.12
***************
*** 28,32 ****
  
  function get_permalink($id=false) {
!     global $post, $wpdb, $tableposts;
      global $querystring_start, $querystring_equal;
  
--- 28,32 ----
  
  function get_permalink($id=false) {
!     global $post, $wpdb;
      global $querystring_start, $querystring_equal;
  
***************
*** 59,63 ****
          }
      } else { // if an ID is given
!         $idpost = $wpdb->get_row("SELECT post_date, post_name FROM $tableposts WHERE ID = $id");
          if ('' != get_settings('permalink_structure')) {
  	    $unixtime = strtotime($idpost->post_date);
--- 59,63 ----
          }
      } else { // if an ID is given
!         $idpost = $wpdb->get_row("SELECT post_date, post_name FROM $wpdb->posts WHERE ID = $id");
          if ('' != get_settings('permalink_structure')) {
  	    $unixtime = strtotime($idpost->post_date);

Index: links.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/links.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** links.php	10 May 2004 08:26:42 -0000	1.12
--- links.php	24 May 2004 08:22:18 -0000	1.13
***************
*** 27,33 ****
                           $show_description = true, $show_rating = false,
                           $limit = -1, $show_updated = 0) {
!     global $tablelinkcategories, $wpdb;
      $cat_id = -1;
!     $results = $wpdb->get_results("SELECT cat_id FROM $tablelinkcategories WHERE cat_name='$cat_name'");
      if ($results) {
          foreach ($results as $result) {
--- 27,33 ----
                           $show_description = true, $show_rating = false,
                           $limit = -1, $show_updated = 0) {
!     global $wpdb;
      $cat_id = -1;
!     $results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
      if ($results) {
          foreach ($results as $result) {
***************
*** 50,58 ****
   **/
  function wp_get_linksbyname($category) {
!     global $wpdb, $tablelinkcategories;
  
      $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
           . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
!          . " text_after_all, list_limit FROM $tablelinkcategories WHERE cat_name='$category'");
      if ($cat) {
          if ($cat->sort_desc == 'Y') {
--- 50,58 ----
   **/
  function wp_get_linksbyname($category) {
!     global $wpdb;
  
      $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
           . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
!          . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_name='$category'");
      if ($cat) {
          if ($cat->sort_desc == 'Y') {
***************
*** 72,80 ****
   **/
  function wp_get_links($category) {
!     global $wpdb, $tablelinkcategories;
  
      $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
           . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
!          . " text_after_all, list_limit FROM $tablelinkcategories WHERE cat_id=$category");
      if ($cat) {
          if ($cat->sort_desc == 'Y') {
--- 72,80 ----
   **/
  function wp_get_links($category) {
!     global $wpdb;
  
      $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
           . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
!          . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$category");
      if ($cat) {
          if ($cat->sort_desc == 'Y') {
***************
*** 115,119 ****
                     $limit = -1, $show_updated = 1, $echo = true) {
  
!     global $tablelinks, $wpdb;
  
      $direction = ' ASC';
--- 115,119 ----
                     $limit = -1, $show_updated = 1, $echo = true) {
  
!     global $wpdb;
  
      $direction = ' ASC';
***************
*** 156,160 ****
      $sql = "SELECT link_url, link_name, link_image, link_target,
              link_description, link_rating, link_rel $length $recently_updated_test $get_updated
!             FROM $tablelinks
              WHERE link_visible = 'Y' " .
             $category_query;
--- 156,160 ----
      $sql = "SELECT link_url, link_name, link_image, link_target,
              link_description, link_rating, link_rel $length $recently_updated_test $get_updated
!             FROM $wpdb->links
              WHERE link_visible = 'Y' " .
             $category_query;
***************
*** 278,284 ****
   **/
  function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
!     global $tablelinkcategories, $wpdb;
      $cat_id = -1;
!     $results = $wpdb->get_results("SELECT cat_id FROM $tablelinkcategories WHERE cat_name='$cat_name'");
      if ($results) {
          foreach ($results as $result) {
--- 278,284 ----
   **/
  function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
!     global $wpdb;
      $cat_id = -1;
!     $results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
      if ($results) {
          foreach ($results as $result) {
***************
*** 325,331 ****
   **/
  function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
!     global $tablelinks, $wpdb;
  
!     $sql = "SELECT * FROM $tablelinks WHERE link_visible = 'Y'";
      if ($category != -1) {
          $sql .= " AND link_category = $category ";
--- 325,331 ----
   **/
  function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
!     global $wpdb;
  
!     $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'";
      if ($category != -1) {
          $sql .= " AND link_category = $category ";
***************
*** 460,467 ****
   */
  function get_linkcatname($id = 0) {
!     global $tablelinkcategories, $wpdb;
      $cat_name = '';
      if ('' != $id) {
!         $cat_name = $wpdb->get_var("SELECT cat_name FROM $tablelinkcategories WHERE cat_id=$id");
      }
      return stripslashes($cat_name);
--- 460,467 ----
   */
  function get_linkcatname($id = 0) {
!     global $wpdb;
      $cat_name = '';
      if ('' != $id) {
!         $cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->linkcategories WHERE cat_id=$id");
      }
      return stripslashes($cat_name);
***************
*** 474,479 ****
   */
  function get_autotoggle($id = 0) {
!     global $tablelinkcategories, $wpdb;
!     $auto_toggle = $wpdb->get_var("SELECT auto_toggle FROM $tablelinkcategories WHERE cat_id=$id");
      if ('' == $auto_toggle)
          $auto_toggle = 'N';
--- 474,479 ----
   */
  function get_autotoggle($id = 0) {
!     global $wpdb;
!     $auto_toggle = $wpdb->get_var("SELECT auto_toggle FROM $wpdb->linkcategories WHERE cat_id=$id");
      if ('' == $auto_toggle)
          $auto_toggle = 'N';
***************
*** 493,499 ****
  function links_popup_script($text = 'Links', $width=400, $height=400,
                              $file='links.all.php', $count = true) {
-    global $tablelinks;
     if ($count == true) {
!       $counts = $wpdb->get_var("SELECT count(*) FROM $tablelinks");
     }
  
--- 493,498 ----
  function links_popup_script($text = 'Links', $width=400, $height=400,
                              $file='links.all.php', $count = true) {
     if ($count == true) {
!       $counts = $wpdb->get_var("SELECT count(*) FROM $wpdb->links");
     }
  
***************
*** 519,523 ****
   *
   * Output a list of all links, listed by category, using the
!  * settings in $tablelinkcategories and output it as a nested
   * HTML unordered list.
   *
--- 518,522 ----
   *
   * Output a list of all links, listed by category, using the
!  * settings in $wpdb->linkcategories and output it as a nested
   * HTML unordered list.
   *
***************
*** 527,531 ****
   */
  function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
! 	global $tablelinkcategories, $tablelinks, $wpdb;
  
  	$order = strtolower($order);
--- 526,530 ----
   */
  function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
! 	global $wpdb;
  
  	$order = strtolower($order);
***************
*** 546,551 ****
  			show_description, show_rating, show_updated, sort_order, 
  			sort_desc, list_limit
! 		FROM `$tablelinks` 
! 		LEFT JOIN `$tablelinkcategories` ON (link_category = cat_id)
  		WHERE link_visible =  'Y'
  			AND list_limit <> 0
--- 545,550 ----
  			show_description, show_rating, show_updated, sort_order, 
  			sort_desc, list_limit
! 		FROM `$wpdb->links` 
! 		LEFT JOIN `$wpdb->linkcategories` ON (link_category = cat_id)
  		WHERE link_visible =  'Y'
  			AND list_limit <> 0

Index: template-functions-general.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/template-functions-general.php,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** template-functions-general.php	17 May 2004 20:46:15 -0000	1.29
--- template-functions-general.php	24 May 2004 08:22:18 -0000	1.30
***************
*** 92,96 ****
  
  function wp_title($sep = '&raquo;', $display = true) {
!     global $wpdb, $tableposts, $tablecategories;
      global $year, $monthnum, $day, $cat, $p, $name, $month, $posts, $single;
  
--- 92,96 ----
  
  function wp_title($sep = '&raquo;', $display = true) {
!     global $wpdb;
      global $year, $monthnum, $day, $cat, $p, $name, $month, $posts, $single;
  
***************
*** 102,106 ****
      }
      if (!empty($category_name)) {
!         $title = stripslashes($wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE category_nicename = '$category_name'"));
      }
  
--- 102,106 ----
      }
      if (!empty($category_name)) {
!         $title = stripslashes($wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE category_nicename = '$category_name'"));
      }
  
***************
*** 137,144 ****
  
  function single_post_title($prefix = '', $display = true) {
!     global $p, $name, $wpdb, $tableposts;
      if (intval($p) || '' != $name) {
          if (!$p) {
!             $p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name'");
          }
          $post_data = get_postdata($p);
--- 137,144 ----
  
  function single_post_title($prefix = '', $display = true) {
!     global $p, $name, $wpdb;
      if (intval($p) || '' != $name) {
          if (!$p) {
!             $p = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$name'");
          }
          $post_data = get_postdata($p);
***************
*** 203,207 ****
  
  function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
-     global $tableposts;
      global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb;
  
--- 203,206 ----
***************
*** 244,248 ****
  
      if ('monthly' == $type) {
!         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
          if ($arcresults) {
              $afterafter = $after;
--- 243,247 ----
  
      if ('monthly' == $type) {
!         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
          if ($arcresults) {
              $afterafter = $after;
***************
*** 259,263 ****
          }
      } elseif ('daily' == $type) {
!         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
          if ($arcresults) {
              foreach ($arcresults as $arcresult) {
--- 258,262 ----
          }
      } elseif ('daily' == $type) {
!         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
          if ($arcresults) {
              foreach ($arcresults as $arcresult) {
***************
*** 270,274 ****
      } elseif ('weekly' == $type) {
  	$start_of_week = get_settings('start_of_week');
!         $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
          $arc_w_last = '';
          if ($arcresults) {
--- 269,273 ----
      } elseif ('weekly' == $type) {
  	$start_of_week = get_settings('start_of_week');
!         $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
          $arc_w_last = '';
          if ($arcresults) {
***************
*** 289,293 ****
          }
      } elseif ('postbypost' == $type) {
!         $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
          if ($arcresults) {
              foreach ($arcresults as $arcresult) {
--- 288,292 ----
          }
      } elseif ('postbypost' == $type) {
!         $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
          if ($arcresults) {
              foreach ($arcresults as $arcresult) {
***************
*** 308,316 ****
  
  function get_calendar($daylength = 1) {
!     global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $tableposts, $posts;
  
      // Quick check. If we have no posts at all, abort!
      if (!$posts) {
!         $gotsome = $wpdb->get_var("SELECT ID from $tableposts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
          if (!$gotsome)
              return;
--- 307,315 ----
  
  function get_calendar($daylength = 1) {
!     global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts;
  
      // Quick check. If we have no posts at all, abort!
      if (!$posts) {
!         $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
          if (!$gotsome)
              return;
***************
*** 350,354 ****
      // Get the next and previous month and year with at least one post
      $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
!             FROM $tableposts
              WHERE post_date < '$thisyear-$thismonth-01'
              AND post_status = 'publish'
--- 349,353 ----
      // Get the next and previous month and year with at least one post
      $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
!             FROM $wpdb->posts
              WHERE post_date < '$thisyear-$thismonth-01'
              AND post_status = 'publish'
***************
*** 356,360 ****
                                LIMIT 1");
      $next = $wpdb->get_row("SELECT  DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
!             FROM $tableposts
              WHERE post_date >  '$thisyear-$thismonth-01'
              AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
--- 355,359 ----
                                LIMIT 1");
      $next = $wpdb->get_row("SELECT  DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
!             FROM $wpdb->posts
              WHERE post_date >  '$thisyear-$thismonth-01'
              AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
***************
*** 410,414 ****
      // Get days with posts
      $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
!             FROM $tableposts WHERE MONTH(post_date) = $thismonth
              AND YEAR(post_date) = $thisyear
              AND post_status = 'publish'
--- 409,413 ----
      // Get days with posts
      $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
!             FROM $wpdb->posts WHERE MONTH(post_date) = $thismonth
              AND YEAR(post_date) = $thisyear
              AND post_status = 'publish'
***************
*** 434,438 ****
      $ak_titles_for_day = array();
      $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
!                                          ."FROM $tableposts "
                                           ."WHERE YEAR(post_date) = '$thisyear' "
                                           ."AND MONTH(post_date) = '$thismonth' "
--- 433,437 ----
      $ak_titles_for_day = array();
      $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
!                                          ."FROM $wpdb->posts "
                                           ."WHERE YEAR(post_date) = '$thisyear' "
                                           ."AND MONTH(post_date) = '$thismonth' "

Index: template-functions-category.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/template-functions-category.php,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** template-functions-category.php	20 May 2004 14:07:55 -0000	1.28
--- template-functions-category.php	24 May 2004 08:22:18 -0000	1.29
***************
*** 2,6 ****
  
  function get_the_category() {
!     global $post, $tablecategories, $tablepost2cat, $wpdb, $category_cache;
      if ($category_cache[$post->ID]) {
          return $category_cache[$post->ID];
--- 2,6 ----
  
  function get_the_category() {
!     global $post, $wpdb, $category_cache;
      if ($category_cache[$post->ID]) {
          return $category_cache[$post->ID];
***************
*** 8,13 ****
          $categories = $wpdb->get_results("
              SELECT category_id, cat_name, category_nicename, category_description, category_parent
!             FROM  $tablecategories, $tablepost2cat
!             WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = $post->ID
              ");
      
--- 8,13 ----
          $categories = $wpdb->get_results("
              SELECT category_id, cat_name, category_nicename, category_description, category_parent
!             FROM  $wpdb->categories, $wpdb->post2cat
!             WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = $post->ID
              ");
      
***************
*** 17,21 ****
  
  function get_category_link($echo = false, $category_id, $category_nicename) {
!     global $wpdb, $tablecategories, $post, $querystring_start, $querystring_equal, $cache_categories;
      $cat_ID = $category_id;
      $permalink_structure = get_settings('permalink_structure');
--- 17,21 ----
  
  function get_category_link($echo = false, $category_id, $category_nicename) {
!     global $wpdb, $post, $querystring_start, $querystring_equal, $cache_categories;
      $cat_ID = $category_id;
      $permalink_structure = get_settings('permalink_structure');
***************
*** 124,130 ****
  
  function get_the_category_by_ID($cat_ID) {
!     global $tablecategories, $cache_categories, $wpdb;
      if ( !$cache_categories[$cat_ID] ) {
!         $cat_name = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'");
          $cache_categories[$cat_ID]->cat_name = $cat_name;
      } else {
--- 124,130 ----
  
  function get_the_category_by_ID($cat_ID) {
!     global $cache_categories, $wpdb;
      if ( !$cache_categories[$cat_ID] ) {
!         $cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE cat_ID = '$cat_ID'");
          $cache_categories[$cat_ID]->cat_name = $cat_name;
      } else {
***************
*** 135,140 ****
  
  function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
!     global $tablecategories, $cache_categories;
!     $chain = "";
      $parent = $cache_categories[$id];
      if ($nicename) {
--- 135,140 ----
  
  function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
!     global $cache_categories;
!     $chain = '';
      $parent = $cache_categories[$id];
      if ($nicename) {
***************
*** 153,157 ****
  
  function get_category_children($id, $before = '/', $after = '') {
!     global $tablecategories, $cache_categories;
      $c_cache = $cache_categories; // Can't do recursive foreach on a global, have to make a copy
      $chain = '';
--- 153,157 ----
  
  function get_category_children($id, $before = '/', $after = '') {
!     global $cache_categories;
      $c_cache = $cache_categories; // Can't do recursive foreach on a global, have to make a copy
      $chain = '';
***************
*** 185,189 ****
  
  function category_description($category = 0) {
!     global $cat, $wpdb, $tablecategories, $cache_categories;
      if (!$category) $category = $cat;
      $category_description = $cache_categories[$category]->category_description;
--- 185,189 ----
  
  function category_description($category = 0) {
!     global $cat, $wpdb, $cache_categories;
      if (!$category) $category = $cat;
      $category_description = $cache_categories[$category]->category_description;
***************
*** 196,200 ****
          $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE,
          $selected=0, $hide=0) {
!     global $tablecategories, $tableposts, $tablepost2cat, $wpdb;
      global $querystring_start, $querystring_equal, $querystring_separator;
      if (($file == 'blah') || ($file == '')) $file = get_settings('home') . '/' . get_settings('blogfilename');
--- 196,200 ----
          $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE,
          $selected=0, $hide=0) {
!     global $wpdb;
      global $querystring_start, $querystring_equal, $querystring_separator;
      if (($file == 'blah') || ($file == '')) $file = get_settings('home') . '/' . get_settings('blogfilename');
***************
*** 204,211 ****
      $query = "
          SELECT cat_ID, cat_name, category_nicename,category_parent,
!         COUNT($tablepost2cat.post_id) AS cat_count,
          DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth
!         FROM $tablecategories LEFT JOIN $tablepost2cat ON (cat_ID = category_id)
!         LEFT JOIN $tableposts ON (ID = post_id)
          WHERE cat_ID > 0
          ";
--- 204,211 ----
      $query = "
          SELECT cat_ID, cat_name, category_nicename,category_parent,
!         COUNT($wpdb->post2cat.post_id) AS cat_count,
          DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth
!         FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id)
!         LEFT JOIN $wpdb->posts ON (ID = post_id)
          WHERE cat_ID > 0
          ";
***************
*** 266,270 ****
  
  function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '') {
! 	global $tablecategories, $tableposts, $tablepost2cat, $wpdb, $category_posts;
  	global $querystring_start, $querystring_equal, $querystring_separator;
  	// Optiondates now works
--- 266,270 ----
  
  function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '') {
! 	global $wpdb, $category_posts;
  	global $querystring_start, $querystring_equal, $querystring_separator;
  	// Optiondates now works
***************
*** 288,292 ****
  		$query  = "
  			SELECT cat_ID, cat_name, category_nicename, category_description, category_parent
! 			FROM $tablecategories
  			WHERE cat_ID > 0 $exclusions
  			ORDER BY $sort_column $sort_order";
--- 288,292 ----
  		$query  = "
  			SELECT cat_ID, cat_name, category_nicename, category_description, category_parent
! 			FROM $wpdb->categories
  			WHERE cat_ID > 0 $exclusions
  			ORDER BY $sort_column $sort_order";
***************
*** 296,303 ****
  	if (!count($category_posts)) {
  		$cat_counts = $wpdb->get_results("	SELECT cat_ID,
! 		COUNT($tablepost2cat.post_id) AS cat_count
! 		FROM $tablecategories 
! 		INNER JOIN $tablepost2cat ON (cat_ID = category_id)
! 		INNER JOIN $tableposts ON (ID = post_id)
  		WHERE post_status = 'publish' $exclusions
  		GROUP BY category_id");
--- 296,303 ----
  	if (!count($category_posts)) {
  		$cat_counts = $wpdb->get_results("	SELECT cat_ID,
! 		COUNT($wpdb->post2cat.post_id) AS cat_count
! 		FROM $wpdb->categories 
! 		INNER JOIN $wpdb->post2cat ON (cat_ID = category_id)
! 		INNER JOIN $wpdb->posts ON (ID = post_id)
  		WHERE post_status = 'publish' $exclusions
  		GROUP BY category_id");
***************
*** 312,318 ****
  		$cat_dates = $wpdb->get_results("	SELECT cat_ID,
  		DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth
! 		FROM $tablecategories 
! 		LEFT JOIN $tablepost2cat ON (cat_ID = category_id)
! 		LEFT JOIN $tableposts ON (ID = post_id)
  		WHERE post_status = 'publish' $exclusions
  		GROUP BY category_id");
--- 312,318 ----
  		$cat_dates = $wpdb->get_results("	SELECT cat_ID,
  		DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth
! 		FROM $wpdb->categories 
! 		LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id)
! 		LEFT JOIN $wpdb->posts ON (ID = post_id)
  		WHERE post_status = 'publish' $exclusions
  		GROUP BY category_id");

Index: template-functions-author.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/template-functions-author.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** template-functions-author.php	28 Apr 2004 07:27:02 -0000	1.8
--- template-functions-author.php	24 May 2004 08:22:18 -0000	1.9
***************
*** 78,82 ****
  
  function get_author_link($echo = false, $author_id, $author_nicename) {
!     global $wpdb, $tableusers, $post, $querystring_start, $querystring_equal, $cache_userdata;
      $auth_ID = $author_id;
      $permalink_structure = get_settings('permalink_structure');
--- 78,82 ----
  
  function get_author_link($echo = false, $author_id, $author_nicename) {
!     global $wpdb, $post, $querystring_start, $querystring_equal, $cache_userdata;
      $auth_ID = $author_id;
      $permalink_structure = get_settings('permalink_structure');
***************
*** 127,133 ****
  
  function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
!     global $tableusers, $wpdb, $blogfilename;
  
!     $query = "SELECT ID, user_nickname, user_firstname, user_lastname, user_nicename from $tableusers " . ($exclude_admin ? "WHERE user_nickname <> 'admin' " : '') . "ORDER BY user_nickname";
      $authors = $wpdb->get_results($query);
  
--- 127,133 ----
  
  function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
!     global $wpdb, $blogfilename;
  
!     $query = "SELECT ID, user_nickname, user_firstname, user_lastname, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_nickname <> 'admin' " : '') . "ORDER BY user_nickname";
      $authors = $wpdb->get_results($query);
  

Index: template-functions-post.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/template-functions-post.php,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** template-functions-post.php	9 May 2004 23:26:41 -0000	1.22
--- template-functions-post.php	24 May 2004 08:22:18 -0000	1.23
***************
*** 276,280 ****
  
  function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
!     global $tableposts, $id, $post, $wpdb;
      global $p, $posts, $posts_per_page, $s, $single;
      global $querystring_start, $querystring_equal, $querystring_separator;
--- 276,280 ----
  
  function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
!     global $id, $post, $wpdb;
      global $p, $posts, $posts_per_page, $s, $single;
      global $querystring_start, $querystring_equal, $querystring_separator;
***************
*** 300,304 ****
  
          $limitprev--;
!         $lastpost = @$wpdb->get_row("SELECT ID, post_title FROM $tableposts WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev, 1");
          if ($lastpost) {
              $string = '<a href="'.get_permalink($lastpost->ID).'">'.$previous;
--- 300,304 ----
  
          $limitprev--;
!         $lastpost = @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev, 1");
          if ($lastpost) {
              $string = '<a href="'.get_permalink($lastpost->ID).'">'.$previous;
***************
*** 314,318 ****
  
  function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
!     global $tableposts, $posts_per_page, $post, $wpdb, $single;
      if(1 == $posts_per_page || 1 == $single) {
  
--- 314,318 ----
  
  function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
!     global $posts_per_page, $post, $wpdb, $single;
      if(1 == $posts_per_page || 1 == $single) {
  
***************
*** 338,342 ****
          $limitnext--;
  
!         $nextpost = @$wpdb->get_row("SELECT ID,post_title FROM $tableposts WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $sqlcat $sql_exclude_cats AND ID != $post->ID ORDER BY post_date ASC LIMIT $limitnext,1");
          if ($nextpost) {
              $string = '<a href="'.get_permalink($nextpost->ID).'">'.$next;
--- 338,342 ----
          $limitnext--;
  
!         $nextpost = @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $sqlcat $sql_exclude_cats AND ID != $post->ID ORDER BY post_date ASC LIMIT $limitnext,1");
          if ($nextpost) {
              $string = '<a href="'.get_permalink($nextpost->ID).'">'.$next;

Index: wp-db.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/wp-db.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** wp-db.php	1 May 2004 00:44:11 -0000	1.11
--- wp-db.php	24 May 2004 08:22:18 -0000	1.12
***************
*** 20,23 ****
--- 20,38 ----
  	var $col_info;
  
+ 	// Our tables
+ 	var $posts;
+ 	var $users;
+ 	var $categories;
+ 	var $post2cat;
+ 	var $comments;
+ 	var $links;
+ 	var $linkcategories;
+ 	var $options;
+ 	var $optiontypes;
+ 	var $optionvalues;
+ 	var $optiongroups;
+ 	var $optiongroup_options;
+ 	var $postmeta;
+ 
  	// ==================================================================
  	//	DB Constructor - connects to the server and selects a database

Index: functions-post.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/functions-post.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** functions-post.php	24 May 2004 01:34:57 -0000	1.1
--- functions-post.php	24 May 2004 08:22:18 -0000	1.2
***************
*** 7,11 ****
   */
  function wp_insert_post($postarr = array()) {
! 	global $wpdb, $tableposts, $post_default_category;
  	
  	// export array as variables
--- 7,11 ----
   */
  function wp_insert_post($postarr = array()) {
! 	global $wpdb, $post_default_category;
  	
  	// export array as variables
***************
*** 32,36 ****
  		$post_date_gmt = get_gmt_from_date($post_date);
  	
! 	$sql = "INSERT INTO $tableposts 
  		(post_author, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, post_title, post_excerpt, post_category, post_status, post_name) 
  		VALUES ('$post_author', '$post_date', '$post_date_gmt', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_cat', '$post_status', '$post_name')";
--- 32,36 ----
  		$post_date_gmt = get_gmt_from_date($post_date);
  	
! 	$sql = "INSERT INTO $wpdb->posts 
  		(post_author, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, post_title, post_excerpt, post_category, post_status, post_name) 
  		VALUES ('$post_author', '$post_date', '$post_date_gmt', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_cat', '$post_status', '$post_name')";
***************
*** 50,56 ****
  
  function wp_get_single_post($postid = 0, $mode = OBJECT) {
! 	global $wpdb, $tableposts;
  
! 	$sql = "SELECT * FROM $tableposts WHERE ID=$postid";
  	$result = $wpdb->get_row($sql, $mode);
  	
--- 50,56 ----
  
  function wp_get_single_post($postid = 0, $mode = OBJECT) {
! 	global $wpdb;
  
! 	$sql = "SELECT * FROM $wpdb->posts WHERE ID=$postid";
  	$result = $wpdb->get_row($sql, $mode);
  	
***************
*** 62,66 ****
  
  function wp_get_recent_posts($num = 10) {
! 	global $wpdb, $tableposts;
  
  	// Set the limit clause, if we got a limit
--- 62,66 ----
  
  function wp_get_recent_posts($num = 10) {
! 	global $wpdb;
  
  	// Set the limit clause, if we got a limit
***************
*** 69,73 ****
  	}
  
! 	$sql = "SELECT * FROM $tableposts ORDER BY post_date DESC $limit";
  	$result = $wpdb->get_results($sql,ARRAY_A);
  
--- 69,73 ----
  	}
  
! 	$sql = "SELECT * FROM $wpdb->posts ORDER BY post_date DESC $limit";
  	$result = $wpdb->get_results($sql,ARRAY_A);
  
***************
*** 76,80 ****
  
  function wp_update_post($postarr = array()) {
! 	global $wpdb, $tableposts;
  
  	// First get all of the original fields
--- 76,80 ----
  
  function wp_update_post($postarr = array()) {
! 	global $wpdb;
  
  	// First get all of the original fields
***************
*** 97,101 ****
  	$post_modified_gmt = current_time('mysql', 1);
  
! 	$sql = "UPDATE $tableposts 
  		SET post_content = '$post_content',
  		post_title = '$post_title',
--- 97,101 ----
  	$post_modified_gmt = current_time('mysql', 1);
  
! 	$sql = "UPDATE $wpdb->posts 
  		SET post_content = '$post_content',
  		post_title = '$post_title',
***************
*** 119,126 ****
  
  function wp_get_post_cats($blogid = '1', $post_ID = 0) {
! 	global $wpdb, $tablepost2cat;
  	
  	$sql = "SELECT category_id 
! 		FROM $tablepost2cat 
  		WHERE post_id = $post_ID 
  		ORDER BY category_id";
--- 119,126 ----
  
  function wp_get_post_cats($blogid = '1', $post_ID = 0) {
! 	global $wpdb;
  	
  	$sql = "SELECT category_id 
! 		FROM $wpdb->post2cat 
  		WHERE post_id = $post_ID 
  		ORDER BY category_id";
***************
*** 132,136 ****
  
  function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
! 	global $wpdb, $tablepost2cat;
  	// If $post_categories isn't already an array, make it one:
  	if (!is_array($post_categories)) {
--- 132,136 ----
  
  function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
! 	global $wpdb;
  	// If $post_categories isn't already an array, make it one:
  	if (!is_array($post_categories)) {
***************
*** 146,150 ****
  	$old_categories = $wpdb->get_col("
  		SELECT category_id 
! 		FROM $tablepost2cat 
  		WHERE post_id = $post_ID");
  	
--- 146,150 ----
  	$old_categories = $wpdb->get_col("
  		SELECT category_id 
! 		FROM $wpdb->post2cat 
  		WHERE post_id = $post_ID");
  	
***************
*** 169,173 ****
  		foreach ($delete_cats as $del) {
  			$wpdb->query("
! 				DELETE FROM $tablepost2cat 
  				WHERE category_id = $del 
  					AND post_id = $post_ID 
--- 169,173 ----
  		foreach ($delete_cats as $del) {
  			$wpdb->query("
! 				DELETE FROM $wpdb->post2cat 
  				WHERE category_id = $del 
  					AND post_id = $post_ID 
***************
*** 186,190 ****
  		foreach ($add_cats as $new_cat) {
  			$wpdb->query("
! 				INSERT INTO $tablepost2cat (post_id, category_id) 
  				VALUES ($post_ID, $new_cat)");
  
--- 186,190 ----
  		foreach ($add_cats as $new_cat) {
  			$wpdb->query("
! 				INSERT INTO $wpdb->post2cat (post_id, category_id) 
  				VALUES ($post_ID, $new_cat)");
  
***************
*** 195,204 ****
  
  function wp_delete_post($postid = 0) {
! 	global $wpdb, $tableposts, $tablepost2cat;
  	
! 	$sql = "DELETE FROM $tablepost2cat WHERE post_id = $postid";
  	$wpdb->query($sql);
  		
! 	$sql = "DELETE FROM $tableposts WHERE ID = $postid";
  	
  	$wpdb->query($sql);
--- 195,204 ----
  
  function wp_delete_post($postid = 0) {
! 	global $wpdb;
  	
! 	$sql = "DELETE FROM $wpdb->post2cat WHERE post_id = $postid";
  	$wpdb->query($sql);
  		
! 	$sql = "DELETE FROM $wpdb->posts WHERE ID = $postid";
  	
  	$wpdb->query($sql);
***************
*** 216,220 ****
  function post_permalink($post_ID=0, $mode = 'id') {
      global $wpdb;
- 	global $tableposts;
  	global $querystring_start, $querystring_equal, $querystring_separator;
  
--- 216,219 ----
***************
*** 266,273 ****
  // Get the name of a category from its ID
  function get_cat_name($cat_id) {
! 	global $wpdb,$tablecategories;
  	
  	$cat_id -= 0; 	// force numeric
! 	$name = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID=$cat_id");
  	
  	return $name;
--- 265,272 ----
  // Get the name of a category from its ID
  function get_cat_name($cat_id) {
! 	global $wpdb;
  	
  	$cat_id -= 0; 	// force numeric
! 	$name = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE cat_ID=$cat_id");
  	
  	return $name;
***************
*** 276,282 ****
  // Get the ID of a category from its name
  function get_cat_ID($cat_name='General') {
! 	global $wpdb,$tablecategories;
  	
! 	$cid = $wpdb->get_var("SELECT cat_ID FROM $tablecategories WHERE cat_name='$cat_name'");
  
  	return $cid?$cid:1;	// default to cat 1
--- 275,281 ----
  // Get the ID of a category from its name
  function get_cat_ID($cat_name='General') {
! 	global $wpdb;
  	
! 	$cid = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'");
  
  	return $cid?$cid:1;	// default to cat 1

Index: template-functions-comment.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/template-functions-comment.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** template-functions-comment.php	10 May 2004 07:51:50 -0000	1.20
--- template-functions-comment.php	24 May 2004 08:22:18 -0000	1.21
***************
*** 27,32 ****
  
  function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $number='') {
!     global $id, $comment, $tablecomments, $wpdb, $comment_count_cache;
!     if ('' == $comment_count_cache["$id"]) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'");
  	else $number = $comment_count_cache["$id"];
      if ($number == 0) {
--- 27,32 ----
  
  function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $number='') {
!     global $id, $comment, $wpdb, $comment_count_cache;
!     if ('' == $comment_count_cache["$id"]) $number = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1'");
  	else $number = $comment_count_cache["$id"];
      if ($number == 0) {
***************
*** 57,66 ****
  
  function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
!     global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb, $tablecomments, $cookiehash;
      global $querystring_start, $querystring_equal, $querystring_separator;
      global $comment_count_cache, $single;
  	if (!$single) {
      if ('' == $comment_count_cache["$id"]) {
!         $number = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1';");
      } else {
          $number = $comment_count_cache["$id"];
--- 57,66 ----
  
  function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
!     global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb, $cookiehash;
      global $querystring_start, $querystring_equal, $querystring_separator;
      global $comment_count_cache, $single;
  	if (!$single) {
      if ('' == $comment_count_cache["$id"]) {
!         $number = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';");
      } else {
          $number = $comment_count_cache["$id"];




More information about the cvs mailing list