Mark on WordPress

WordPress puts food on my table.

Plugin Sandboxing

with 37 comments

I just finished a feature for WordPress 2.2 that I’m pretty excited about. Not that it’s anything sexy or groundbreaking. It’s just one of those “it just works” features that sits in the background minding its own business and doesn’t reveal itself until you really need it.

Here is the first scenario:

You find (or write) a great new plugin and upload it to your /plugins/ directory. You activate it and — oh no. PHP Fatal Error. Someone missed a curly brace somewhere. No problem, you think, that’s what the back button is for. But guess what, the plugin is active, even on the Plugin management screen. Now your entire blog is down as well as the WordPress administration interface. At this point, your only recourse is to FTP in, find the plugin, and delete or rename it.

While that scenario is aggravating enough, it’s nothing compared to the second scenario:

You’re on the road, checking your mail at a computer that’s not your usual computer. You notice an e-mail from someone saying that one of the plugins on your site is misbehaving. You navigate to the Plugin Editing screen in WordPress and quickly correct the problem. Hurray for in-WP plugin editing! But when you click the save button, you get a fatal error. You must have forgotten a semicolon somewhere. And suddenly you realize that you don’t know your FTP password, so the only method you have of editing your plugin is now blocked. And you won’t have access to your main computer for 3 days, during which time your blog will be broken.

If you’ve ever experienced one of the above, you know how annoying it is. So the feature I’ve put into WordPress 2.2 is what I call plugin sandboxing. Before a plugin is activated or a plugin is edited, it is tested in a temporary fashion (that is, without being permanently activated). If it passes the test, it is activated for real. If it doesn’t pass the test (it’s throwing a fatal error that would normally take down your WordPress install), it is deactivated, and you get a nice error message telling you what went wrong. If the fatal error was caused because you edited an active plugin, the “Update File” button changes to “Update File and Attempt to Reactivate,” so that once you correct your typo, the plugin will go back to being activated, without requiring you to go back and manually activate it.

If you never activate a flawed plugin or never make a typo when editing your plugins, you’ll never know this functionality is there. But some day you just might slip up, and now WordPress will cover for you.

Written by Mark Jaquith

February 14, 2007 at 2:44 am

Posted in 2.2, plugins, wordpress

37 Responses

