Missing querycount

git-svn-id: https://develop.svn.wordpress.org/trunk@558 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mike Little
2003-11-25 00:46:52 +00:00
parent 6c8852bc51
commit 4efb6bb23a
27 changed files with 95 additions and 31 deletions

View File

@@ -478,7 +478,7 @@ function get_usernumposts($userid) {
// examine a url (supposedly from this blog) and try to
// determine the post ID it represents.
function url_to_postid($url = '') {
global $wpdb, $tableposts, $siteurl;
global $wpdb, $querycount, $tableposts, $siteurl;
// Take a link like 'http://example.com/blog/something'
// and extract just the '/something':
@@ -536,7 +536,8 @@ function url_to_postid($url = '') {
if ($postname) $where .= " AND post_name = '" . $wpdb->escape($postname) . "' ";
// Run the query to get the post ID:
return intval($wpdb->get_var("SELECT ID FROM $tableposts WHERE 1 = 1 " . $where));
++$querycount;
return intval($wpdb->get_var("SELECT ID FROM $tableposts WHERE 1 = 1 " . $where));
}
@@ -681,6 +682,7 @@ function dropdown_categories($blog_ID=1, $default=1) {
if ($postdata["Category"] != '') {
$default = $postdata["Category"];
}
++$querycount;
foreach($results as $post) {
echo "<option value=\"".$post->cat_ID."\"";
if ($post->cat_ID == $default)
@@ -1439,28 +1441,32 @@ function wp_set_comment_status($comment_id, $comment_status) {
a (boolean) false signals an error
*/
function wp_get_comment_status($comment_id) {
global $wpdb, $tablecomments;
global $wpdb, $querycount, $tablecomments;
$result = $wpdb->get_var("SELECT comment_approved FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1");
++$querycount;
if ($result == NULL) {
return "deleted";
return "deleted";
} else if ($result == "1") {
return "approved";
return "approved";
} else if ($result == "0") {
return "unapproved";
return "unapproved";
} else {
return false;
return false;
}
}
function wp_notify_postauthor($comment_id, $comment_type) {
global $wpdb, $tablecomments, $tableposts, $tableusers;
global $wpdb, $querycount, $tablecomments, $tableposts, $tableusers;
global $querystring_start, $querystring_equal, $querystring_separator;
global $blogfilename, $blogname, $siteurl;
$comment = $wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1");
++$querycount;
$post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID='$comment->comment_post_ID' LIMIT 1");
++$querycount;
$user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID='$post->post_author' LIMIT 1");
++$querycount;
if ('' == $user->user_email) return false; // If there's no email to send the comment to
@@ -1511,16 +1517,20 @@ function wp_notify_postauthor($comment_id, $comment_type) {
always returns true
*/
function wp_notify_moderator($comment_id) {
global $wpdb, $tablecomments, $tableposts, $tableusers;
global $wpdb, $querycount, $tablecomments, $tableposts, $tableusers;
global $querystring_start, $querystring_equal, $querystring_separator;
global $blogfilename, $blogname, $siteurl;
$comment = $wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1");
++$querycount;
$post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID='$comment->comment_post_ID' LIMIT 1");
++$querycount;
$user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID='$post->post_author' LIMIT 1");
++$querycount;
$comment_author_domain = gethostbyaddr($comment->comment_author_IP);
$comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $tablecomments WHERE comment_approved = '0'");
++$querycount;
$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";
$notify_message .= "Author : $comment->comment_author (IP: $comment->comment_author_IP , $comment_author_domain)\r\n";

View File

@@ -232,11 +232,12 @@ function get_archives($type='', $limit='', $format='html', $before = "", $after
}
function get_calendar($daylength = 1) {
global $wpdb, $HTTP_GET_VARS, $m, $monthnum, $year, $timedifference, $month, $weekday, $tableposts, $posts;
global $wpdb, $HTTP_GET_VARS, $m, $monthnum, $year, $timedifference, $month, $weekday, $tableposts, $posts, $querycount;
// Quick check. If we have no posts at all, abort!
if (!$posts) {
$gotsome = $wpdb->get_var("SELECT ID from $tableposts WHERE post_status = 'publish' AND post_category > 0 ORDER BY post_date DESC LIMIT 1");
++$querycount;
if (!$gotsome)
return;
}
@@ -253,6 +254,7 @@ function get_calendar($daylength = 1) {
$thisyear = ''.intval(substr($m, 0, 4));
$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
++$querycount;
} elseif (!empty($m)) {
$calendar = substr($m, 0, 6);
$thisyear = ''.intval(substr($m, 0, 4));
@@ -275,6 +277,7 @@ function get_calendar($daylength = 1) {
AND post_status = 'publish'
ORDER BY post_date DESC
LIMIT 1");
++$querycount;
$next = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year
FROM $tableposts
WHERE post_date > '$thisyear-$thismonth-01'
@@ -282,6 +285,7 @@ function get_calendar($daylength = 1) {
AND post_status = 'publish'
ORDER BY post_date ASC
LIMIT 1");
++$querycount;
echo '<table id="wp-calendar">
<caption>' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption>
@@ -329,7 +333,7 @@ function get_calendar($daylength = 1) {
AND YEAR(post_date) = $thisyear
AND post_status = 'publish'
AND post_date < '" . date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."'", ARRAY_N);
++$querycount;
if ($dayswithposts) {
foreach ($dayswithposts as $daywith) {
$daywithpost[] = $daywith[0];
@@ -355,6 +359,7 @@ function get_calendar($daylength = 1) {
."AND post_date < '".date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."' "
."AND post_status = 'publish'"
);
++$querycount;
if ($ak_post_titles) {
foreach ($ak_post_titles as $ak_post_title) {
if (empty($ak_titles_for_day["$ak_post_title->dom"])) { // first one
@@ -405,7 +410,8 @@ function get_calendar($daylength = 1) {
/***** Links *****/
function get_permalink($id=false) {
global $post, $wpdb, $tableposts;
global $siteurl, $blogfilename, $querystring_start, $querystring_equal;
global $siteurl, $blogfilename, $querystring_start, $querystring_equal, $querycount;
$rewritecode = array(
'%year%',
'%monthnum%',
@@ -427,6 +433,7 @@ function get_permalink($id=false) {
}
} else { // if an ID is given
$idpost = $wpdb->get_row("SELECT post_date, post_name FROM $tableposts WHERE ID = $id");
++$querycount;
if ('' != get_settings('permalink_structure')) {
$unixtime = strtotime($idpost->post_date);
$rewritereplace = array(
@@ -1350,7 +1357,7 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
$query .= " ORDER BY $sort_column $sort_order, post_date DESC";
$categories = $wpdb->get_results($query);
++$querycount;
if (!$categories) {
if ($list) {
$before = '<li>';
@@ -1359,7 +1366,6 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
echo $before . "No categories" . $after . "\n";
return;
}
++$querycount;
if (intval($optionall) == 1) {
$all = apply_filters('list_cats', $all);
$link = "<a href=\"".$file.$querystring_start.'cat'.$querystring_equal.'all">'.$all."</a>";
@@ -1405,11 +1411,12 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $include_unapproved = false) {
global $id, $comment, $tablecomments, $querycount, $wpdb;
$query = "SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = '$id'";
$query = "SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id";
if (false == $include_unapproved) {
$query .= " AND comment_approved = '1'";
}
$number = $wpdb->get_var($query);
++$querycount;
if ($number == 0) {
$blah = $zero;
} elseif ($number == 1) {
@@ -1438,9 +1445,10 @@ function comments_popup_script($width=400, $height=400, $file='b2commentspopup.p
}
function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
global $id, $b2commentspopupfile, $b2commentsjavascript, $post, $wpdb, $tablecomments, $HTTP_COOKIE_VARS, $cookiehash;
global $id, $b2commentspopupfile, $b2commentsjavascript, $post, $wpdb, $querycount, $tablecomments, $HTTP_COOKIE_VARS, $cookiehash;
global $querystring_start, $querystring_equal, $querystring_separator, $siteurl;
$number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'");
++$querycount;
if (0 == $number && 'closed' == $post->comment_status) {
echo $none;
return;