I just installed the latest 6.2 and everything was working great until I created a block that had some php code in it.

Here's what happened:
1. I enabled the PHP filter
2. I created a custom block for the right side
3. I put some php code in that runs some OpenX ads (see below)
4. I saved the block (PHP filter option was checked) - the code worked fine.
5. I went back to make a change to the same block and could not save it - validation error
6. I tried to edit an existing post and make a new post - validation error
7. I tried to delete my custom block with PHP - validation error
8. I tried removing the PHP filter option from the main modules - validation error
9. I tried changing the PHP code in the block to nothing - validation error
10. I disabled my ad campaign in OpenX, now when I edit a post I get a validation error AND the following error:

"user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY fit DESC LIMIT 0, 1' at line 1 query: SELECT * FROM menu_router WHERE path IN () ORDER BY fit DESC LIMIT 0, 1 in /home/mydir/public_html/includes/menu.inc on line 315."

Basically the only think I can do now is login. No new posts or editing can be done.

Here is the PHP code that broke everything:

<?php
 /* <!-- OpenX XML-RPC Tag v2.4.5 -->
  *
  * As the PHP script below tries to set cookies, it must be called
  * before any output is sent to the user's browser. Once the script
  * has finished running, the HTML code needed to display the ad is
  * stored in the $adArray array (so that multiple ads can be obtained
  * by using mulitple tags). Once all ads have been obtained, and all
  * cookies set, then you can send output to the user's browser, and
  * print out the contents of $adArray where appropriate.
  *
  * Example code for printing from $adArray is at the end of the tag -
  * you will need to remove this before using the tag in production.
  * Remember to ensure that the PEAR::XML-RPC package is installed
  * and available to this script, and to copy over the
  * lib/xmlrpc/php/openads-xmlrpc.inc.php library file. You may need to
  * alter the 'include_path' value immediately below.
  */

    //ini_set('include_path', '.:/usr/local/lib');
    require 'openads-xmlrpc.inc.php';

    if (!isset($OA_context)) $OA_context = array();

    $oaXmlRpc = new OA_XmlRpc('mydomain.com', '/openx/www/delivery/axmlrpc.php', 0, false, 15);
    $adArray = $oaXmlRpc->view('', 0, '', '', 0, $OA_context);

    echo $adArray['html'];
?>

Any ideas?

-Sean

Comments

seanlee’s picture

This isn't the proper "fix" for this bug (bug is http://drupal.org/node/240828), but it got me my site back.

For me, I entered some offending php code into a custom block. So what I did was go into the MySQL database using phpmysql and to a search for the custom block name I made (mine was called Showcase). It poped up a few places - but the place I was concerned about was inside the table called "boxes." I went into the body of that table and sure enough, the PHP code I had entered was there.

So I removed the PHP code and entered "test" instead and saved the table. This allowed me to go into my block admin area in Drupal and finally delete (ore re-edit) and save the block properties. This is obviously a bug, and should be fixed. But at least this is a temporary work-around to get the site out of "read-only" mode.

-Sean

silverguy’s picture

I was able to find it in Cpanel as you suggested by searching for the block name and edited as you said in the theme that was running it.
Was able to get it functioning again in 5 mins with your suggestion. This section needs a error check to enable rollback for any errors which prove to be toxic.

shiggi7’s picture

I had exactly the same problem - your post saved me. The Javascript invocation code in Openx seems to be the only one that doesn't break Drupal.

Scott

blueblade’s picture

My site has the same problem...

I installed CCK and created about 10 forms with quite a lot of fields, I dont know why but all fields are showing up as a block on the block page...I have about hundred of those now...should I check each of them? I dont remember I have added any php code to any of them....

can you please further explain how you did it? sorry I have zero programming knowledge and am new to mysql

Thank you for your help.

Skelly1983’s picture

Had same problem when i tried to upload delegator module from ctools without ctools so i could us anouther module that depended on delegator, when i enabled the module it must have caused problems and i recieved this error, so have disabled it and everything is back to normal

Anarchist.Quaker’s picture

I registered for this drupal.org just so I could post this comment. I was sweating blood and was having a heck of a time finding useful posts searching through Google. I found your post and was able to fix the site in a few minutes!

cindyr’s picture

You're awesome! My problem was with PHP code too. I was using custom php code to return values for a cck checkboxes field. My php code was bad, which I knew, but it caused errors all over the site. I went back and deleted the php code from the allowed values list, and the site started working again. Phew! You just saved me untold hours of angst!