Subscribe to comments with RSS.

  1. Great functionality, good work Mark!

    Lee Kelleher

    February 14, 2007 at 5:19 am

  2. Fantastic functionality addition Mark. This may just be a life saver!

    But, can it be extended to more than plugins? Maybe themes as well?

    Ajay

    February 14, 2007 at 7:35 am

  3. Ajay,
    Fatal errors in themes don’t prevent you from editing them, so this isn’t really needed.

    Mark Jaquith

    February 14, 2007 at 7:39 am

  4. I’m excited about this new functionality! I’ve done your first scenario more than I care to admit, and while a sandbox is no replacement for actually thinking things through, it’s going to help me a ton.

    Sarah Lewis

    February 14, 2007 at 10:57 am

  5. That sounds awesome…it’s almost like your teasing us though because it is a feature many of us would like to have now. ;)

    Ryan Wagner

    February 14, 2007 at 11:30 am

  6. Sounds like an excellent feature! At the moment I tend to use a “sandbox” installation of WP on a sub-domain to test things out before I install them but this should make things even easier.
    Looking forward to seeing what else you guys can come up with.

    StevieB

    February 14, 2007 at 12:39 pm

  7. [...] at “Mark On WordPress” there is news of an excellent added feature, a plug-in “sandbox” facility: So the feature I’ve put into WordPress 2.2 is what I [...]

  8. nice work

    mozey

    February 14, 2007 at 3:15 pm

  9. Nice, I was hoping this would come about sooner than later… :D

    Will

    February 15, 2007 at 5:34 am

  10. [...] ik nog altijd aan het thrillseeken ben met versie 2.07 van WordPress, lees ik op de weblog van Mark Jaquith over aardige functionaliteit die in versie 2.2 zal worden ingebouwd. Het betreft een zogenaamde [...]

  11. [...] instalaron un nuevo plugin. Pues bien, parece que a partir de la versión 2.2 el CMS tendrá una nueva característica (Plugin Sandboxing) a través de la cual nos advertirá antes de la activación, de que el plugin [...]

  12. Nice.. But i dont know where the link to download it..

    Tguh

    February 16, 2007 at 9:35 pm

  13. [...] Plugin sandboxing will not allow plugins to activate if they break your wordpress blog or cause fatal PHP errors. “Before a plugin is activated or a plugin is edited, it is tested in a temporary fashion (that is, without being permanently activated). If it passes the test, it is activated for real. If it doesn’t pass the test (it’s throwing a fatal error that would normally take down your WordPress install), it is deactivated, and you get a nice error message telling you what went wrong. If the fatal error was caused because you edited an active plugin, the “Update File” button changes to “Update File and Attempt to Reactivate,” so that once you correct your typo, the plugin will go back to being activated, without requiring you to go back and manually activate it.” [...]

  14. Mark.. where the link?

    Tguh

    February 17, 2007 at 6:42 pm

  15. Tguh: WordPress 2.2 isn’t available yet. You’ll have to wait a little while until it is.

    Bon

    February 18, 2007 at 6:22 pm

  16. [...] Mark Jaquith has noted a cool new feature for WordPress 2.2 that some plugin and theme creators are going to love. So the feature I’ve put into WordPress 2.2 is what I call plugin sandboxing. Before a plugin is activated or a plugin is edited, it is tested in a temporary fashion (that is, without being permanently activated). If it passes the test, it is activated for real. If it doesn’t pass the test (it’s throwing a fatal error that would normally take down your WordPress install), it is deactivated, and you get a nice error message telling you what went wrong. If the fatal error was caused because you edited an active plugin, the “Update File” button changes to “Update File and Attempt to Reactivate,” so that once you correct your typo, the plugin will go back to being activated, without requiring you to go back and manually activate it. [...]

  17. [...] nada que se liberara mañana mismo). Uno de los anuncios más recientes lo realizaba ayer mismo Mark Jaquith, comentando la implementación de una función denominada ‘sandboxing‘, que se [...]

  18. [...] Mark zu einer der neuesten upcoming Features für die 2.2er Version: So the feature I’ve put into WordPress 2.2 is what I call plugin sandboxing. Before a plugin is activated or a plugin is edited, it is tested in a temporary fashion (that is, without being permanently activated). If it passes the test, it is activated for real. If it doesn’t pass the test (it’s throwing a fatal error that would normally take down your WordPress install), it is deactivated, and you get a nice error message telling you what went wrong. If the fatal error was caused because you edited an active plugin, the “Update File” button changes to “Update File and Attempt to Reactivate,” so that once you correct your typo, the plugin will go back to being activated, without requiring you to go back and manually activate it. [...]

  19. [...] One feature I’ve just read about has been written by that nice Mark Jaquith. He calls it Plugin Sandboxing – the idea is that when you activate a new plugin, or edit an existing one, it is first activated [...]

  20. [...] Plugin Sandboxing to Test Drive Plugins [...]

  21. [...] caught my eye is Plugin Sandboxing. On more than one occasion I’ve killed my site because a plugin I’ve installed has [...]

  22. [...] Plugin Sandboxing para poder realizar pruebas de módulos/plugins. [...]

  23. [...] Plugin Sandboxing. Τι κάνει αυτό; Με λίγα λόγια κατά την ενεργοποίηση ενός plugin γίνεται έλεγχος αν το plugin μπορεί να τρέξει χωρίς να δημιουργήσει προβλήματα (fatal errors κτλ). Αν όχι, τότε γίνεται αυτόματα de-activate μέχρι να διορθωθεί — μία καλή λύση για όσους συνηθίζουν να τροποποιούν τα plugins μέσα από τον plugin editor του WordPress. [...]

  24. great idea!

    jez

    April 19, 2007 at 8:12 am

  25. [...] implementato phpmailer, formati multipli per feed dei commenti, dall’implementazione del plugin sandboxing, che ci dovrebbe salvare il blog dai plugin mal programmati, tema classico e di default [...]

  26. Now this should be fantastic! It saves us all the trouble of using FTP just to fix a broken plugin.

    Btw, why don’t we offer a direct upload for plugins from the wp-admin itself?

    markku

    April 20, 2007 at 1:32 am

  27. [...] Plugin Sandboxing untuk uji coba plugins sebelum benar² di install di WordPress [...]

  28. Awesome functionality addition Mark!!!

    Thanks so much ;-)

    gidibao

    April 25, 2007 at 7:09 pm

  29. [...] Plugin Sandboxing to Test Drive Plugins [...]

  30. Hi Mark,

    Can you please help me to disable this Plugin Sandboxing feature in 2.2?

    See here; http://wordpress.org/support/topic/118418

    Thanks,
    Halil

    hgurol

    May 20, 2007 at 4:55 am

  31. Halil,

    In WordPress 2.3, it will show the error message to the user (but still refuse to activate the plugin). I think this is the best of both worlds, because you know why the plugin failed, but it doesn’t take your site down.

    Mark Jaquith

    June 26, 2007 at 1:03 am

  32. Yeah, but it doesn’t tell you what the fatal error is. This makes it rather hard for ordinary users to report problems.

    Michael Hampton

    December 6, 2007 at 6:43 pm

  33. Just to clarify what Mark said. In WP 2.3, it WILL show the fatal error message BUT ONLY IF you have PHP display_errors turned on. I guess it’s obvious, but I chased my tail for a while before I finally got it to work.

    Shack Dougall

    February 18, 2008 at 3:50 pm

  34. This version it was really excited. WordPress is the best!

    Gry Logiczne

    September 21, 2008 at 11:02 am

  35. Great website! Thx ;)

    gry

    December 1, 2008 at 2:17 pm

  36. Mark,
    I can’t find the WP Plugin Management Screen link. Can you direct me?
    Thanks,
    Ginger

    helendreamseries

    January 9, 2009 at 9:41 am


Leave a Reply