Make WordPress Core

Changeset 558


Ignore:
Timestamp:
11/25/2003 12:46:52 AM (20 years ago)
Author:
mikelittle
Message:

Missing querycount

Location:
trunk
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/b2-include/b2functions.php

    r555 r558  
    479479// determine the post ID it represents.
    480480function url_to_postid($url = '') {
    481     global $wpdb, $tableposts, $siteurl;
     481    global $wpdb, $querycount, $tableposts, $siteurl;
    482482
    483483    // Take a link like 'http://example.com/blog/something'
     
    537537
    538538    // Run the query to get the post ID:
    539     return intval($wpdb->get_var("SELECT ID FROM $tableposts WHERE 1 = 1 " . $where));
     539    ++$querycount;
     540    return intval($wpdb->get_var("SELECT ID FROM $tableposts WHERE 1 = 1 " . $where));
    540541}
    541542
     
    682683        $default = $postdata["Category"];
    683684    }
     685    ++$querycount;
    684686    foreach($results as $post) {
    685687        echo "<option value=\"".$post->cat_ID."\"";
     
    14401442 */
    14411443function wp_get_comment_status($comment_id) {
    1442     global $wpdb, $tablecomments;
     1444    global $wpdb, $querycount, $tablecomments;
    14431445   
    14441446    $result = $wpdb->get_var("SELECT comment_approved FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1");
     1447    ++$querycount;
    14451448    if ($result == NULL) {
    1446     return "deleted";
     1449        return "deleted";
    14471450    } else if ($result == "1") {
    1448     return "approved";
     1451        return "approved";
    14491452    } else if ($result == "0") {
    1450     return "unapproved";
     1453        return "unapproved";
    14511454    } else {
    1452     return false;
     1455        return false;
    14531456    }
    14541457}
    14551458
    14561459function wp_notify_postauthor($comment_id, $comment_type) {
    1457     global $wpdb, $tablecomments, $tableposts, $tableusers;
     1460    global $wpdb, $querycount, $tablecomments, $tableposts, $tableusers;
    14581461    global $querystring_start, $querystring_equal, $querystring_separator;
    14591462    global $blogfilename, $blogname, $siteurl;
    14601463   
    14611464    $comment = $wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1");
     1465    ++$querycount;
    14621466    $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID='$comment->comment_post_ID' LIMIT 1");
     1467    ++$querycount;
    14631468    $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID='$post->post_author' LIMIT 1");
     1469    ++$querycount;
    14641470
    14651471    if ('' == $user->user_email) return false; // If there's no email to send the comment to
     
    15121518 */
    15131519function wp_notify_moderator($comment_id) {
    1514     global $wpdb, $tablecomments, $tableposts, $tableusers;
     1520    global $wpdb, $querycount, $tablecomments, $tableposts, $tableusers;
    15151521    global $querystring_start, $querystring_equal, $querystring_separator;
    15161522    global $blogfilename, $blogname, $siteurl;
    15171523   
    15181524    $comment = $wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1");
     1525    ++$querycount;
    15191526    $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID='$comment->comment_post_ID' LIMIT 1");
     1527    ++$querycount;
    15201528    $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID='$post->post_author' LIMIT 1");
     1529    ++$querycount;
    15211530
    15221531    $comment_author_domain = gethostbyaddr($comment->comment_author_IP);
    15231532    $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $tablecomments WHERE comment_approved = '0'");
     1533    ++$querycount;
    15241534
    15251535    $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";
  • trunk/b2-include/b2template.functions.php

    r557 r558  
    233233
    234234function get_calendar($daylength = 1) {
    235     global $wpdb, $HTTP_GET_VARS, $m, $monthnum, $year, $timedifference, $month, $weekday, $tableposts, $posts;
     235    global $wpdb, $HTTP_GET_VARS, $m, $monthnum, $year, $timedifference, $month, $weekday, $tableposts, $posts, $querycount;
    236236
    237237    // Quick check. If we have no posts at all, abort!
    238238    if (!$posts) {
    239239        $gotsome = $wpdb->get_var("SELECT ID from $tableposts WHERE post_status = 'publish' AND post_category > 0 ORDER BY post_date DESC LIMIT 1");
     240        ++$querycount;
    240241        if (!$gotsome)
    241242            return;
     
    254255        $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
    255256        $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
     257        ++$querycount;
    256258    } elseif (!empty($m)) {
    257259        $calendar = substr($m, 0, 6);
     
    276278                              ORDER BY post_date DESC
    277279                              LIMIT 1");
     280    ++$querycount;
    278281    $next = $wpdb->get_row("SELECT  DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year
    279282            FROM $tableposts
     
    283286                              ORDER  BY post_date ASC
    284287                              LIMIT 1");
     288    ++$querycount;
    285289
    286290    echo '<table id="wp-calendar">
     
    330334            AND post_status = 'publish'
    331335            AND post_date < '" . date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."'", ARRAY_N);
    332 
     336    ++$querycount;
    333337    if ($dayswithposts) {
    334338        foreach ($dayswithposts as $daywith) {
     
    356360                                         ."AND post_status = 'publish'"
    357361                                        );
     362    ++$querycount;
    358363    if ($ak_post_titles) {
    359364        foreach ($ak_post_titles as $ak_post_title) {
     
    406411function get_permalink($id=false) {
    407412    global $post, $wpdb, $tableposts;
    408     global $siteurl, $blogfilename, $querystring_start, $querystring_equal;
     413    global $siteurl, $blogfilename, $querystring_start, $querystring_equal, $querycount;
     414
    409415    $rewritecode = array(
    410416        '%year%',
     
    428434    } else { // if an ID is given
    429435        $idpost = $wpdb->get_row("SELECT post_date, post_name FROM $tableposts WHERE ID = $id");
     436        ++$querycount;
    430437        if ('' != get_settings('permalink_structure')) {
    431438            $unixtime = strtotime($idpost->post_date);
     
    13511358
    13521359    $categories = $wpdb->get_results($query);
    1353 
     1360    ++$querycount;
    13541361    if (!$categories) {
    13551362        if ($list) {
     
    13601367        return;
    13611368    }
    1362     ++$querycount;
    13631369    if (intval($optionall) == 1) {
    13641370        $all = apply_filters('list_cats', $all);
     
    14061412function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $include_unapproved = false) {
    14071413    global $id, $comment, $tablecomments, $querycount, $wpdb;
    1408     $query = "SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = '$id'";
     1414    $query = "SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id";
    14091415    if (false == $include_unapproved) {
    14101416        $query .= " AND comment_approved = '1'";
    14111417    }
    14121418    $number = $wpdb->get_var($query);
     1419    ++$querycount;
    14131420    if ($number == 0) {
    14141421        $blah = $zero;
     
    14391446
    14401447function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
    1441     global $id, $b2commentspopupfile, $b2commentsjavascript, $post, $wpdb, $tablecomments, $HTTP_COOKIE_VARS, $cookiehash;
     1448    global $id, $b2commentspopupfile, $b2commentsjavascript, $post, $wpdb, $querycount, $tablecomments, $HTTP_COOKIE_VARS, $cookiehash;
    14421449    global $querystring_start, $querystring_equal, $querystring_separator, $siteurl;
    14431450    $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'");
     1451    ++$querycount;
    14441452    if (0 == $number && 'closed' == $post->comment_status) {
    14451453        echo $none;
  • trunk/b2comments.php

    r549 r558  
    1616
    1717        $comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1' ORDER BY comment_date");
     18        ++$querycount;
    1819?>
    1920
  • trunk/b2comments.post.php

    r555 r558  
    4040
    4141$commentstatus = $wpdb->get_var("SELECT comment_status FROM $tableposts WHERE ID = $comment_post_ID");
    42 
     42++$querycount;
    4343if ('closed' == $commentstatus)
    4444    die('Sorry, comments are closed for this item.');
     
    6969/* Flood-protection */
    7070$lasttime = $wpdb->get_var("SELECT comment_date FROM $tablecomments WHERE comment_author_IP = '$user_ip' ORDER BY comment_date DESC LIMIT 1");
     71++$querycount;
    7172$ok = true;
    7273if (!empty($lasttime)) {
     
    101102
    102103    $comment_ID = $wpdb->get_var('SELECT last_insert_id()');
     104    ++$querycount;
    103105
    104106    if (($moderation_notify) && (!$approved)) {
  • trunk/b2commentspopup.php

    r549 r558  
    3131// this line is WordPress' motor, do not delete it.
    3232$comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1' ORDER BY comment_date");
     33++$querycount;
    3334$commentstatus = $wpdb->get_row("SELECT comment_status, post_password FROM $tableposts WHERE ID = $id");
     35++$querycount;
    3436if (!empty($commentstatus->post_password) && $HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $commentstatus->post_password) {  // and it doesn't match the cookie
    3537    echo(get_the_password_form());
  • trunk/b2login.php

    r546 r558  
    6767        $redirect_to = $HTTP_POST_VARS["redirect_to"];
    6868    }
    69    
     69
    7070    function login() {
    7171        global $wpdb, $log, $pwd, $error, $user_ID;
     
    8787            $password = substr($password, 4, strlen($password));
    8888            $query = "SELECT ID, user_login, user_pass FROM $tableusers WHERE user_login = '$user_login' AND MD5(user_pass) = '$password'";
     89            ++$querycount;
    8990        } else {
    9091            $pass_is_md5 = 0;
    9192            $query = "SELECT ID, user_login, user_pass FROM $tableusers WHERE user_login = '$user_login' AND user_pass = '$password'";
     93            ++$querycount;
    9294        }
    9395        $login = $wpdb->get_row($query);
  • trunk/b2mail.php

    r294 r558  
    205205        $sql = "SELECT ID, user_level FROM $tableusers WHERE user_login='$user_login' AND user_pass='$user_pass' ORDER BY ID DESC LIMIT 1";
    206206        $result = $wpdb->get_row($sql);
     207        ++$querycount;
    207208
    208209        if (!$result) {
  • trunk/b2register.php

    r368 r558  
    8181    /* checking the login isn't already used by another user */
    8282    $result = $wpdb->get_results("SELECT user_login FROM $tableusers WHERE user_login = '$user_login'");
    83     if (count($result) >= 1) {
     83    ++$querycount;
     84    if (count($result) >= 1) {
    8485        die ('<strong>ERROR</strong>: This login is already registered, please choose another one.');
    8586    }
  • trunk/b2trackback.php

    r555 r558  
    3232
    3333    $pingstatus = $wpdb->get_var("SELECT ping_status FROM $tableposts WHERE ID = $tb_id");
     34    ++$querycount;
    3435
    3536    if ('closed' == $pingstatus)
     
    8788    } else {
    8889        $comment_ID = $wpdb->get_var('SELECT last_insert_id()');
     90        ++$querycount;
    8991        if ($comments_notify)
    9092            wp_notify_postauthor($comment_ID, 'trackback');
  • trunk/blog.header.php

    r554 r558  
    305305// echo $request;
    306306$posts = $wpdb->get_results($request);
    307 
     307++$querycount;
    308308if (1 == count($posts)) {
    309309    if ($p || $name) {
  • trunk/wp-admin/b2team.php

    r222 r558  
    104104    <?php
    105105    $users = $wpdb->get_results("SELECT ID FROM $tableusers WHERE user_level>0 ORDER BY ID");
     106    ++$querycount;
    106107    foreach ($users as $user) {
    107108        $user_data = get_userdata($user->ID);
     
    139140<?php
    140141    $users = $wpdb->get_results("SELECT * FROM $tableusers WHERE user_level=0 ORDER BY ID");
     142    ++$querycount;
    141143    if ($users) {
    142144?>
  • trunk/wp-admin/b2verifauth.php

    r546 r558  
    66function veriflog() {
    77    global $HTTP_COOKIE_VARS,$cookiehash;
    8     global $tableusers, $wpdb;
     8    global $tableusers, $wpdb, $querycount;
    99
    1010    if (!empty($HTTP_COOKIE_VARS["wordpressuser_".$cookiehash])) {
     
    2121
    2222    $login = $wpdb->get_row("SELECT user_login, user_pass FROM $tableusers WHERE user_login = '$user_login'");
     23    ++$querycount;
    2324
    2425    if (!$login) {
  • trunk/wp-admin/edit-comments.php

    r552 r558  
    137137                                    LIMIT $commentstart, $commentend"
    138138                                  );
     139    ++$querycount;
    139140
    140141// need to account for offet, etc.
  • trunk/wp-admin/edit.php

    r556 r558  
    269269
    270270                    $comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = $id ORDER BY comment_date");
     271                    ++$querycount;
    271272                    if ($comments) {
    272273                    ?>
  • trunk/wp-admin/import-b2.php

    r513 r558  
    140140    $query = "SELECT link_updated FROM $tablelinks LIMIT 1";
    141141    $q = @mysql_query($query);
     142    ++$querycount;
    142143    if ($q != false) {
    143144        if ($row = mysql_fetch_object($q)) {
     
    151152    echo "<p>Looking for column link_rel...</p>\n";
    152153    $query = "SELECT link_rel FROM $tablelinks LIMIT 1";
     154    ++$querycount;
    153155    $q = @mysql_query($query);
    154156    if ($q != false) {
     
    167169    echo "<p>Looking for category 1...</p>\n";
    168170    $sql = "SELECT * FROM $tablelinkcategories WHERE cat_id=1 ";
     171    ++$querycount;
    169172    $result = mysql_query($sql) or print ("Can't query '$tablelinkcategories'.<br />" . $sql . "<br />" . mysql_error());
    170173    if ($result != false) {
  • trunk/wp-admin/import-blogger.php

    r430 r558  
    7070            // we'll check the author is registered already
    7171            $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE user_login = '$post_author'");
     72            ++$querycount;
    7273            if (!$user) { // seems s/he's not, so let's register
    7374                $user_ip = '127.0.0.1';
     
    112113
    113114            $post_author_ID = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_login = '$post_author'");
     115            ++$querycount;
    114116
    115117            $post_date = explode(' ', $post_date);
     
    135137            // Quick-n-dirty check for dups:
    136138            $dupcheck = $wpdb->get_results("SELECT ID,post_date,post_title FROM $tableposts WHERE post_date='$post_date' AND post_title='$post_title' LIMIT 1",ARRAY_A);
     139            ++$querycount;
    137140            if ($dupcheck[0]['ID']) {
    138141                print "<br />\nSkipping duplicate post, ID = '" . $dupcheck[0]['ID'] . "'<br />\n";
  • trunk/wp-admin/import-greymatter.php

    r503 r558  
    140140            $sql = "SELECT * FROM $tableusers WHERE user_login = '$post_author'";
    141141            $result = mysql_query($sql);
     142            ++$querycount;
    142143            if (!mysql_num_rows($result)) { // if deleted from GM, we register the author as a level 0 user in b2
    143144                $user_ip="127.0.0.1";
     
    160161
    161162            $sql = "SELECT * FROM $tableusers WHERE user_login = '$post_author'";
     163            ++$querycount;
    162164            $result = mysql_query($sql);
    163165            $myrow = mysql_fetch_array($result);
     
    196198           
    197199            $sql2 = "SELECT * FROM $tableposts WHERE 1=1 ORDER BY ID DESC LIMIT 1";
     200            ++$querycount;
    198201            $result2 = mysql_query($sql2);
    199202            $myrow2 = mysql_fetch_array($result2);
  • trunk/wp-admin/import-textpattern.php

    r529 r558  
    8181// For now we're going to give everything the same author and same category
    8282$author = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_level = 10 LIMIT 1");
     83++$querycount;
    8384$category = $wpdb->get_var("SELECT cat_ID FROM $tablecategories LIMIT 1");
     85++$querycount;
    8486
    8587$posts = mysql_query('SELECT * FROM textpattern', $connection);
     88++$querycount;
    8689
    8790while ($post = mysql_fetch_array($posts)) {
     
    109112    // Get wordpress post id
    110113    $wp_post_ID = $wpdb->get_var("SELECT ID FROM $tableposts ORDER BY ID DESC LIMIT 1");
     114    ++$querycount;
    111115   
    112116    // Now let's insert comments if there are any for the TP post
    113117    $tp_id = $post['ID'];
    114118    $comments = mysql_query("SELECT * FROM txp_Discuss WHERE parentid = $tp_id");
     119    ++$querycount;
    115120    if ($comments) {
    116121        while($comment = mysql_fetch_object($comments)) {
  • trunk/wp-admin/linkcategories.php

    r438 r558  
    135135         . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
    136136         . " text_after_all, list_limit FROM $tablelinkcategories WHERE cat_id=$cat_id");
     137    ++$querycount;
    137138    if ($row) {
    138139        if ($row->list_limit == -1) {
     
    325326         . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
    326327         . " text_after_all, list_limit FROM $tablelinkcategories ORDER BY cat_id");
    327     foreach ($results as $row) {
    328         if ($row->list_limit == -1) {
    329             $row->list_limit = 'none';
    330         }
    331         $style = ($i % 2) ? ' class="alternate"' : '';
     328++$querycount;
     329foreach ($results as $row) {
     330    if ($row->list_limit == -1) {
     331        $row->list_limit = 'none';
     332    }
     333    $style = ($i % 2) ? ' class="alternate"' : '';
    332334?>
    333335              <tr valign="middle" <?php echo $style ?>>
  • trunk/wp-admin/linkmanager.php

    r526 r558  
    3434
    3535function category_dropdown($fieldname, $selected = 0) {
    36     global $wpdb, $tablelinkcategories;
     36    global $wpdb, $querycount, $tablelinkcategories;
    3737
    3838    $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
     39    ++$querycount;
    3940    echo '        <select name="'.$fieldname.'" size="1">'."\n";
    4041    foreach ($results as $row) {
     
    110111    $all_links = join(',', $linkcheck);
    111112    $results = $wpdb->get_results("SELECT link_id, link_owner, user_level FROM $tablelinks LEFT JOIN $tableusers ON link_owner = ID WHERE link_id in ($all_links)");
     113    ++$querycount;
    112114    foreach ($results as $row) {
    113115      if (!get_settings('links_use_adminlevels') || ($user_level >= $row->user_level)) { // ok to proceed
     
    139141    $all_links = join(',', $linkcheck);
    140142    $results = $wpdb->get_results("SELECT link_id, link_visible FROM $tablelinks WHERE link_id in ($all_links)");
     143    ++$querycount;
    141144    foreach ($results as $row) {
    142145        if ($row->link_visible == 'Y') { // ok to proceed
     
    305308      " FROM $tablelinks " .
    306309      " WHERE link_id = $link_id");
     310    ++$querycount;
    307311
    308312    if ($row) {
     
    499503<?php
    500504    $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
     505    ++$querycount;
    501506    echo "        <select name=\"cat_id\">\n";
    502507    echo "          <option value=\"All\"";
     
    561566            LEFT JOIN $tablelinkcategories ON $tablelinks.link_category = $tablelinkcategories.cat_id
    562567            LEFT JOIN $tableusers ON $tableusers.ID = $tablelinks.link_owner ";
     568    ++$querycount;
    563569
    564570    if (isset($cat_id) && ($cat_id != 'All')) {
     
    631637<?php
    632638    $results = $wpdb->get_results("SELECT ID, user_login FROM $tableusers WHERE user_level > 0 ORDER BY ID");
     639    ++$querycount;
    633640    echo "          <select name=\"newowner\" size=\"1\">\n";
    634641    foreach ($results as $row) {
  • trunk/wp-admin/links.import.php

    r504 r558  
    7474<?php
    7575    $categories = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
     76    ++$querycount;
    7677    foreach ($categories as $category) {
    7778?>
  • trunk/wp-admin/optionhandler.php

    r294 r558  
    5151                                         ."WHERE option_id = $option_result->option_id "
    5252                                         ."ORDER BY optionvalue_seq");
     53            ++$querycount;
    5354            if ($select) {
    5455                foreach($select as $option) {
     
    6869            // first get the sql to run
    6970            $sql = $wpdb->get_var("SELECT optionvalue FROM $tableoptionvalues WHERE option_id = $option_result->option_id");
     71            ++$querycount;
    7072            if (!$sql) {
    7173                return $option_result->option_name . $editable;
  • trunk/wp-admin/wp-edit.showposts.php

    r546 r558  
    272272
    273273                    $comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = $id ORDER BY comment_date");
     274                    ++$querycount;
    274275                    if ($comments) {
    275276                    ?>
  • trunk/wp-commentsrss2.php

    r546 r558  
    6060                                            ORDER BY comment_date
    6161                                            LIMIT $posts_per_rss");
     62            ++$querycount;
    6263        }
    6364        else { // if no post id passed in, we'll just ue the last 10 comments.
     
    7980                                            ORDER BY comment_date DESC
    8081                                            LIMIT $posts_per_rss");
     82            ++$querycount;
    8183        }
    8284    // this line is WordPress' motor, do not delete it.
  • trunk/wp-rdf.php

    r535 r558  
    1212
    1313$maxdate = $wpdb->get_var($sql);
    14 
     14++$querycount;
    1515$unixtime = strtotime($maxdate);
    1616
  • trunk/wp-rss.php

    r535 r558  
    1212
    1313$maxdate = $wpdb->get_var($sql);
    14 
     14++$querycount;
    1515$unixtime = strtotime($maxdate);
    1616
  • trunk/wp-rss2.php

    r533 r558  
    1212
    1313$maxdate = $wpdb->get_var($sql);
     14++$querycount;
    1415
    1516$unixtime = strtotime($maxdate);
Note: See TracChangeset for help on using the changeset viewer.