Block visibility PHP crash protection

iantresman - June 21, 2008 - 13:20

If I create or modify a block snippet in a block's "Page specific visibility settings", I could crash my Drupal set-up on displaying the faulty block code.

If I am not careful, I might not be able to re-edit the block contents, since the code will continue to crash the installation. What's the best way to ensure I can isolate and correct bad block code snippets?

Use a test site.

Cayenne - June 21, 2008 - 13:26

Use a test site.

Sure, but even that seems

iantresman - June 21, 2008 - 14:04

Sure, but even that seems inefficient, having to re-install Drupal each time I make a silly PHP synatax error. For example:

  • A "test" user account, so that the error appears only to the test user, but does not appear to an Admin, who can correct it?
  • The Demonstration site (Sandbox) module
  • The Druplet module "an on-demand Drupal sandbox generating machine"

I just thought that maybe someone had some experience of these, and could highlight some pros and cons.

This is a great idea. The

cog.rusty - June 21, 2008 - 18:14

This is a great idea. The way Drupal handles bad code in a block feels like a critical core bug. But I have no idea how it can be fixed. Does PHP have any "test-eval" function?

But on the other hand that could be expensive, with all the queries usually run by blocks.

Test in new site but thats

Elita - June 21, 2008 - 23:25

Test in new site but thats gerrat !

http://forum.pcgames.ir

Solution

iantresman - June 23, 2008 - 23:43

Try as I may, I was unable to crash Drupal 5.7 by inserting bad PHP code into the "PHP block visibility settings" section.

To be on the safe side, I created a test account, and ensured that the new block was visible only to the "Test" user. I was able to log-in to my site under two different account names, by using Firefox and MS Internet Explorer (actually the MS IE Tab add-on for Firefox)

Failing to return 'true' may

cog.rusty - June 24, 2008 - 00:33

Failing to return 'true' may not be a mortal sin after all. Try bad code in the block content itself.

By the way, today while I was playing with some PHP code in Drupal 6 (although in a node, not in a block) I noticed that bad code was causing the "PHP input format" to be automatically unselected. I didn't check with a block, but progress may have been made after all.

 
 

Drupal is a registered trademark of Dries Buytaert.