background image
HomeRecent PostsDrupalSearchTagsRSSContactAboutAccount
Eric.London's picture

If your site uses the admin_menu & menu_breadcrumb modules, you might have noticed something wrong with your page titles on the /user page, similar to this:

# / # <img src="/sites/all/modules/admin_menu/images/icon_users.png" width="16" height="15" alt="Current anonymous / authenticated users" title="Current anonymous / authenticated users" />

The incorrect HTML is being output from the admin_menu in admin_menu.module on line 286, but it's caused from the menu_breadcrumb module.

As a quick solution, I added some code to my theme template.php file in a preprocess_page function to replace the titles.

<?php
function MYTHEME_preprocess_page(&$variables) {
  if (
stripos($variables['head_title'],'icon_users.png')) {
   
$variables['head_title'] = 'User account | ' . variable_get('site_name', '');
  }
  if (
stripos($variables['title'],'icon_users.png')) {
   
$variables['title'] = 'User account';
  }
}
?>

Eric.London's picture

I just encountered a PHP fatal error when running my cron.php:

Fatal error: Call to undefined function timezone_open() in /MYSERVERPATH/httpdocs/sites/all/modules/date/date_api.module on line 607

A quick Google search, and I found the issue is documented here. The solution is to enable the Date PHP4 module. But, this issue does not happen in our production environment, so I decided to compare PHP versions:

# on the production server:
$ php -v | head -1
PHP 5.2.8 (cli) (built: Dec  9 2008 14:03:11)

It turns out, a fully updated installation of Centos 5.2 only supplies PHP 5.1.x. So, I decided to upgrade PHP in my development environment according to this documentation.

I created a new yum repo file:

$ sudo emacs /etc/yum.repos.d/utterramblings.repo

# FILE CONTENTS - START
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
# FILE CONTENTS - END

And, ran another yum update:

$ sudo yum update
# ...snip...
Resolving Dependencies
# ...snip...
Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Updating:
apr                     i386       1.2.12-2.jason.1  utterramblings    257 k
apr-util                i386       1.2.12-5.jason.1  utterramblings    159 k
httpd                   i386       2.2.8-jason.3    utterramblings    2.5 M
mod_ssl                 i386       1:2.2.8-jason.3  utterramblings    314 k
mysql                   i386       5.0.58-jason.2   utterramblings    6.4 M
mysql-server            i386       5.0.58-jason.2   utterramblings     10 M
pcre                    i386       7.6-jason.1      utterramblings    562 k
php                     i386       5.2.6-jason.1    utterramblings    3.7 M
php-cli                 i386       5.2.6-jason.1    utterramblings    2.6 M
php-common              i386       5.2.6-jason.1    utterramblings    481 k
php-devel               i386       5.2.6-jason.1    utterramblings    568 k
php-gd                  i386       5.2.6-jason.1    utterramblings    320 k
php-ldap                i386       5.2.6-jason.1    utterramblings     56 k
php-mbstring            i386       5.2.6-jason.1    utterramblings    1.3 M
php-mssql               i386       5.2.6-jason.1    utterramblings     61 k
php-mysql               i386       5.2.6-jason.1    utterramblings    258 k
php-odbc                i386       5.2.6-jason.1    utterramblings    112 k
php-pdo                 i386       5.2.6-jason.1    utterramblings    159 k
php-pear                noarch     1:1.6.2-1.jason.1  utterramblings    418 k
php-soap                i386       5.2.6-jason.1    utterramblings    342 k
php-xml                 i386       5.2.6-jason.1    utterramblings    316 k
php-xmlrpc              i386       5.2.6-jason.1    utterramblings    130 k
subversion              i386       1.4.4-jason.1    utterramblings    4.3 M

Transaction Summary
=============================================================================
Install      0 Package(s)        
Update      23 Package(s)        
Remove       0 Package(s)        

Total download size: 35 M
Is this ok [y/N]:

After updating all these packages, I checked out my new PHP version:

$ php -v | head -1
PHP 5.2.6 (cli) (built: May  5 2008 10:32:59)

Now, my PHP fatal error has been resolved :)

Eric.London's picture

I recently had to deploy some new code to an old production environment. Like a good doobie, I made all my changes in a local checked out copy of the subversion file system. I did not want to break the production environment, so I copied the entire vhost into my home directory on the server. I tried to execute an svn update command, but it terminated with the message: object of the same name already exists. This means that a file was creating in my development environment (later revision) that was also created in the production environment. When I ran a svn stat command, there were too many additions, deletions, and modifications, so I decided to write a PHP script to compare the directory structure and files of the 2 environments. I used this script to analyze the file system and create a deployment plan...

<?php
// define where all my files are
$path_httpdocs = '/my/first/path/httpdocs';
$path_httpdocs_new = '/my/second/path/httpdocs';

// get a list of files from the 1st location, ignoring subversion folders
chdir($path_httpdocs);
$files_httpdocs = `find . | grep -v \.svn | sort`;
$files_httpdocs = explode("\n", $files_httpdocs);

// get a list of files from the 2nd location, ignoring subversion folders
chdir($path_httpdocs_new);
$files_httpdocs_new = `find . | grep -v \.svn | sort`;
$files_httpdocs_new = explode("\n", $files_httpdocs_new);

// check for file list diffs
$diffs = array_diff($files_httpdocs, $files_httpdocs_new);
sort($diffs);
echo
"### Additions to httpdocs:\n";
print_r($diffs);

// loop through files and check if they are additions
foreach ($diffs as $f) {
  if (
file_exists($path_httpdocs . '/' . $f) && !file_exists($path_httpdocs_new . '/' . $f)) {
   
// copy new addition to new folder
   
copy($path_httpdocs . '/' . $f, $path_httpdocs_new .'/' . $f);
  }
}

// check for file list diffs
$diffs = array_diff($files_httpdocs_new, $files_httpdocs);
sort($diffs);
echo
"### Additions to httpdocs_new:\n";
print_r($diffs);

// do not continue if there are file differences in the 2 directories
if (count(array_diff($files_httpdocs, $files_httpdocs_new)) || count(array_diff($files_httpdocs_new, $files_httpdocs))) {
  echo
"### Clean up file differences before continuing...\n";
  die;
}

// loop through files and check file properties
$diffs = array();
foreach (
$files_httpdocs as $f) {
  if (!
is_file($path_httpdocs . '/' . $f)) continue;

 
// do a diff on the files 
 
$command = "diff \"$path_httpdocs/$f\" \"$path_httpdocs_new/$f\"";
 
$t = `$command`;

 
// if the diff command generated output, store it
 
if (strlen($t)) {
   
$diffs[$f] = $t;
  }

}

// print all the file diffs
print_r($diffs);
?>

Eric.London's picture

I just the following error when loading a large cck node form:

user warning: Got a packet bigger than 'max_allowed_packet' bytes

You can resolve this error by adding a line to your /etc/my.cnf MySQL configuration:
[mysqld]
set-variable = max_allowed_packet=32M

Eric.London's picture

Normally when there is a form input error, Drupal highlights the form input by adding a red border and changing the text color. Unfortunately, nothing happens for checkboxes and radio buttons. Here's a little jQuery to add the error class to the label directly above a set of checkboxes or radios when an error occurs.

<?php
$('form#node-form div.form-item').each(function(){
  var
result = 0;
 
result += $(this).find('div.form-radios input.form-radio.error').length;
 
result += $(this).find('div.form-checkboxes input.form-checkbox.error').length;
  if (
result) $(this).find('label:first').removeClass('error').addClass('error');
});
?>

Syndicate content