bbPress

Simple, Fast, Elegant

bbPress support forums » Troubleshooting

Having trouble integrating WP functions

(30 posts)
  • Started 8 months ago by ixray2
  • Latest reply from stumain
  • This topic is not resolved

Tags:

  1. ixray2
    Member

    Hi,

    I have bbPress running along with Wordpress. It's working fine so far, but now I'm trying to use WP functions in my bbPress theme.

    I followed the directions and added "require_once('/var/www/web7/web/wp-blog-header.php');" to the top of my bbPress config.php file.

    But all I get is "Connection Reset by Server" when I open bbPress. As soon as I remove that line, it'll work again, but without the WP functions, of course.

    What am I doing wrong here?

    Posted 8 months ago #
  2. Could you paste the web server's error log?

    Posted 8 months ago #
  3. ixray2
    Member

    Well, actually it's a Safari error message and it's in German, but I'll post it anyway:

    "Safari kann die Seite „..“ nicht öffnen, da der Server die Verbindung unerwartet beendet hat. Dies tritt manchmal auf, wenn ein Server überlastet ist. Möglicherweise können Sie die Seite später öffnen."

    Rough translation: "Safari can't open the page .., because the connection was unexpectedly reset by the server. This may occur if the server is busy. You might try again later."

    In Firefox, I just get a white page, no error message.

    When I add the ""require_once('/var/www/web7/web/wp-blog-header.php');" line to the bottom of config.php, I get this error message:
    "Fatal error: Cannot redeclare _http_build_query() in /var/www/web7/web/wp-includes/compat.php on line 108"

    Again, both Wordpress and bbPress are running fine on its own, but it seems as soon as I try to load them together, something goes wrong.

    Posted 8 months ago #
  4. Well, I didn't mean that kind of error message. If your hosting provider gives you cpanel, there should be a "Error Logs"

    And put that line top of original config.php is correct, but to bottom isn't.

    Maybe you can try to use relative path? (I don't think this will help...)

    What are the versions of WordPress and bbPress which you are using?

    Still need the error log.

    Posted 8 months ago #
  5. ixray2
    Member

    I'm running WP 2.3.1 and bbPres 0.8.3.

    The server's error log looks like this:

    [Sun Dec 16 21:52:52 2007] [error] [client 217.255.224.134] PHP Fatal error: Cannot redeclare _http_build_query() in /var/www/web7/web/wp-includes/compat.php on line 108

    But I suspect those are the errors from when I put the integration line to the end of the config.php file. There do not seem to be any errors in the log file from when put at the top.

    Posted 8 months ago #
  6. ixray2
    Member

    Btw, I just deactivated all bbPress plugins and switched to the standard theme, but still no luck.

    Posted 8 months ago #
  7. I don't have any clues to solve you problem.

    If I were you, I will
    1. put error_log('WordPress loaded'); after that request_once to make sure wp has been loaded.
    2. check error log for WordPress loaded, if I get that, that means the problem should be on bbPress, or on WordPress.
    3. keep using error_log, find out where causes a program end.

    This is my no-debugger-debugging method.

    Posted 8 months ago #
  8. ixray2
    Member

    thanks, livibetter.

    well, i tried your method, and "WordPress loaded" does show up in the error log..

    Posted 8 months ago #
  9. Then, you should trace in bbPress' code to find out where causes an exit.

    BTW, you can also test error_log(get_option('blogname')); to make sure WordPress loaded database correctly.

    PS. debugging with no debugger is a crazy thing. You have to guess by experiences for best shot.

    Posted 8 months ago #
  10. ixray2
    Member

    hey, using your method i found what's causing the problem.

    i's the following lines from bb-settings.php:

    if ( defined('BBLANG') && '' != constant('BBLANG') ) {
    include_once(BBPATH . BBINC . 'streams.php');
    include_once(BBPATH . BBINC . 'gettext.php');
    }

    When I remove them, it works. However, then it doesn't load my language file (which is perfectly working without integration, btw). Any ideas?

    Posted 8 months ago #
  11. Reproduced.

    I didn't use any language files. But after I put a language code in bb-config.php (for r988) and wp-config.php, I got a blank page.

    Don't know if I can fix this.

    Posted 8 months ago #
  12. ixray2
    Member

    Thanks for your support on this, wouldn't have come this far whithout you.

    I guess I could manually change everything to German, but that's obviously just the second best solution.

    Posted 8 months ago #
  13. I think this needs to change bbPress core and even WordPress'.

    What's the WordPress function that you are planning to use?

    Posted 8 months ago #
  14. This is a quick workaround:

    if ( defined('BBLANG') && '' != constant('BBLANG') ) {
        if ( function_exists('load_default_textdomain') ) :
            global $l10n;
    
            $locale = BBLANG;
            $mofile = BBLANGDIR . "$locale.mo";
    
            load_textdomain('default', $mofile);
        else:
            include_once(BBPATH . BBINC . 'streams.php');
            include_once(BBPATH . BBINC . 'gettext.php');
        endif;
    }
    if ( !( defined('DB_NAME') || defined('WP_BB') && WP_BB ) ) {  // Don't include these when WP is running.
        require( BBPATH . BBINC . 'kses.php');
        if ( !function_exists('load_default_textdomain') )
            require( BBPATH . BBINC . 'l10n.php');
    }

    It should drops WordPress' language file, and replaces with bbPress'. That means translations need to be done in WordPress won't be translated since this code drops language file. This wont happen when you read your blog. However, I don't have any language files, so this is coded by guessing.

    This is not a solution, just a temporary fix. I will file a ticket.

    Posted 8 months ago #
  15. ixray2
    Member

    Well, basically all of them, including plugins. I want to use my WP header, sidebar etc. and I am planning to build some custom functions that make use both of WP and bbPress functions. So I really do need integration.

    Did you find out anything on what exactly is causing the hick-up?

    Posted 8 months ago #
  16. Seems you will use a lot of stuff from WordPress. If your WordPress template is already written in German, then you should have no problems. If not or some functions use gettext functions, then you will see many text in original language.

    Posted 8 months ago #
  17. ixray2
    Member

    tried out your workaround, does not seem to work (doesn't load language file).

    also, shouldn't it be $mofile = BBLANGDIR . $locale . ".mo";?

    but even with that fixed, it doesn't work.

    but still, thanks a lot!!

    Posted 8 months ago #
  18. streams.php and gettext.php are just libraries, so if they are loaded by WordPress, then they don't need to be loaded again. Although "include_once" should take care of that.

    The problem with the language file not loading is because of the next couple of lines. They say that if WordPress is loaded not to load the kses.php and l10n.php files. This means it is looking for yor language file for bbPress in the same place as the WordPress language file.

    It's possible (but I don't know enough about how gettext works) that just dropping the bbPress mo file into the same place as the WordPress mo file will work... just call the bbPress mo file bbpress-de.mo or something like that.

    I think someone solved this before... search a little harder through the forums I think.

    Posted 8 months ago #
  19. ixray2
    Member

    echoed $mofile, and it does reference the right language file.. just doesn't load it.

    Posted 8 months ago #
  20. ixray2
    Member

    guys, thanks for your help. it's time to go to bed on this side of the pond now, but I'll investigate further tomorrow!

    Posted 8 months ago #
  21. Sorry, didn't read bbPress source carefully. Replace first if clause with

    if ( defined('BBLANG') && '' != constant('BBLANG') ) {
        if ( function_exists('load_default_textdomain') ) {
            global $l10n;
    
            $locale = BBLANG;
            $mofile = BBPATH . BBINC . 'languages/' . "$locale.mo";
            if ( is_readable($mofile) ) {
                $input = new CachedFileReader($mofile);
                $l10n['default'] = new gettext_reader($input);
            }
        }
        else {
            include_once(BBPATH . BBINC . 'streams.php');
            include_once(BBPATH . BBINC . 'gettext.php');
        }
    }

    PS. That ".." is how you put variable to be parsed in string in PHP ( Variable parsing )

    Posted 8 months ago #
  22. ixray2
    Member

    @livibetter: Awesome, now it works. You made my day!!!

    And regarding variable parsing: Nice to know, wasn't aware of that.

    Posted 8 months ago #
  23. The workaround won't work for plugins.

    @sambauers: I think there is no complete working solution if you don't touch the core files.

    First, load_default_textdomain and load_plugin_textdomain are WordPress version, they only look language files in WordPress directories. So, in bbPress, all text won't be translated since language file are not loaded because WordPress load_*_textdomain won't find language files in bbPress' directories.

    Second, WordPress and bbPress both use default as textdomain when calling __() or _e() without assigning textdomain, that means we can only use either WordPress' or bbPress' language files at the same time, not both.

    (edit: plugin's problem can be solved by add a bb_load_plugin_textdomain, but bbPress's part. If we don't want to use something like bb__(), bb_e(), maybe we can try to merge bbPress translations into WordPress' in runtime? or search bbPress' first, then WordPress' if can't find)

    Posted 8 months ago #
  24. ixray2
    Member

    Okay, here is another problem:

    Ever since I've integrated Wordpress as detailed above, I can't access the bb-admin .. it's just a blank page.. as soon as I remove Wordpress integration, it'll work again.

    Posted 8 months ago #
  25. ixray2
    Member

    Here is a quick workaround I just figured out, but I'm not sure this is state of the art:

    Instead of
    require_once(dirname(__FILE__) . '/../wp-blog-header.php');
    in config.php, I put
    `if ( !defined('DB_NAME') && !strstr($_SERVER["PHP_SELF"],'bb-admin') )
    require_once(dirname(__FILE__) . '/../wp-blog-header.php'); `

    Posted 8 months ago #
  26. !defined('DB_NAME') is redundant, since you should be only one can code on your files.

    I will use

    if ( !strpos($_SERVER["PHP_SELF"], 'bb-admin') )
        require_once('../wp-blog-header.php');

    Anyway, you did a great job!

    PS. could you show us your forums?

    Posted 8 months ago #
  27. ixray2
    Member

    You can see the current, half-integrated version at http://www.macnotes.de/forum/.

    The new version will be up and running in January.

    Posted 8 months ago #
  28. Did you make the theme? It's great!

    Posted 8 months ago #
  29. I am currently using the version of 0.8.3.1, the version is still not solved by the above method. Any idea?

    ixray2, what version of bbpress are you using?

    Posted 6 months ago #
  30. stumain
    Member

    ixray2, livibetter,

    many thanks guys! I had the issue with bb-admin not displaying after integration. Now solved thanks.

    Posted 2 months ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.