I got this error when selecting zen as default theme in a fresh install of drupal 6.4, no contributed or other themes added:
Fatal error: Call to undefined function ctype_lower() in /var/www/localhost/htdocs/drupal-6.4/sites/all/themes/zen/zen/template.php on line 348

Comments

ejk’s picture

I was running into the same thing. When I looked at phpinfo(), I saw that my server's version of PHP had the configuration option '--disable-ctype'. Not sure why you'd ever want to do that.

From http://us.php.net/manual/en/ctype.installation.php:

Beginning with PHP 4.2.0 these functions are enabled by default. For older versions you have to configure and compile PHP with --enable-ctype. You can disable ctype support with --disable-ctype.

The Windows version of PHP has built-in support for this extension. You do not need to load any additional extensions in order to use these functions.

jaguarondi’s picture

Status: Active » Closed (fixed)

Indeed, that was the issue and that's the default setting under gentoo. Thanks for the help and sorry for the noise.

JohnAlbin’s picture

Title: Fatal error: Call to undefined function ctype_lower() » WSOD/Fatal error: Call to undefined function ctype_lower()
Status: Closed (fixed) » Active

Re-opening so others can comment on it.

I was hoping foobar PHP installs weren't common, but I'd like to know what systems/hosting people who have this problem are using.

NapkinSketch’s picture

I posted this in another post, but here is what I have at http://drupal.org/node/310411

Issue is on all 6.x versions of the Zen theme.

Line 250 of template.php in the /zen folder.

if (!ctype_lower($string{0})) { // Don't use ctype_alpha since its locale aware.
$string = 'id' . $string;
}

I commented out this line and my theme began to work perfectly, and not result in the white screen of death on pages beyond the homepage. I am not a php coder so I dont know how critical the line of code is, but I think it requires some investigation as this issue seems to be wide spread. Simply commenting this line of code out works and I have seen no ill effects of it.

This is similar to the bug reported on the main Zen download page.
Note:
There seems to be a conflict between some host installations of the SiteZen site builder and the Zen directory name. If you experience this problem, change the name of the 2 theme directories from "zen" to "Zen" and you should be back in business (i.e. zen/zen becomes Zen/Zen). More about this issue here. http://drupal.org/node/91335

None of these solutions worked for me, such as renaming the theme or changing to capital letter. Also noted, this is my very own servers on SuSE linux 10.01 running Apache/PHP (front end) and MySQL (Backend). I dont have cpanel nor sitebuilder as noted in the noted issue 91335.

JohnAlbin’s picture

Sorry, Mark, I should have been more explicit.

The PHP you are using has been specially compiled to NOT include a standard library of PHP. See #1 above.

Can you tell me what hosting provider you are using? or, if you are self-hosting, what server software you are using?

dostergaard’s picture

I just ran across this thread when I was looking for a solution to this very problem.

I am running Drupal on my own Gentoo Linux server. By default Gentoo builds PHP without the ctype library enabled. The first reply here clued me into this. There is a bug filed for it (see http://bugs.gentoo.org/117492).

My solution was to put the necessary USE flag in the the package.use file and re-emerge PHP. It took about 10 minutes to rebuild then I restarted apache and the problem was solved.

In my case the commands were . . .

$ su -
# echo "=dev-lang/php-5.2.8-r2 ctype xml" >> /etc/portage/package.use
# emerge php -Dvta
# /etc/init.d/apache2 restart

If a hosting provider is hosting on Gentoo and they're unaware of the default build behavior for PHP then they would need to do something similar to the above to fix it.

- Dean

1fotograf.ru’s picture

I have a working replacement for the buggy line which preserves script's functionality exactly but does not require any libs. Just change the line to

if((ord($string)<ord('a'))||(ord($string)>ord('z'))) {

and it's fixed. I don't think it's optimal, but it works. Should it be fixed in dist?

aturetta’s picture

In FreeBSD php is modularized, and to get ctype_lower() and friends you have to install port textproc/php5-ctype.

Ciao,

T27drupal’s picture

Component: Code » PHP Code

Woohoo!!
1fotograf.ru's code change suggestion for zen themes worked for me.

I found the offending code in themes/zen/zen/zen/template.php (note all the zen subdirs)

JohnAlbin’s picture

Title: WSOD/Fatal error: Call to undefined function ctype_lower() » Remove ctype_lower() from zen_id_safe() to prevent WSOD/Fatal error on some systems
Status: Active » Fixed

1fotograf.ru's code doesn't work for extended latin character which are valid css class characters, even though extended latin characters aren't valid ID characters.

For 6.x-2.x, we're going to go with this solution: #624046: Replace zen_id_safe() with drupal_html_class() and drupal_html_id()

But for 6.x-1.x, I think we should just remove the entire validation for “If the first character is not a-z, add 'id' in front.” Hopefully, CSS authors will know not to start classes with numbers; and if they do and the class doesn't work, they'll figure it out. This goes in line with the “we don't babysit broken code” dicussed in #464862: Add drupal_css_class() to clean class names and rename form_clean_id

I've removed this code from zen_id_safe():

  // If the first character is not a-z, add 'id' in front.
  if (!ctype_lower($string{0})) { // Don't use ctype_alpha since its locale aware.
    $string = 'id' . $string;
  }

Fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.