WordPress.org

Forums

WPBook
[resolved] Fatal Error when publishing post (36 posts)

  1. efeb
    Member
    Posted 4 years ago #

    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.

  2. HumbleHumans
    Member
    Posted 4 years ago #

    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!

  3. BandonRandon
    Member
    Plugin Contributor

    Posted 4 years ago #

    @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.

  4. John Eckman
    Member
    Plugin Author

    Posted 4 years ago #

    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.

  5. efeb
    Member
    Posted 4 years ago #

    @johneckman

    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

  6. John Eckman
    Member
    Plugin Author

    Posted 4 years ago #

    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:

    include_once(WP_PLUGIN_DIR.'/wpbook/includes/client/facebook.php');

    (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?

  7. efeb
    Member
    Posted 4 years ago #

    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

  8. John Eckman
    Member
    Plugin Author

    Posted 4 years ago #

    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.

  9. efeb
    Member
    Posted 4 years ago #

    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

  10. John Eckman
    Member
    Plugin Author

    Posted 4 years ago #

    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?

  11. efeb
    Member
    Posted 4 years ago #

    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

  12. John Eckman
    Member
    Plugin Author

    Posted 4 years ago #

    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.

  13. dasfisch
    Member
    Posted 4 years ago #

    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?

  14. dasfisch
    Member
    Posted 4 years ago #

    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()!

    Cheers!

  15. John Eckman
    Member
    Plugin Author

    Posted 4 years ago #

    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.

  16. dasfisch
    Member
    Posted 4 years ago #

    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!

  17. TraciBunkers
    Member
    Posted 3 years ago #

    I just got a similar error:

    Fatal error: Cannot redeclare wpbook_safe_publish_to_facebook() (previously declared in /home/tracibu/public_html/blog/wp-content/plugins/wpbook/includes/publish_to_facebook.php:6) in /home/tracibu/public_html/blog/wp-content/plugins/wpbook/includes/publish_to_facebook.php on line 403

    This happened when I tried saving a slideshow using the SlideDeck plugin. I'm using WPBook version 2.2.3.

  18. John Eckman
    Member
    Plugin Author

    Posted 3 years ago #

    Traci - you can grab the development version from http://wordpress.org/extend/plugins/wpbook/download/ (at the bottom of the page).

    Or you can make the change described by dasfisch above - checking to see if wpbook_safe_publish_to_facebook() already exists before importing it.

    What concerns me though is why this is happening - it happens when multiple posts are being published at the same time - does the SlideDeck plugin make multiple posts for each "deck"?

  19. TraciBunkers
    Member
    Posted 3 years ago #

    I tried to make the change that dasfisch suggested--but for me, it was around line 2059 that I had to add in if(!function_exists('wpbook_publish_to_facebook')) {

    plus, mine had some code that his didn't, so I'm not sure if I needed to do something else. Here's what I had after add that line:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Then when I tried to save the slide show, I would get the message "Sorry, but you can't run this plugin, it requires PHP 5 or higher." But I do have PHP5.2.15. If I deactivated WPBook, it didn't happen and I could save the slide show. After saving it, I realized the slideshow plugin didn't do what I wanted, so I deactivated it.

    I don't believe slidedeck is even making posts because you create a slideshow, then you can insert it into a post. But maybe for each "slide" that it creates for the slideshow (each photo is a slide), it acts as a post?

    Aside from SlideDeck, I'm not sure if the error had anything to do with other issues I have with WPBook (I've posted a question about it, and you replied) where at first it was cutting off the post when it posted to my page, but not on my profile (which was posted as a note). Without me changing anything (that I can remember) it stopped doing that, but if you click on "read more", it takes you to my blog--so no comments can be left on FB for it. I'm not sure if I have something set up wrong or not.

  20. TraciBunkers
    Member
    Posted 3 years ago #

    Today I tried publishing a new post, and I got the same error "Sorry, but you can't run this plugin, it requires PHP 5 or higher." This time it's not due to SlideDeck because I deleted it. All I was doing was publishing a post with some photos. I removed the code I had added (listed above in a previous comment here), and was able to publish. But lately, since WPBook isn't posting to Facebook, it's not doing anything.

  21. dasfisch
    Member
    Posted 3 years ago #

    The code you have is slightly wrong.

    Here's what you have:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    The if statement was in the wrong position. I very well might have done that myself. If I did, I apologize. The code should be good to go! PM me if you have any questions. I'd be happy to help you out.

  22. TraciBunkers
    Member
    Posted 3 years ago #

    dasfisch: thanks for your help! I deleted the plugin, and just reinstalled it. I deleted it because it had stopped publishing to my facebook, and it hadn't been behaving properly before that. Facebook has changed the app set-up, so it took me awhile to get it set back up again. Hopefully I've got it right. Then I made the change like you gave. I'll have to wait until I post something to see if everything is working correctly. I would do a test post, but I have a bunch of subscribers and don't want to annoy them. I'll let you know if I need any help. Thanks so much!

  23. TraciBunkers
    Member
    Posted 3 years ago #

    I am working on a post for tomorrow. When I tried to save it as a draft, I got this error:

    Warning: Cannot modify header information - headers already sent by (output started at /home/tracibu/public_html/blog/wp-content/plugins/wpbook/wpbook.php:2756) in /home/tracibu/public_html/blog/wp-includes/pluggable.php on line 934

    Here's that section of pluggable.php (click on the pastebin link to see)

    http://pastebin.com/Q7RKF1ff

    line 934 is header("Location: $location", true, $status);

  24. TraciBunkers
    Member
    Posted 3 years ago #

    Okay, I deleted the plug-in again, and uploaded the development version. With it activated, I was able to save the draft. Tomorrow when I finish the post and post it, I'll see if it posts it to my facebook page & profile.

  25. TraciBunkers
    Member
    Posted 3 years ago #

    I just tried publishing my post, and got this error:

    Caught exception in stream publish for user: Error validating application.Error code: 0

    I'll have to deactivate WPBook in order to publish it.

    Edit: Even though I got the error, it did publish my post, but only on my blog, not FB. I've deleted the developer's version, and reinstalled the most recent version. I'm about to give up.

  26. John Eckman
    Member
    Plugin Author

    Posted 3 years ago #

    Tracibunkers - sorry to hear you're having trouble - just haven't been able to keep up with support in the forums lately.

    When you had the development version installed, did you re-grant permissions?

    Sounds like a configuration error, but those are very difficult to track down. The "Error validating application" comes from Facebook, and likely means some kind of OAuth error.

  27. TraciBunkers
    Member
    Posted 3 years ago #

    John, I "think" I regranted permissions, but I might not have. When I reinstalled the most recent version, I did. Do you suggest I reinstall the development version, and regrant permissions? The posts show up fine on my canvas, and aren't cut off anymore, but they aren't posting to my FB wall.

  28. John Eckman
    Member
    Plugin Author

    Posted 3 years ago #

    Yes - reinstall the development version, and regrant permissions.

    Then let me know what the "check permissions" link shows - exactly what it says - that's the only way I can debug what's going on here.

  29. TraciBunkers
    Member
    Posted 3 years ago #

    Okay, done & done. Here's what it says, and I replaced my ID with XXX:

    This page is where you can check and grant extended permissions, which enable WPBook to publish to your personal wall and/or to the walls of fan pages.

    The Facebook profile ID you are currently logged in to Facebook as is XXX. You have defined XXX as your Facebook user id in WPBook Settings.

    FB profile XXX has granted these permissions:

    offline_access - yes
    read_stream - yes
    publish_stream - yes
    manage_pages - yes

    An access token for this user has been stored.

    You've indicated you wish to publish to this page: 373353135887

    An access token corresponding to this page has been stored.

    To correct any of these, Grant or re-grant permissions for your userid. (This is required if you intend to publish to your personal wall OR any fan pages.)

  30. TraciBunkers
    Member
    Posted 3 years ago #

    Okay, I just created a post to test it out. I was able to publish the post just fine, and it posted to both my facebook profile & fan page. On my fan page, to read more, it takes you to my blog--and that's fine. On the post on my profile (posted as a note), I wrote a comment to test it out. I also wrote a comment on my blog to see if the comments would show up in both places. They don't, or haven't--maybe it takes awhile? But this is what was happening before. It would be great for the comments to be shared in both places, but maybe I should just change it so that it doesn't post as a note to my profile, and posts through the app. Then when anyone clicks on it to read more, it just takes them to my blog?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WPBook
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags