Support » Plugins and Hacks » WPBook » [Resolved] [Plugin: WPBook] Fatal Error when publishing post

[Resolved] [Plugin: WPBook] Fatal Error when publishing post

  • when publishing post i’m getting this:

    Fatal error: Cannot redeclare wpbook_safe_publish_to_facebook() (previously declared in /home/krakoff/ftp/krakoff.info/wp-content/plugins/wpbook/publish_to_facebook.php:6) in /home/krakoff/ftp/krakoff.info/wp-content/plugins/wpbook/publish_to_facebook.php on line 179

    except that message plugin works.

Viewing 15 replies - 1 through 15 (of 35 total)
  • HumbleHumans


    I am having the same error, line referencet to 179 included. This is just a guess and I’m really not sure, but it might have something to do with the Gravatar rating setting.

    I had the beta version working flawlessly, it wasn’t till I made two changes that I received the error. Change the first was the addition of the “Super Cat Listener” plugin. Change the second was selecting a Gravatar rating under commenting options which previously remained unselected.

    I was able to go back and delete the questionable plugin. Unfortunately I am notable to unselect a Gravatar rating and forced to choose one of the radio buttons supplied.

    That said I could be completely wrong… please help!

    Plugin Contributor BandonRandon


    @efab what verison of WPBook? I think this message is just happening randomly but we’ve had several reports. I expericed it for a breif time then it went away.

    Plugin Author John Eckman


    This is an error with 2.0.10 – not sure why you only see it some times.

    I just checked into SVN a newer version of 2.0.10 with the duplicate functions removed – should show up on the “other versions” page in the next 30 minutes.

    Please test and let me know if that solves your problems.


    while publishing i’m getting this:

    Warning: include_once(/home/krakoff/ftp/krakoff.info/wp-content/plugins/wpbook/client/facebook.php) [function.include-once]: failed to open stream: No such file or directory in /home/krakoff/ftp/krakoff.info/wp-content/plugins/wpbook/includes/publish_to_facebook.php on line 8

    Warning: include_once() [function.include]: Failed opening ‘/home/krakoff/ftp/krakoff.info/wp-content/plugins/wpbook/client/facebook.php’ for inclusion (include_path=’.:/usr/local/lib/php’) in /home/krakoff/ftp/krakoff.info/wp-content/plugins/wpbook/includes/publish_to_facebook.php on line 8

    Fatal error: Class ‘Facebook’ not found in /home/krakoff/ftp/krakoff.info/wp-content/plugins/wpbook/includes/publish_to_facebook.php on line 26

    post is published on blog but not on FB, so i moved ‘client’ folder back to root directory. after that while publish i’m getting:
    Fatal error: Cannot redeclare wpbook_safe_publish_to_facebook() (previously declared in /home/krakoff/ftp/krakoff.info/wp-content/plugins/wpbook/includes/publish_to_facebook.php:6) in /home/krakoff/ftp/krakoff.info/wp-content/plugins/wpbook/includes/publish_to_facebook.php on line 179

    I checked in taco html editor php syntax and i’ve get:
    Parse error: parse error in /wpbook/includes/TacoHTMLEditPHPCheckTemp.php on line 42
    Errors parsing /wpbook/includes/TacoHTMLEditPHPCheckTemp.php

    Plugin Author John Eckman


    Ah – I see an error that crept in in the 2.0.10 push – just checked in a new version of the file.

    wpbook/includes/publish_to_facebook.php, line 8, should be:


    (The path includes the “includes” dir between wpbook and “client”).

    The “cannot redeclare” errors come from a bad copy of 2.0.10 on Brooke’s blog – get the version from the wordpress.org/extend/plugins/wpbook/download page.

    What is Taco HTML Editor?

    I’ve got the newest version of plugin from that location.
    Taco HTML Editor is a free Mac software i use for editing php files.

    I’ve changed line 8 and i’m still getting:

    Fatal error: Cannot redeclare wpbook_safe_publish_to_facebook() (previously declared in /krakoff.info/wp-content/plugins/wpbook/includes/publish_to_facebook.php:6) in /krakoff.info/wp-content/plugins/wpbook/includes/publish_to_facebook.php on line 179

    Plugin Author John Eckman


    From which location did you pull 2.0.10?

    The error you’re getting suggests that you do not have the latest from the SVN repository as you would not have a line 179.

    Try the latest “development version” from http://www.wordpress.org/extend/plugins/wpbook/download/

    I’ve no idea what’s causing the parse error with Taco HTML Editor but you’d have to look to them for support.

    i’ve downloaded version 2.0.10. from ‘development version’ and i’ve got this:

    Fatal error: Cannot redeclare wpbook_safe_publish_to_facebook() (previously declared in /krakoff.info/wp-content/plugins/wpbook/includes/publish_to_facebook.php:6) in /krakoff.info/wp-content/plugins/wpbook/includes/publish_to_facebook.php on line 182

    Plugin Author John Eckman


    Not sure what’s going on, but line 182 in my version (which is direct from SVN trunk and should be the same as the development version) is just this:
    } // end of wpbook_safe_publish_to_facebook

    Which is just an end function and comment.

    How many lines long is your wpbook_safe_publish_to_facebook.php file? Or how many KB is it?

    How many lines long is your wpbook_safe_publish_to_facebook.php file? Or how many KB is it?

    it’s 184 line long but the last one is empty
    and it’s 12 KB

    Plugin Author John Eckman


    Hmm. That error just doesn’t make sense to me given that line 182 is just a comment.

    Have you tried deactivating and deleting the whole plugin directory and reinstalling?

    Sorry to not be more helpful but the error doesn’t make sense to me here.

    So, I’ve upgraded my version to 2.2.3. This issue still happens: Fatal error: Cannot redeclare wpbook_safe_publish_to_facebook() (previously declared in __FILE__/publish_to_facebook.php:6) in __FILE__/publish_to_facebook.php on line 403.

    I’m writing a simple script to get all of the unpublished posts, and publish them. For some reason, when I run wp_publish_post(), that error gets throw. What’s stranger is that error gets thrown on the third post. What does WPBook have to do with individual posts, especially in reference to publishing a single post? Why does that error get thrown when publishing posts?

    To anyone having an issue, I figured out what the problem is.

    NOTE: I am using WPBook 2.2.3! So any lines I put in here might be incorrect!

    That said…

    In the wpbook.php file, there is a function wpbook_publish_to_facebook() on line 1029. This is the function called through the hook, ‘draft_to_publish.’ This hook was causing the issue we were all seeing. The issue is every time I called wp_publish_post, that hook was running the wpbook_publish_to_facebook() function. Here’s where the problem lies:

    if (!version_compare(PHP_VERSION, '5.0.0', '<')) {
    include(WP_PLUGIN_DIR .'/wpbook/includes/publish_to_facebook.php');

    All that code is doing is making sure we are running PHP5.0.0 or higher. This means, any time this function is called, we are going to reinclude the publish_to_facebook.php file. Ergo, we are going to have redefinition of wpbook_publish_to_facebook(). This will cause that error to get throw.

    Here’s what the code should look like to ensure we don’t have redefinition errors:

    if (!version_compare(PHP_VERSION, '5.0.0', '<')) {
    if(!function_exists('wpbook_publish_to_facebook')) {
    include(WP_PLUGIN_DIR .'/wpbook/includes/publish_to_facebook.php');

    Please make use of this as you see fit! It will clear up any redefinition errors you have with wpbook_publish_to_facebook()!


    Plugin Author John Eckman


    The other approach, which is what’s in the current dev version and just hasn’t yet been released, is just to use include_once rather than include.

    Thanks for sharing your troubleshooting, and sorry that we haven’t pushed this code change out yet – it’s been sitting on the queue waiting for another release. (See the entry in the dev log from 6 weeks ago: http://plugins.trac.wordpress.org/log/wpbook/). I was waiting to bundle this change in with some others and then got sidetracked.

    To those following along, this becomes an issue when multiple posts get published at the same time, which you often see on imports or syndication style models, like autoblogger.

    That definitely be good a start. I would definitely add in the function_exists call, as well, in case some one decides to get crazy and ends up redefining the function. This will protect both aspects.

    And not a problem at all. Gives me a chance to delve into the code more. I know how it can get maintaining code, especially when there’s a lot on your plate.

    Thanks for the plugin, by the way!

Viewing 15 replies - 1 through 15 (of 35 total)
  • The topic ‘[Resolved] [Plugin: WPBook] Fatal Error when publishing post’ is closed to new replies.
Skip to toolbar