Today I had to do some support on a Drupal 6 website and when I tried to refresh a CSS file, all the themes disappeared. When going to the theme page, nothing in the list at all. Not even the core themes.

This is a Drupal 6.x website and I am running it on my current development system which runs PHP 7.x among other things.

Why would my theme disappear like that?

Note: I tried clearly all the cache tables and click on the "Clear all Caches" and the caching is turned off in the Performance screen (so that way I know it's not that creating problems.)

  • I'm voting to close this question as off-topic because it is not about the official Drupal code.
    – apaderno
    Sep 20, 2016 at 16:33

2 Answers 2


I don't know specifically why your themes disappeared, but the requirements page for Drupal (https://www.drupal.org/docs/7/system-requirements/overview) states:

Drupal 6: PHP 5.x only (5.2.5 or higher recommended). Warning: support for PHP 4.x has been dropped. Drupal core should work with PHP 5.3.x, but PHP 5.3.x and higher may produce errors or unexpected behavior especially for contributed modules and themes.

PHP 7 is definitely not supported. You will likely find many more errors than this over time.

  • Oh yeah, I already fixed 3 or 4 others. It's just to do some work for a client. No time to create a computer with just PHP 5.x... I do not just have a spare computer to do that, that is. Sep 18, 2016 at 1:31
  • 1
    ... What? Why do you need a spare computer to install PHP?
    – Kevin
    Sep 18, 2016 at 1:46

After a couple of hours looking at the code, I finally found the problem:

There is a function in file.inc that uses preg_match() with a pattern where no delimiters are added. Whoever was maintaining that line of code, just put a '@' in front of it, instead of properly adding the delimiters.

There is the offensive line (around 1095):

elseif ($depth >= $min_depth && @ereg($mask, $file)) {

Note: The correct line says @ereg() which does not require the delimiters, so when I changed that to preg_match() so it works with PHP 7, the delimiters became required.

(Notice the @ character in there? Even with PHP 5 you'd get some kind of error message on that line without it!)

The $mask variable is a regular expression, but all are missing the delimiters (for example: "\.info$" to search for the theme.info files.)

There is my proposed fix. I just add "/" before and after the mask, and just in case, escape any slash that would be appearing inside the name.

elseif ($depth >= $min_depth && preg_match('/' . str_replace('/', '\\/', $mask) . '/', $file)) {
  • Hacking around core is not a fix. Best to use PHP 5.x.
    – Kevin
    Sep 18, 2016 at 1:45
  • He! He! I've been hacking around Core since I started. It's just not perfect... I do not know how (if at all possible) to run two versions of PHP on the same computer. So I have 7. Sep 18, 2016 at 1:50
  • Actually, Drupal 6 is using elseif ($depth >= $min_depth && @ereg($mask, $file)) {. So, the code you show has been edited from somebody, and it is not the original Drupal 6 code.
    – apaderno
    Sep 20, 2016 at 16:31
  • @kiamlaluno Ah, that could explain the lack of delimiters. ereg() has not been valid for a very long time, even in PHP 5.x, but was removed in PHP 7 so I must have changed it when I upgraded my OS to 16.04... Sep 20, 2016 at 17:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.