WP-Table plugin – Fatal Error fix for WordPress 2.5+

27Jun08

We have moved, so please update your bookmarks for this page to this!

WP-Table plugin by Alex Boelinger is a unique WordPress plugin that allows admins to create tables, by this I mean the ones with rows and columns like in Excel, easily in WordPress. It is the only one that I am aware of at the moment that makes it possible to add actual tables without putting-in extra HTML when creating new posts and pages.

However, activating the latest version (1.52) of the plugin triggers a fatal error (shown below) in WordPress 2.5+:

Plugin could not be activated because it triggered a fatal error.

Fortunately there is a quick fix that can be done to resolve this issue, where the full credit for this solution goes to Michael Bester, the developer of the Kimili Flash Embed, who posted a comment on Jovel Stefan’s Embedded Video Plugin post about a fix to ensure that a plugin should check for the buttonsnap class upon activation.

This class is used to add a button to your WordPress editor, and should only ever be loaded once, so if any other plugin uses buttonsnap, it will cause the fatal error to occur.

To resolve this problem, find Line 344 in wp-table.php

require_once(WPTABLE_ABSPATH.'js/buttonsnap.php');

and add before it:

if(!class_exists('buttonsnap'))

So ultimately you should see this:

// ButtonSnap needs to be loaded outside the class in order to work right
if(!class_exists('buttonsnap'))
require_once(WPTABLE_ABSPATH.'js/buttonsnap.php');

I tested this on a local install of WordPress 2.5.1, and it worked very well. This quick fix has also been posted on the WordPress Support Forums, and hopefully others will find it helpful as well.

Any feedback would be brilliant! If it works for you, please let me know by posting in the comments. Similarly, if it doesn’t work for you, then again, please do post! I don’t see the plugin requiring any further edits for the time being (apart from new features) and am confident that it will also work with later WordPress versions as well.

p/s: UPDATE (July 20th) – Apparently the plugin does work with WP 2.6!

p/s: Our new website is now at http://www.wpsnippets.com, and you can read the article (again?) right here!

Advertisement


9 Responses to “WP-Table plugin – Fatal Error fix for WordPress 2.5+”

  1. 1 chartzog

    I installed the WP Table plugin on my WordPress 2.5.1 database, and yes, initially WP Table did produce the fatal error as described. I added the fix described above and it now works as advertised. I look forward to using wp table as I really love tables.

    Chris
    http://www.chris-hartzog.com

  2. 2 flick

    @Chris: Thanks for your comment! It’s great to know this solution worked for you as well.

  3. Kewl Scene Mate. I never thought this could be a problem with the shipped WP-Table. Thanks mate. You made my day.

  4. 4 flick

    Apparently WP-Table still works with WP 2.6!

    With thanks to jhsesq of jhsiess.com who is using it on his site.

    @iwebie: Thank you for your friendly comment! It’s made my day! πŸ™‚

  5. 5 gwade

    Hi

    I have installed the line of code as per above but I am still getting the fatal error message. I am using WP 2.6

    This is the error that I get:
    ———–
    Warning: require_once(/home/nocellu/public_html/wp-content/plugins/wp-table/js/buttonsnap.php) [function.require-once]: failed to open stream: No such file or directory in /home/nocellu/public_html/wp-content/plugins/wp-table/wp-table.php on line 345

    Fatal error: require_once() [function.require]: Failed opening required ‘/home/nocellu/public_html/wp-content/plugins/wp-table/js/buttonsnap.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/nocellu/public_html/wp-content/plugins/wp-table/wp-table.php on line 345
    ————-
    I did deactivate all my other plugins and tried to activate the table plugin but still got the error above.

    This is my code in the plugin editor:

    // ButtonSnap needs to be loaded outside the class in order to work right

    if(!class_exists(‘buttonsnap’))
    require_once(WPTABLE_ABSPATH.’js/buttonsnap.php’);

    Any ideas?

    Thanks
    Grant

  6. For anyone using wp-table on WordPress 2.6 and getting the following error on CSV import:

    Warning: move_uploaded_file(/home/content/c/l/e/sitename/html//home/content/c/l/e/sitename/html/wp-content/uploads/filename.csv) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/content/c/l/e/sitename/html/wp-content/plugins/wp-table/wp-table-admin.php on line 170

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpJG2DBQ' to '/home/content/c/l/e/sitename/html//home/content/c/l/e/sitename/html/wp-content/uploads/filename.csv' in /home/content/c/l/e/sitename/html/wp-content/plugins/wp-table/wp-table-admin.php on line 170
    ERROR : File cannot be saved. Check the permission of the wordpress upload folder

    There is a fix. In the wp-table-admin.php file, replace this line:

    $csv_file = ABSPATH.get_option('upload_path' ).'/'.$_FILES['csv_file']['name']; // set upload path

    With this line;

    $csv_file = $_FILES['csv_file']['name']; // set upload path

    If you look at the error message you can see that the ABSPATH is showing up twice in the filename, like this:

    "/home/content/c/l/e/sitename/html//home/content/c/l/e/sitename/html/wp-content/uploads/filename.csv"

    Notice the double slash in that string, the sections just before and just after the double slash are the same. I’m new to WordPress, but it appears that the issue is that in 2.6 the filename (as used in this plugin) already contains the full absolute path so the ABSPATH doesn’t need to be prepended to the filename.

    As I said, I’m a WP noob so your mileage may vary, and this might break anything and everything, but it’s working for me on 2.6!

  7. 7 flick

    For those wondering about the answer to Grant’s question, please see: http://www.wpsnippets.com/2008/06/wp-table-plugin-fatal-error-fix/

  8. 8 flick

    @EngineerBoy: Thanks for your input! πŸ˜‰ I wonder if it’s a situation that was faced joyo who commented on the new version of this page.

    The solution that we came up at the time with was essentially several clicks in the admin panel to ‘reset’ the database value.

    For those who are wondering, you can see the comment here:
    http://www.wpsnippets.com/2008/06/wp-table-plugin-fatal-error-fix/#comment-8

  9. 9 flick

    As this article has now moved, please can new comments be made here instead:

    http://www.wpsnippets.com/2008/06/wp-table-plugin-fatal-error-fix/

    Thanks!



%d bloggers like this: