Search Results for 'code'
-
AuthorSearch Results
-
July 21, 2007 at 2:33 pm #59336
In reply to: performance idea, preloading general options
_ck_
Participanter, omg, tracing the code I think the option has already been written into bbpress and just not documented?
$bb->load_options = true
put into config.php ?
can it be that easy? does it work or not ready for primetime?
July 21, 2007 at 2:26 pm #2146Topic: performance idea, preloading general options
in forum Troubleshooting_ck_
ParticipantI’ll probably copy this to TRAC but it’s good for a discussion here too?
I’ve been poking around the results using the query list plugin and something hit me.
Options are not being preloaded (ie. SELECT meta_value FROM $bbdb->topicmeta WHERE topic_id = 0)
However a few options, like active plugins MUST be loaded on every load. So the options table has to be queried at least once, usually two or three times. This causes extra queries.
So the question is, what’s slower, unserializing possibly serialized data in half a dozen to a dozen options, or making half a dozen to a dozen extra mysql queries?
Preloading could be a plugin, the cache code is already there. Just wondering if I should bother working on it given the above question.
fel64
MemberYup. Add
global $bb_cache;to bbpress’ config.php.July 21, 2007 at 4:13 am #59297In reply to: front page takes 50 mysql queries
_ck_
ParticipantActually he can’t really “fix” the plugin, it’s an overall integration failure which necessarily adds more mysql queries (just like the plugin needed to allow spaces adds more overhead).
Basically the output template will HAVE to use a difference function call than the “use display name” which fixes it everywhere else before it’s written back to the database.
It’s the cost of integration and yet another example of why bbpress isn’t magically better than any other forum for integration with wordpress.
(or just use my workaround to cut out the extra queries

ps. “mdawaffle” wasn’t a “dig” – isn’t that his nickname?
July 20, 2007 at 11:11 pm #2143sam_a
MemberI know the emails have to come from somewhere, but still… this was surprise.
Could there be a notice somewhere that the admin email is used to send every registration notification? Spambots are getting it too

I had expected that bbPress would use it only to send notifications to the admin.
July 20, 2007 at 6:12 pm #59310In reply to: Noobish CSS Question
Andrew
MemberThanks. Someone else contacted me with another fix.
add this
<div style=”clear:both;”></div>
just before the end of wrapper div.. before this
</div>
<div
id=”footer”>
<p>Nyquist Forums is proudly powered by <a
href=”http://bbpress.org”>bbPress.</p
>
</div>
There are more topics but they are private.
July 20, 2007 at 5:16 pm #2140Topic: ‘Are you sure you want to submit this post?’
in forum Troubleshootingtisme
Memberwhat are possible reasons/conditions of getting this nonce message?
I gathered it could be issued by the
bb_check_admin_referer( 'create-post_' . $topic_id );but what is it for?PS I saw there’s a similar title resolved thread, but it doesn’t make it clear.
July 20, 2007 at 5:06 pm #59291In reply to: front page takes 50 mysql queries
_ck_
ParticipantNo, all those are properly cached and do not reduce mysql queries.
topic_last_poster() for some reason forces a new metadata reload and two new mysql queries, uncached. It’s meant to be able to be used outside loops so it basically has to. It can’t just peek at the entire topics table just returned from the database.
Any plugin that affects the username has already affected it on the write to the topics table. It’s already set for presentation. No need to hook it unless you are doing something really crazy. Even the “admin use display names” plugin will still work correctly.
It’s the only really easy optimization.
“topic_last_poster()” sticks out badly if you install the plugin I posted above and look at the results.
update: if you are really worried about filters you can either have a lightweight pseudo function or do it this way
echo apply_filters( 'topic_last_poster', $topic->topic_last_poster_name, $topic->topic_last_poster);instead of just
echo $topic->topic_last_poster_name;and that will apply any filters looking for it
July 20, 2007 at 3:53 pm #59289In reply to: front page takes 50 mysql queries
_ck_
ParticipantOMG. This is insane.
Go edit your front-page.php, forum.php and view.php templates.
Change
topic_last_poster();to
echo $topic->topic_last_poster_name;Cuts mysql queries in half. I went from 50 to under 20.
The data is already in the retrieved topics in memory, there’s no need to reload all the userdata.
July 20, 2007 at 3:21 pm #59309In reply to: Noobish CSS Question
fel64
MemberThere’s no direct solution. You can do one of these:
- Change
<?php tag_heat_map(); ?>to<?php tag_heat_map('limit=30'); ?>. The default limit is 40 I think, if you set it to 30 or any appropriate number they won’t go so far down. But you’d want to change that again later. - Put the
footerinside thewrapper. I’m not sure how your templates are arranged, but in kakumei you’d just have to openfooter.phpand move the codeblock that produces the divfooterup a few lines, just above the previous</div>. Permanent change, now the footer is on the white, but the white will always stretch down sufficiently. - Wait it out – eventually there’ll be enough topics to stretch the page

I think there are a few other things you could do, but that second point is probably the best if you need it changed now.
July 20, 2007 at 2:15 pm #59228In reply to: Plugin: Plugin browser for bbPress
so1o
Participanti dont see any plugins in the list either.. i dont have any other plugin except this one..
am i doing something wrong!
July 20, 2007 at 2:12 pm #59260In reply to: let’s build a poll plugin!
_ck_
ParticipantYou mean the one by GamerZ S010?
I’ve watched him improve that over the past year or two, actually sent some bug fixes and improvements. Still doesn’t do quite everything I’ve seen in other advanced polls but he’s got the multi-vote option so that’s good.
It uses the metadata so it would be fairly easy to convert, the only problem is his creation and management menus are all meant for the admin interface so a new creation routing would have to be written for the regular user interface. Then there is the problem of the trigger and attachment. I guess it gets attached to the topic-info box.
Now if we could only get him to switch from simple machines forum to bbpress we’d have a shedload of new bbpress plugins within a month
July 20, 2007 at 1:53 pm #59302In reply to: Custom fields
so1o
Participantand you can catch this field in
bb_post.phpaction to process the post.July 20, 2007 at 1:14 pm #56714In reply to: Plugin: Avatar Upload
Detective
MemberIt appears just in the upload avatar template. Everything else works fine
July 20, 2007 at 1:06 pm #59212In reply to: Help with an if/then statement
outchy
MemberYES!!! oh, you’ve made my week, thank you so much

the log in text is here in template-functions.php:
if ( ( is_topic() && bb_current_user_can( ‘write_post’, $topic->topic_id ) && $page == $last_page ) || ( !is_topic() && bb_current_user_can( ‘write_topic’, $forum->forum_id ) ) ) {
echo “<form class=’postform’ name=’postform’ id=’postform’ method=’post’ action='” . bb_get_option(‘uri’) . “bb-post.php’>n”;
bb_load_template( ‘post-form.php’, array(‘h2’ => $h2) );
bb_nonce_field( is_topic() ? ‘create-post_’ . $topic->topic_id : ‘create-topic’ );
if ( is_forum() )
echo “<input type=’hidden’ name=’forum_id’ value=’$forum->forum_id’ />n”;
else if ( is_topic() )
echo “<input type=’hidden’ name=’topic_id’ value=’$topic->topic_id’ />n”;
do_action(‘post_form’);
echo “n</form>”;
} elseif ( !bb_is_user_logged_in() ) {
echo ‘<p>’;
printf(__(‘You must log in to post.’), attribute_escape( bb_get_option(‘uri’) . ‘bb-login.php’ ));
echo ‘</p>’;
}
do_action(‘post_post_form’);
}
this is the last piece of the puzzle for me
July 20, 2007 at 1:05 pm #59301In reply to: Custom fields
fel64
MemberYou can use a hook to add an input field. Your code would look something like this:
add_action('post_form', 'addmyinputfield');
function addmyinputfield() {
echo '<input type="text" name="mine" id="mine" />';
}You would need another hook to then get the value when it’s been posted. I’m not sure about this one, but I think the hook would be
pre_post. Again you use it in the same way as above:add_action('hook_name', 'function_name');There’s a list of hooks here, http://bbpulp.org/wiki/API/actions if that wasn’t the one you wanted. Maybepost_form_pre_post?July 20, 2007 at 12:54 pm #59211In reply to: Help with an if/then statement
fel64
MemberIt’s in front-page.php at the very bottom. You can see at the start it checks if $forums is set, and if it isn’t (line 75, where it says
else : $forums) it delivers the page to make a new topic (and in the background $forums isn’t set if the url has ?new=1). That’s where the post_form() is too. Finding that one out took a while
I don’t know. Where is the you must log in to post text?
July 20, 2007 at 12:45 pm #59210In reply to: Help with an if/then statement
outchy
Membersweet, thanks.
now the only one i’m getting hung up on is the “add new topic” page because the page url is http://www.example.com/bbpress/?new=1 and i can’t see which page that actually is referring to (i can usually see something like “/topic.php?id=35&page&replies=2” in the url to know what page to edit. i know the actual form itself resides in post-form.php but the <h2> i’m trying to alter isn’t actually in that file. same goes with the line breaks before it, they would go in the same place.
i can see where it is in the template-functions.php:
elseif ( is_bb_tag() || is_front() )
$h2 = __(‘Add New Topic’);
i simply can’t find it elsewhere in the code and i’m going mad and blind!
all your help is much appreciated.
ps: one more thing! do you know where would i change the “you must log in to post” text?
July 20, 2007 at 10:36 am #59209In reply to: Help with an if/then statement
fel64
MemberYou do the same thing, but in different templates. If you look at the code, if $h2 is empty (ie. you didn’t tell it what to set) then it checks where it is – in a topic, in a forum, on a tag page or on the front page. But you can always tell it what to put instead. So if you want something else on a tag page, open the tag pages (tags.php, tag-single.php I think) in your template, look for
<?php post_form(); ?>and change it to<?php post_form('No pizza for you!'); ?>. That’s a change that will happen only on the pages whose template you modified.To add line breaks in HTML you use
<br />. But I’m not sure you can have that inside an <h2> element. You can probably just put that right above the<?php post_form(); ?>, like so:<br />
<br />
<?php post_form('Macaroni Cheese'); ?>July 20, 2007 at 10:30 am #59284In reply to: Bug in register-success.php?
fel64
MemberJuly 20, 2007 at 10:22 am #56713In reply to: Plugin: Avatar Upload
LMD
ParticipantHi, the error you are reporting appears to be a problem with the bbPress core code, specifically the user ‘capabilities’ class.
Have I understood this correct:
– You are using the latest bbPress version (0.8.2.1) ?
– The error only appeared AFTER you upgraded to the latest Avatar Upload plugin to version (0.6.2)?
– Does the error appear on EVERY page, or just the Avatar Upload template in the profile area?
July 20, 2007 at 8:35 am #59287In reply to: front page takes 50 mysql queries
_ck_
ParticipantAh I totally forgot I’ve got visitor tracking which adds some calls but doesn’t explain why it’s more than a dozen calls by design.
If anyone’s interested, I’ve ported the “query diagnostics” plugin from wordpress so you can see each mysql call used, hidden as a report at the end of each page (for administrators).
<?php
/*
Plugin Name: bb-benchmark
Plugin URI: http://CKon.WordPress.com
Version: 0.10
Description: Prints simple benchmarks and mysql diagnostics, hidden in page footers.
based on Jerome Lavigne's Query Diagnostics for WordPress http://vapourtrails.ca/wp-plugins
Author: _ck_
Author URI: http://CKon.WordPress.com
*/
/* INSTRUCTIONS:
1. add this line to your bbpress config.php file: @define('SAVEQUERIES', true);
2. install & activate plugin
3. do a "view source" on any bbpress page to see hidden results at bottom
*/
function bb_benchmark_output() {
if (bb_current_user_can( 'administrate' ) ) :
if (SAVEQUERIES) :
global $bbdb;
echo "<!-- n === benchmark & query results === n ";
while($qposition < $bbdb->num_queries){
$qsubtime=$bbdb->queries[$qposition][1];
if ($qsubtime>$qmaxtime) {$qmaxtime=$qsubtime;$qmaxquery=$bbdb->queries[$qposition][0];}
$qtotal += $qsubtime;
$qposition++;
}
$timer_stop=bb_timer_stop(0);
echo @shell_exec("uptime")."n";
echo "query count: ".$bbdb->num_queries." nn";
echo "total query time: ".round($qtotal,4)." seconds nn";
echo "total page time: ".round($timer_stop,4)." seconds.nn";
echo "page render difference: ".(round($timer_stop-$qtotal,4))." seconds nn";
echo "slowest call was: ".$qmaxquery."n at ".round($qmaxtime,4)." seconds nn";
if (phpversion() >5.0 && function_exists(memory_get_peak_usage()) && function_exists(memory_get_usage())) {
echo "nn === memory usage === n";
echo "peak memory ".memory_get_peak_usage()." nn";
echo "total memory ".memory_get_usage()." nn";
}
// echo "nn === resource usage === n";
// print_r (getrusage());
echo "nn === mysql queries used === n";
print_r($bbdb->queries);
echo "-->";
endif;
endif;
}
add_action('bb_foot', 'bb_benchmark_output');
?>July 20, 2007 at 8:25 am #59286In reply to: permalinks with trailing slash
_ck_
ParticipantIf it makes you feel any better, wordpress doesn’t deal with it well either.
I have to trick it into enforcing trailing slashes like this:
RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_URI} !..+$
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1/ [R=301,L,QSA]and that doesn’t even work half the time depending on what other htaccess trickery I’ve got going on
But I notice if I have slugs turned on in bbpress, it will remove the trailing slash always. If I have slugs turned off, it won’t tolerate a trailing slash at all and will 404
I did manage to get the topmost rss feed to tolerate slash or not using this obvious mod
RewriteRule ^rss(/|)$ /forums/rss.php [L,QSA]One thing that is important to do in bbpress vs how it’s typically done in wordpress, is not re-use/re-load the bbpress core engine if there is a redirect (which doubles the mysql calls) but to try to do it through htaccess
July 20, 2007 at 6:15 am #56712In reply to: Plugin: Avatar Upload
Detective
MemberHi,
I just upgraded to the last version and now my forum prints this message:
Warning: call_user_func_array() [function.call-user-func-array]: First argumented is expected to be a valid callback, 'stdClass::has_cap' was given in /home/ficcion/public_html/wp-includes/capabilities.php on line 454
Warning: call_user_func_array() [function.call-user-func-array]: First argumented is expected to be a valid callback, ‘stdClass::has_cap’ was given in /home/ficcion/public_html/wp-includes/capabilities.php on line 454
Warning: call_user_func_array() [function.call-user-func-array]: First argumented is expected to be a valid callback, ‘stdClass::has_cap’ was given in /home/ficcion/public_html/wp-includes/capabilities.php on line 454
Warning: call_user_func_array() [function.call-user-func-array]: First argumented is expected to be a valid callback, ‘stdClass::has_cap’ was given in /home/ficcion/public_html/wp-includes/capabilities.php on line 454
Sadly i don’t know what it is.
July 20, 2007 at 3:43 am #59041In reply to: User name not show on registration successful page.
sailorman
MemberThank you
- Change
-
AuthorSearch Results