Lucid Lynx and Drupal 5
Introduction
If you are a Drupal lover like us or not, it could not have escaped you that Drupal doesn't function very well in Lucid Lynx the reason is neither Drupal's fault nor Ubuntu. The fault lies this time with PHP (PHP Hypertext Processor) Lucid Lynx uses LAMP (Linux, Apache, Mysql, PHP). Many components around Drupal, Linux and Apache core are updated often and in some case regularly PHP is one such component. PHP have thrown a wobbler big time as many drupal 5 sites which run on Linux sites and specificly Ubuntu Lucid Lynx 10.04.1 and above use PHP 5.3 which is incompatible with Drupal 5.23 or under. Many of you would have seen large quantities of if not errors then warnings.
The problem can be compounded when during transition of website the drupal 5 site or sites break to text on the open page for no apparent reason. It is at this point, we have identified that your database(s) has become corrupt if you backup your databases regularly you can restore from a know good backup, if not then you indeed have a problem.
We can not predict what may appear on your website page but it is possible that your page may show a flood of what appears to be text, if this appears after a database upgrade the "update.php" function may have something to do with it. We at SoSLUG have spent considerable time correcting this problem but even more time understanding what is going on.
Drupal 5 - What to do if your site shows errors or warnings
This is difficult to establish as each situation is different but if you are displaying errors associated with "eregi" then it is possible your PHP version is Version 5.3. The Drupal core community has any number of suggestions to fix or prevent this problem one method is by ignoring it. The kind of errors you want to eliminate are those that interfere with the visual display experienced by your intended audience and those that interfere with your production of the site.
As I am not a PHP programmer I can not tell you very much other then the fact that PHP in their infinite wisdom have deprecated the use of "ereg" and "eregi" and perhaps a hold load more, these are the ones that have so far surfaced and therefore need be addressed. This article will look at ways you can fix your Drupal 5 site but before we do, we should establish what version of PHP you are running.
Your drupal site should be sitting on a remote server hopefully with Apache. Finding out the exact version of the various aspects of your server can be hard, it is especially hard if your Drupal site has crashed. There are a number of things you can do to find out more about your server and the applications that run on it "phpinfo()" is one such tool.
If all your virtual drupal sites have crashed
Create a php file on your server or directory that stores your drupal site you can call it anything you like but something like "serverandphpinfo.php" in this case which might be appropriate. You need but one string of text inside it so you can just copy and paste.
<? phpinfo() ?>What this function should do is display server and PHP information in the form of a table starting first with the server and following on to some details of PHP elements and of course Mysql. To activate this function you need to call it, if you have placed the file some where in the root of your website the syntax might be
"http://websitename.com/serverandphpinfi.php" place this in your browser url (Uniform Resource Locator) if you are managing sites then we assume you know what this is.Displayed in this form is significant information relating to the Server it is sitting on the SQL Server the Apache Server and the PHP versions you are using.
Howto fix your Drupal Code for Version 5
Let me be perfectly clear we are talking about a fix that Drupal themselves have not yet brought out a patch for it is conceivable they will or may not release a patch that fixes this problem if the do well you won't need this fix.
Warning please make a backup accidents happen and an error in this code can modify your database so ensure you backup the file you intend to edit and the database it relates to restore from an known good backup if text is displayed on your webpage first. Also ensure you have cleared recent history from your browser otherwise you may get false results.
We need modify not replace to files on Drupal version 5 the first is the theme file "page.tpl.php" it is more likely the fault within this page will effected by your menu, if you are using a theme based on bluemarine the original default drupal theme you may find errors or warnings appear on many of the visitor and administration pages (Pretty much you will see messages all the time regardless of user). As this is visible to your website guests and visitors this is something you want addressed. Here is a small section of the page.tpl.php
>?php $dapath = $_SERVER["REQUEST_URI"]; if (eregi("/*.learning",$dapath)) { $sect = "learning"; }elseif(eregi("/*.about",$dapath)){ $sect = "about"; }elseif(eregi("/*.reserch",$dapath)){ $sect = "research"; }elseif(eregi("/*.projects",$dapath)){ $sect = "projects"; }elseif(eregi("/*.events",$dapath)){ $sect = "events"; }elseif(eregi("/*.research",$dapath)){ $sect = "research"; }elseif(eregi("/*.words",$dapath)){ $sect = "words"; }elseif(eregi("/*.links",$dapath)){ $sect = "links"; }elseif(eregi("/*.freemedia",$dapath)){ $sect = "freemedia"; }elseif(eregi("/*.login",$dapath)){ $sect = "login"; }else{Ok this is customised code therefore you wouldn't see it in standard bluemarine theme but this is based on this theme so if you have based your website on this theme or have used "eregi" you may have seen the problem we speak of. Anyway
eregi — Case insensitive regular expression match Descriptionint eregi ( string $pattern , string $string [, array &$regs ] )
This function is identical to ereg() except that it ignores case distinction when matching alphabetic characters.
WarningThis function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.
If you have customised your site using this function you need to change it with a substitute fortunately one exists called preg_match here is the function description below. preg_match — Perform a regular expression match Report a bug Description int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] )
Searches subject for a match to the regular expression given in pattern.
Parameters patternThe pattern to search for, as a string.
If your code within page.tpl.php looks nothing like the example I have shown you may need to trawl through Drupals own Community Support section for an answer.
The fix for this code is this
>?php $dapath = $_SERVER["REQUEST_URI"]; if (preg_match("/^.*learning/",$dapath)) { $sect = "learning"; }elseif(preg_match("/^.*about/",$dapath)){ $sect = "about"; }elseif(preg_match("/^.*reserch/",$dapath)){ $sect = "research"; }elseif(preg_match("/^.*projects/",$dapath)){ $sect = "projects"; }elseif(preg_match("/^.*events/",$dapath)){ $sect = "events"; }elseif(preg_match("/^.*research/",$dapath)){ $sect = "research"; }elseif(preg_match("/^.*words/",$dapath)){ $sect = "words"; }elseif(preg_match("/^.*links/",$dapath)){ $sect = "links"; }elseif(preg_match("/^.*freemedia/",$dapath)){ $sect = "freemedia"; }elseif(preg_match("/^.*login/",$dapath)){ $sect = "login"; }else{This now has fixed the problem with messages displaying as we browse the site for the guest user. Now we need to address the production side of the problem on some of the administration pages accessed by admins and editors of the site to correct this problem we need to modify "file.inc" in the includes folder of drupal core. This one to correct we still use the "preg_match" function as a replacement this time to the function ereg without the "i" on the end.
elseif ($depth >= $min_depth && ereg($mask, $file))Is replaced by this line in includes/file.inc elseif ($depth >= $min_depth && preg_match("/$mask/", $file))
You may still see some Boolean errors or warnings on the some of pages accessed by administrator but as these are not generally visible by the general public and they are few in number these can be ignored.

