Since the theme can now be initialized without the database, I'd like to make the maintenance pages themable, and move the maintenance specific stuff into garland.

Changing the maintenance theme will require making a change in settings.php and I think profiles should also be able to specify the maintenance theme.

It should be possible to discover a theme without the database just with its name, so:

$conf['maintenance_theme'] = 'garland';

Using drupal_system_listing on the themes directories, we can find garland pretty easily and read its .info file. (In fact, we can probably add an argument to system_theme_data to ignore the system table entirely...or break up the function so that the part that doesn't need the database is handled independently, and that part can move into theme.inc)

drupal_maintenance_theme() can, then, discover the theme based upon the name, load the abbreviated registry. We could possibly go an additional step and specifically mark theme functions that don't require the database, but I think that should probably only be done as a documentation issue. i.e, create a maintenance theme @group and @ingroup theme implementations that can be used during maintenance (to make it easy to tell).

Once that's set up, the existing maintenance themes just need to be converted to use the newer philosophies. They're actually fairly close, since they do a bunch of variables settings and call out to templates already.

I intend to work on this as I have time, but I dunno how much time I have. Discussion on the topic is welcome.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dvessel’s picture

subscribing

Anonymous’s picture

You can already hook these functions in your theme. I forget now where I found out. When I run across it again I'll post. But you basically just garland_maintenance_theme, i.e. replacing the drupal_ part of the function with your themes name.

Anonymous’s picture

Look at theme_maintenance_page API documentation.

So,

function phptemplate_maintenace_page($content, $messages = TRUE, $partial = FALSE) {

...

}

and the Maintenance Page has your themed maintenance page.

merlinofchaos’s picture

Earnie, what are you talking about? Drupal always calls theme_maintenance_page or theme_install_page or the like, never theme('maintenance_page') or theme('install_page'). You're confusing things.

add1sun’s picture

subscribe

Anonymous’s picture

@merlinofchaos: Sorry, that is often the case. The title misled me to think the track that I did especially in light of the fact that I went searching for ways to themeize the site maintenance UI and that is what I came up with. I haven't done too much with theme coding but looking at the theme() API documentation I now know what you are after. I'll look further at the API and see what else I can think of.

Anonymous’s picture

For a little more clarity of what I was talking about in my first post I'm posting the entire phptemplate_maintenance_page() function I used for an antique_white theme. This gives the site maintenance page the theme to match the site. So if the same function for the garland them existed then the Site Maintenance page would be themed to the garland theme.

function phptemplate_maintenance_page($content, $messages = TRUE, $partial = FALSE) {
  drupal_set_header('Content-Type: text/html; charset=utf-8');
  drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() .'themes/antique_modern/style.css";</style>');
  drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() . drupal_get_path('module', 'system') .'/defaults.css";</style>');
  drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() . drupal_get_path('module', 'system') .'/system.css";</style>');
  drupal_set_html_head('<link rel="shortcut icon" href="'. base_path() .'misc/favicon.ico" type="image/x-icon" />');

  $output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
  $output .= '<html xmlns="http://www.w3.org/1999/xhtml">';
  $output .= '<head>';
  $output .= ' <title>'. strip_tags(drupal_get_title()) .'</title>';
  $output .= drupal_get_html_head();
  $output .= drupal_get_js();
  $output .= '</head>';
  $output .= '<body>';
  $output .= ' <div id="head">';
  $output .= '  <div id="site-name">' . variable_get ('site_name', 'Drupal') . '</div>';
  $output .= '  <div class="site-slogan">' . variable_get('site_slogan','') . '</div>';
  $output .= '  <div id="menu"></div>';
  $output .= ' </div>';

  if ($messages) {
    $output .= theme('status_messages');
  }

  $output .= "\n<!-- begin content -->\n";
  $output .= '<div id="body_wrapper">';
  $output .= '<div id="body">';
  $output .= '<div id="subhead"></div>';
  $output .= '<div id="all">';
  $output .= ' <div class="top"></div>';
  $output .= ' <div class="content">';
  $output .= '  <div id="main">';
  $output .= '   <div class="breadcrumb"><a href="/">Home</a> &raquo; <span class="title">' . drupal_get_title() . '</span></div>';
  $output .= '   <div class="tabs">';
  $output .= $content;
  $output .= '   </div>';
  $output .= '  </div>';
  $output .= ' </div>';
  $output .= '</div>';
  $output .= '</div>';
  $output .= ' <div class="bottom"></div>';
  $output .= '</div>';
  $output .= '<div id="end_body"></div>';
  $output .= "\n<!-- end content -->\n";

  if (!$partial) {
    $output .= '<div id="footer"></div>';
    $output .= '</body></html>';
  }

  return $output; 
}
dvessel’s picture

earnie: Yeah, the maintenance page can be themed but that would depend on the db being setup and active. Merlins' proposal bypasses the need for a db.

+1 to the idea. I've tried some crazy hacks to get this done before and I've seen others too attempt it too. They are all dirty.

Anonymous’s picture

I don't get it. The DB must be setup before the pages can be displayed. You do the install, you create the first account, you go to the administration page and set the site in maintenance mode and your done. If the garland theme already contained the phptemplate_maintenance_page it would be themed. So the change needs to happen with the theme/garland/template.php file.

merlinofchaos’s picture

The maintenance theme includes all of the installer pages.

So it is more than just the "Site is in maintenance mode" page. The DB may not exist for several of the maintenace pages (including "OH MY GOD YOUR SITE IS HOSED error messages, which *must* be themeable, IMO, for corporate sites).

Anonymous’s picture

I get it now. Site up for months or years and the DB crashes. Now pages are not served except in limited form. So we need a method to identify JEOPARDY_MAINTENANCE and display the Site Maintenance page. Since this may happen with multi-site setup a DB crash can affect more than one site. Does sites/all/settings.php get loaded, if not we could cause that to happen and define JEOPARDY_MAINTENANCE and display the Site Maintenance if set. For individual sites that may have corrupted tables where the outage is localized to the one site the JEOPARDY_MAINTENANCE would be defined in the site/mysite/settings.php file. Then change the bootstrap process to check it. The value of JEOPARDY_MAINTENACE could be the value of the theme, true or false.

merlinofchaos’s picture

Status: Active » Needs review
FileSize
43.81 KB

Finally, here's a patch. This does everything I really wanted this patch to do:

1) It promotes maintenance.tpl.php into a proper template, maintenance_page.tpl.php
2) It sets aside he maintenance theme code into maintenance.inc to make it easier to identify and can be conditionally loaded, since the maintenance theme isn't needed most of the time.
3) I had to move part of system_theme_data into the includes, and I also didn't want THAT to be loaded all of the time, so I made a theme.admin.inc -- I have to imagine more stuff can go into this, though nothing came up. We already do this with some other less used APIs as well.

This can be easily tested: copy maintenance_page.tpl.php into garland and modify. Or copy it into your theme, go to settings.php and set $conf['maintenance_theme'] = 'garland' (or the name of your theme). You will need to copy or symlink it to install_page.tpl.php to get the install page version. (I'm not sure how well the install page can even be themed, since no settings.php exists at that point. Further investigation into allowing the a profile to set the installer theme might be necessary).

I'm particularly proud of this piece of work. Corporate sites want to protect their branding. Since Steven made it even possible to theme the maintenance stuff, this advance makes it possible for sites to protect their branding when their site goes into maintenance mode.

Note that unrelated to this, I've discovered that maintenance mode currently does not work on HEAD. This is true with or without this patch.

add1sun’s picture

Well I went ahead and applied this and played around a bit. As for testing it is sort of hard to really see much with maintenance mode broken but I did change some stuff up on the install_page.tpl.php and it worked great. No errors or other funny business.

I think it would be a good idea for there to be some documentation perhaps on the Site Maintenance page that says you can customize this by blah blah blah.

This is one of those things that just bugs the crap out of a themer so I'm excited about this getting in along with the other cool theming changes.

merlinofchaos’s picture

Maintenance mode has been restored, so it may now be tested as well. Since that mode didn't exist in Drupal 6, obviously I've done very little testing on it with this patch (actually none yet, as I haven't gotten back to it).

http://drupal.org/node/146937

Also, dmitrig01 did some testing on the patch and all worked as advertised, but he didn't post his results here. SO that's another successful test. I think that means we can probably RTBC this soon.

merlinofchaos’s picture

FileSize
42.19 KB

Result of my own code review, now that I've had a couple of days of distance. Fixed several minor code problems.

add1sun’s picture

Latest version of HEAD - the patch applies with a few offsets but then I get WSOD on install.php and also when trying to do update.php from an older version of HEAD. Reversing the patch let's me proceed. :( Also applying the patch after install and setting the site to maintenance mode gives WSOD as well.

So, I went ahead and applied the patch and copied garland's page.tpl.php to be maintenance_page.tpl.php on a successfully installed (that is just fresh HEAD) site and maintenance mode "worked" but was plain HTML with errors:

    * warning: include(./includes/maintenance_page.tpl.php) [function.include]: failed to open stream: No such file or directory in /Users/addi/Sites/test/includes/theme.inc on line 615.
    * warning: include() [function.include]: Failed opening './includes/maintenance_page.tpl.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /Users/addi/Sites/test/includes/theme.inc on line 615.

I also did the same (copy page.tpl.php) for the install_page.tpl.php and the installation worked (as well as the maintenence mode) BUT my modified template file (having a I'M AN INSTALL PAGE header) did not show. Just the standard install/maintenance page.

Now that I am sufficiently confused, hopefully you are not. :p

merlinofchaos’s picture

FileSize
44.42 KB

maintenance_page.tpl.php somehow got left out of the last page.

Getting the installer to use a different theme is al ittle different, because there is no settings.php. It turns out, though, that it's super easy. At the beginning of the .profile, right after the // $id line, just do this:

global $conf;
$conf['maintenance_theme'] = 'themename';

That'll automatically switch the installer to your theme.

I tried it with bluemarine which makes one hellaciously ugly installer theme, but it works.

add1sun’s picture

Yep, that does the trick. So nice to be able to edit the maintenance page just like anything else. Kudos!

merlinofchaos’s picture

Status: Needs review » Reviewed & tested by the community

I believe this is ready to go.

Dries’s picture

I think this looks OK. The only thing I'm not sure about is theme.admin.inc (vs theme.inc). I'd actually prefer to put that in a separate patch after some more discussion. The maintenance.inc seems reasonable to me though.

Steven’s picture

If the patch says:

+    // Fall back to Garland. If Garland doesn't exist, they've deleted files
+    // they should not have and this will crash horribly and that is not our
+    // problem.

... why is the Garland maintenance_page.tpl.php still in the includes directory rather than in the Garland directory?

merlinofchaos’s picture

Actually, I think the only reason it will crash horribly is because there's no theme, so the object it's looking for will have no information at all. It's entirely possible that we could dummy something up to keep things working there, but it seems like a waste of code.

Even though the default installer is using Garland's style, it made more sense to keep the maintenance page tpl with Drupal itself rather than having it live in the theme.

Dries: The main reason for theme.admin.inc here is that a bunch of code is getting moved from system.module to theme.inc and I was growing concerned with how much code a minimal bootstrap was being forced to load. I can undo that and still all the code in theme.inc anyway, if you really want, but if anything I'd say an extra step there would be accomplished similarly be taking this version and then analyzing if we need to tweak it. I've tweaked it as much as I think I can right now. (Ok, and selfishly, it'd be extra work that I'm 100% sure no one else will do =)

eaton’s picture

Just wanted to come in and give a HUGE +1 to this. Drupal is being used in more and more high-profile sites, where "what happens when there's an error" must be carefully managed and controlled as much as the everyday situations. In addition, the rise of distributions and profiles means that branding and/or massaging the install experience is important as well. I know of three clients we've had who required core hacks to achieve this functionality on their sites.

This is much needed. +1. Would RTBC if it weren't already. ;)

merlinofchaos’s picture

Dries: Is what's holding this up that I balked on folding theme.admin.inc back into theme.inc? I can do that and create a new issue to split it up again, if that's the only roadblock here.

dvessel’s picture

Status: Reviewed & tested by the community » Needs work

Is this going in? As it currently stands, the notes on theme_maintenance_page mentions that the function is *not* themeable but it's a registered function. Seems like it can be overridden.

And it's a bit odd that maintenance.tpl.php is inside the /misc folder for HEAD. Patch doesn't apply anymore. Tried to re-roll but the changes are too big.

merlinofchaos’s picture

Since this sat RTBC for 2 months, and we're well past codefreeze now, I don't see any point in rerolling this without getting a core committer in here to say it's worth spending time on.

dvessel’s picture

Status: Needs work » Needs review
FileSize
7.01 KB

I discovered that the maintenance is indeed not overridable. This is a serious regression.

What this patch does is let themers override and it also *does not* depend on the database to function.

I tried to keep it as simple as possible. Only the theme_maintenance_page() function + maintenance.tpl.php file were affected.

The way it works now is this. A handful of directories are checked for.

1. sites/example.com/maintenance
2. sites/default/maintenance
3. misc

From there the maintenance.tpl.php, style.css, logo and favicon.ico is checked for. If no overrides are found then the default behavior is maintained. Minnelli is also checked as a fallback for the logo and style.css.

dvessel’s picture

Priority: Normal » Critical

This is critical IMO.

dvessel’s picture

Category: task » bug

And a bug..

dvessel’s picture

Title: Allow maintenance theme functions to be themable » Regression: Allow maintenance to be themable
dvessel’s picture

I was informed by greggles that this would not get in unfortunately.

Here's another anyway just to fix which folders are checked.

1. sites/example.com/maintenance or sites/default/maintenance. Wherever it's installed.
2. sites/all/maintenance -changed from sites/default/maintenance
3. misc

greggles’s picture

I believe this regression is actually part of http://drupal.org/node/117018 which changed the doxygen to say "note - not themeable"

I don't see in the discussion where it explains why those shouldn't be themeable, though.

dvessel’s picture

Status: Needs review » Needs work

Thanks for the pointer Greggles,

It looks like there's a bigger issue with viewing the maintenance page. The registry doesn't read from the db and even weirder is that the coded registry doesn't return proper results.

Here's an example from "page" when viewed in maintenance mode:

"page"]=>
  array(4) {
    ["arguments"]=>
    array(3) {
      ["content"]=>
      NULL
      ["show_blocks"]=>
      bool(true)
      ["show_messages"]=>
      bool(true)
    }
    ["template"]=>
    string(4) "page"
    ["function"]=>
    string(10) "theme_page"
    ["theme path"]=>
    string(4) "misc"
  }

Expected results.. Note that I removed page.tpl.php from garland to show what gets registered outside the theme.

["page"]=>
  array(6) {
    ["arguments"]=>
    array(3) {
      ["content"]=>
      NULL
      ["show_blocks"]=>
      bool(true)
      ["show_messages"]=>
      bool(true)
    }
    ["template"]=>
    string(19) "modules/system/page"
    ["type"]=>
    string(6) "module"
    ["theme path"]=>
    string(14) "modules/system"
    ["theme paths"]=>
    array(1) {
      [0]=>
      string(14) "modules/system"
    }
    ["preprocess functions"]=>
    array(2) {
      [0]=>
      string(19) "template_preprocess"
      [1]=>
      string(24) "template_preprocess_page"
    }
  }
merlinofchaos’s picture

Ok, this is a bit of an ugly bug in that it means that maintenance page stuff can't be moved into template_preprocess functions because for those to work, the registry *must* go through the discovery process and not just use the current hack where it simply returns the basic results from drupal_common_themes.

I'm not exactly sure what to suggest on this one. I, for one, would really like to see this get fixed in Drupal 6, because I think it is a major problem that maintenance pages can't be themable even though it's fairly easy to do so.

But to do it, you're going to have to restore my code from my original patch that processes the theme registry in a database-safe (i.e, no db available) manner.

dvessel’s picture

Well, never mind that. I thought it still went through _theme_build_registry even without a db.

Either the patch I posted can be accepted or the _theme_load_registry has to be reworked so it works with and without a db connection. Not sure what to do there.

dvessel’s picture

@merlinofchaos, Yeah, that looks like a lot of work and it'd take me forever to figure out.

dvessel’s picture

Assigned: Unassigned » dvessel

I decided to tackle this in a better way. Closer to what Merlinofchaos had in mind but I'll try change as little code as I can. I have a better idea now after a little IRC chatting.

Senpai’s picture

Subscribing.

dvessel’s picture

I'm still trying to get this done. It's not easy, and sorry for the delay.

xmacinfo’s picture

Subscribing

chx’s picture

dvessel, try to share the ideas and whatever code you have. let us help.

dvessel’s picture

Status: Needs work » Needs review
FileSize
44.08 KB

Chx:

This definitely needs work but marking CNR just to get your and other opinions.

The patch works. Maintenance page is themable in situations where the site is explicitly set into offline mode. It also works when the database is dead but in order to use a custom theme when the databse is dead, you have to set the 'maintenance_theme' key for the $config array inside your settings.php file.

The theme registry is built only one way. Previously, it would go off on an alternate route to rebuild a custom registry just for the off line page. Now it just builds it anew when the db can't be touched. This is done with the new function "db_is_active()".

The install and update pages will always default to Minnelli.

The function list_theme_engines() has been removed. It seems to serve no purpose since the engine information is already attached to $theme->info. It's counterpart to save the theme engine information into the database was also removed from system_theme_data().

It needs more loving. I've spent too much time on this already so if anyone want's to jump in, it'd be great.

dvessel’s picture

I mean I'll jump back on this later. I'm not abandoning it. :)

dvessel’s picture

FileSize
44.88 KB

Forgot to remove theme_maintenance_page which was replaced with the preprocessor.

Another note, the maintenance template and style sheets where moved to modules/system/ and it's based on the default page.tpl.php file. Previously, it was based on the markup from garland. So, the minnelli maintenance page was added inside Minnelli folder since that's the default.

BioALIEN’s picture

subscribing

jleider’s picture

Subscribing

keith.smith’s picture

Status: Needs review » Needs work

I'm pretty certain there is an existing issue in the documentation component queue for some of these strings, which I'll find and mark as a duplicate of this issue.

I know none of these items -- or very very few of them -- are changes in this patch, but can some string cleanup happen here:

Can this:

We were unable to find any installer profiles. Installer profiles tell us what modules to enable and what schema to install in the database. A profile is necessary to continue with the installation process.

Be something like (change person):

An installation profile was not found. An installation profile provides important configuration data to the Drupal installer, and is required to continue the installation process.

There are several instances where an error message says something similar to this example:

For more help, see the Installation and upgrading handbook. If you are unsure what these terms mean you should probably contact your hosting provider.

Can that last sentence (on all those instances -- there are a bunch of them) be just (no "should probably"):

If you are unfamiliar with these terms, contact your hosting provider.

Where the error messages use "We", like in (change person):

We were unable to use the MySQL database because the MySQL extension for PHP is not installed. Check your PHP.ini to see how you can enable it. For more help, see the Installation and upgrading handbook. If you are unsure what these terms mean you should probably contact your hosting provider.

Is there another alternative?

Just:

The MySQL extension for PHP is not installed. Check your PHP.ini file for information on enabling it. ...

"

Or

We were able to connect to the MySQL database server (which means your username and password are okay) but not able to select the database.

to something like:

A successful connection was made to the database server, but the database could not be selected.
Gábor Hojtsy’s picture

I looked through the patch. Some comments:

- I agree that misc/maintenance.tpl.php and misc/maintenance.css are not well placed, so these could use some move to a more proper place (system module possibly). Their dependency on Minnelli is also evident. I see this patch does add a generic maintenance page and then a minnelli themed one.
- Why not make distinct themes for the install, update, error and offline maintenance pages, reusing the generic theme if no specific is available? That would save us from redoing lots of stuff around the install and update system, which there is no intention to make themeable as it seems, and admittedly, they should not be themeable for consistency.
- There is lots of stuff changed in the patch, both external and internal APIs.
- There was no progress on this issue for weeks.

Let me remind you that this issue is in the critical queue for Drupal 6 which means that as it stands now a Drupal 6 release is hold back in part by this issue. If there is no intention in pursuing this feature anymore, we can close the issue, or move to D7 if there is no progress to be done here in the D6 timeframe.

I agree that restoring the themeability of the maintenance page is desired, and I hope it will be doable in D6, but the release should not be hold back if there is no interest in pushing this forward.

dvessel’s picture

Status: Needs work » Needs review
FileSize
46.73 KB

Everyone.. I'm sorry for the delay. I've been swamped with work.

Gábor, It now uses distinct themable function for update, install and maintenance but it shared a good deal of code.

theme_maintenance_page is a templated function while update and install are both "regular" functions but they tap into template_preprocess_maintenance_page to keep all the variables consistent. Also the variables in there mirror what's available inside the normal "page" hook. Again, for consistency.

A new template suggestion is also made available when the database is off-line. This allows the maintenance page to swap the content entirely so site visitors don't see db errors.

dvessel’s picture

BTW, while testing this you may run into a notice about trying to get a property of non-object while installing. It's not due to this patch. system.install uses the "t()" function all over the place before the global $language is available.

Dries’s picture

Priority: Critical » Normal
+  else {
+    // Force the maintenance theme only when the database is not on-line and
+    // the settings.php file is configured for it. When the database is active,
+    // it will automatically use the active theme.
+    $conf['theme_default'] = variable_get('maintenance_theme', 'minnelli');
+  }

I'm not sure this comment reflect reality. The active theme is something different from the 'maintenance_theme' not? Why should there be a maintenance theme when we're able to load the active theme?

The part in the code where you processes the theme_registry when the database is inactive, could use more documentation. It wasn't instantly clear what was going on in that code or why it matters. It could do with more verbose documentation (that is non-obvious).

+ /* Add favicon */ should be + // Add favicon

I'm not sure I'd quality this issue as 'critical'. Regression or not, critical issues are issues that prevent your Drupal installation from working.

dvessel’s picture

I'm not sure this comment reflect reality. The active theme is something different from the 'maintenance_theme' not? Why should there be a maintenance theme when we're able to load the active theme?

Dries, that's just passing in what's set inside settings.php when the db is inactive. It must use 'theme_default' so it properly initializes the theme within init_theme().

drupal_maintenance_theme() is run in only these cases:
1.) install page. -to force Minnelli.
2.) update page. -the same as install.
3.) db dies. -to read what's set as the 'maintenance_theme'.

When the site is set to off-line mode and the db is working, drupal_maintenance_theme() isn't run (I removed it). drupal_site_offline() is called and the theming system is intact so it will work without problems.

I'll get a patch up shortly.

dvessel’s picture

FileSize
48.1 KB

Okay, _theme_load_registry_offline() was moved into the main _theme_load_registry(). I realized it wasn't needed. Not sure if the docs are what you wanted in here. Hope it makes sense.

The other issues I changed. the comments using /* */ was simply copied from template_preprocess_page() so I changed that too to what you suggested.

ksenzee’s picture

Subscribing. Would this be possible to backport, or is it 6.x specific?

dvessel’s picture

ksenzee, the theming system between the two versions is very different so it won't happen.

Any further feedback would be nice. Dries, Gábor: if there's anything else in here that doesn't seem satisfactory then please tell me. I'll try to clarify or fix it ASAP.

And anyone else looking over this, please review and verify that it works.

eaton’s picture

Status: Needs review » Needs work

This may have been broken by the recent requirements changes, but when the patch is applied, error messages and notices during the installation process no longer appear. That's pretty critical since it means people get no indication of why they can't install. I'm taking a look to see if I can track it down but am not sure I'll have time to fix it.

dvessel’s picture

Eaton, I accidentally flipped the 'show_message' flag to false inside theme_install_page(). That's a simple fix.

I'm in the process of reworking some areas so I'll roll it into the next patch.

dvessel’s picture

Status: Needs work » Needs review
FileSize
48.09 KB

The previous patch would use the currently selected theme when in offline mode. I changed this since some themes might not be setup for it and break the layout completely.

In drupal 5, it had to be themed explicitly, so, it's the same in here. First the theme must be explicitly enabled for off-line mode but this time it must be set through settings.php + the theme overrides if the theme needs it.

Pure CSS themes would just have to enable it through settings.php since the markup from maintenance-page.tpl.php and page.tpl.php is very similar.

I also moved alot of the functions into a new theme.maintenance.php.

eaton’s picture

Status: Needs review » Reviewed & tested by the community

Just took this through its paces and it deals gracefully with a dead database and other similar situations. The approach appears to be clean and tidy, and I know of a number of our clients who will be thrilled that occasional DB issues don't result in a big splatter of 'stock theme' over their carefully tailored site branding...

dvessel’s picture

FileSize
47.81 KB

Great Eaton! Thanks for your time. :)

Minor doc cleanup on this one but it's exactly the same.

Oh, and did I mention that theme inheritance work too now? Not sure I did. It was restricted before.

So if we wanted, we can clean up Minnelli a bit so it inherits Garlands styles instead of importing them. I think there was a problem with that.. Not sure. My mind has been on another project.

Thanks for your patients.

Gábor Hojtsy’s picture

Given the size and timing of this change, I wrote Dries a mail to check back and review the patch. I definitely like this feature being kept, and proposed fixing this in other issues, but at the same time, the D6 release process went ahead a lot in the meantime.

sun’s picture

A huge +1! As mentioned before, corporate websites can't live without this.

/**
 * Enables use of the theme system without requiring database access.
 */
function drupal_maintenance_theme() {

Added one-line descripiton (API).

/**
 * Note: This setting does not apply to installation and update pages.
 */

Added this note to settings.php and moved phpdoc block right in front of the setting.

Was list_theme_engines() in theme.inc intentionally removed? Just curious. There is no reference in core.

Note: I don't know how to remove files in a local working copy, so I wasn't able to remove misc/maintenance.css and misc/maintenance.tpl.php in this patch.

Anonymous’s picture

Note: I don't know how to remove files in a local working copy, so I
wasn't able to remove misc/maintenance.css and misc/maintenance.tpl.php
in this patch.

The only method I know of is to create a local repository and issuing the ``cvs remove ...'' command.

Gábor Hojtsy’s picture

Earnie: Grrrhm.
Earnie, sun: read the docs! http://drupal.org/patch/create

sun’s picture

Sorry for being dumb. Let's get back to focus.

merlinofchaos’s picture

Goba: While this is not as flashy of a usability improvement as drag & drop, this really qualifies as an important one for a serious target market of Drupal; that is, large, high profile sites who are very keenly interested in retaining their brand identity. It can be a big deal when something breaks and suddenly a million people see the Druplicon rather than whatever corporate logo should've been there.

Also, work on this started long, long ago, but stagnated for several months awaiting responses. It's always unfortunate when that happens.

Gábor Hojtsy’s picture

merlinofchaos: Maybe you have not seen but I have even postponed some API modifying drag and drop issues, before Dries came and "approved" them (getting them back to the 6.x queue), and also put a now RTBC looking drag and drop issue to his consideration because of the same reasons: big API breaking changes without Dries' prior approval. That's not about how flashy an issue is but how late it is going to be applied in the cycle. I did not receive privileges to say yes to these without consulting Dries.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

I reviewed this patch, found it nice for my taste, and wrote Dries an email yesterday afternoon, but did not receive a reply since then. Dries seemingly being mostly out of time to review bigger patches now, I slept one more on this patch, and being a low level issue which is not at all possible to fix in contrib, I decided to commit it.

Please understand that I am trying to watch the best interest of the community, and that sometimes conflicts with the interest of (your) customers. I would not like to offend highly valued people who work hard on completing a big fix they think is important. But at the same time I would not like to offend others who postponed their important fixes to D7 understanding that the community needs to agree on common rules on deadlines and focusing on stabilizing what is already there instead of looking into what is missing, to have a release in a reasonable timeframe. Additionally I do not like to provide grounds for finger pointing like "but you accepted drag and drop patches, and ours is just as important" (as demonstrated above) or "but you accepted the maintenance theming patch". This can go on forever if the focus is not agreed on.

So much for the background. As I said, I liked what I have seen in this patch, and would love to see you fine folks in the criticals issue queue (http://drupal.org/project/issues?projects=3060&versions=97368,184399,175...), now that this is resolved. There is a nice small theming bug there which would fly if you would take a look and approve / comment on the suggested fix: http://drupal.org/node/194026 (although all the other issues are just as interesting).

Thanks for all your time making Drupal 6 better, it is all highly respected.

Gábor Hojtsy’s picture

Status: Fixed » Active

OK, this made the install theme buggy when the site is already installed, but the DB is not populated. Reproduce:

- install Drupal
- drop the database
- create the database empty
- visit install.php

All you get is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>Choose language | Drupal</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/profilednd/misc/favicon.ico" type="image/x-icon" />
    <link type="text/css" rel="stylesheet" media="all" href="/profilednd/modules/system/defaults.css" />
<link type="text/css" rel="stylesheet" media="all" href="/profilednd/modules/system/system.css" />
<link type="text/css" rel="stylesheet" media="all" href="/profilednd/modules/system/system-menus.css" />
<link type="text/css" rel="stylesheet" media="all" href="/profilednd/modules/system/maintenance.css" />
        <!--[if lt IE 7]>

This is an edge case, but might uncover other bugs introduced with this. Previously, the installer was possible to be used to populate the tables when the DB was cleaned as said above. Not good.

With display_errors = TRUE:

<br />
<b>Warning</b>:  Table &#039;installer.system&#039; doesn&#039;t exist
query: SELECT * FROM system WHERE type = &#039;theme&#039; in <b>/Users/gabor_h/Desktop/Websites/installer/includes/database.mysqli.inc</b> on line <b>167</b><br />
<br />
<b>Notice</b>:  Undefined index:  minnelli in <b>/Users/gabor_h/Desktop/Websites/installer/includes/theme.maintenance.inc</b> on line <b>61</b><br />

<br />
<b>Notice</b>:  Trying to get property of non-object in <b>/Users/gabor_h/Desktop/Websites/installer/includes/theme.inc</b> on line <b>93</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in <b>/Users/gabor_h/Desktop/Websites/installer/includes/theme.inc</b> on line <b>390</b><br />
<br />

<b>Notice</b>:  Trying to get property of non-object in <b>/Users/gabor_h/Desktop/Websites/installer/includes/theme.inc</b> on line <b>390</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in <b>/Users/gabor_h/Desktop/Websites/installer/includes/theme.inc</b> on line <b>390</b><br />
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /Users/gabor_h/Desktop/Websites/installer/includes/database.mysqli.inc:167) in <b>/Users/gabor_h/Desktop/Websites/installer/includes/common.inc</b> on line <b>141</b><br />

<br />
<b>Warning</b>:  Table &#039;installer.system&#039; doesn&#039;t exist
query: SELECT * FROM system WHERE type = &#039;theme&#039; in <b>/Users/gabor_h/Desktop/Websites/installer/includes/database.mysqli.inc</b> on line <b>167</b><br />
<br />
<b>Notice</b>:  Undefined index:  minnelli in <b>/Users/gabor_h/Desktop/Websites/installer/includes/theme.inc</b> on line <b>881</b><br />

<br />
<b>Notice</b>:  Trying to get property of non-object in <b>/Users/gabor_h/Desktop/Websites/installer/includes/theme.inc</b> on line <b>893</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in <b>/Users/gabor_h/Desktop/Websites/installer/includes/theme.inc</b> on line <b>902</b><br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>Choose language | Drupal</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/installer/misc/favicon.ico" type="image/x-icon" />
    <link type="text/css" rel="stylesheet" media="all" href="/installer/modules/system/defaults.css" />
<link type="text/css" rel="stylesheet" media="all" href="/installer/modules/system/system.css" />
<link type="text/css" rel="stylesheet" media="all" href="/installer/modules/system/system-menus.css" />
<link type="text/css" rel="stylesheet" media="all" href="/installer/modules/system/maintenance.css" />
        <!--[if lt IE 7]>
      <br />

<b>Fatal error</b>:  Call to undefined function  phptemplate_get_ie_styles() in <b>/Users/gabor_h/Desktop/Websites/installer/themes/garland/maintenance-page.tpl.php</b> on line <b>23</b><br />
dvessel’s picture

Great! this is finally in. :)

Previously, the installer was possible to be used to populate the tables when the DB was cleaned as said above. Not good.

Wow, I never knew this. I'll look into this edge case..

Gábor, thanks for your hard work.

dvessel’s picture

The problem is with how list_themes() was modified. The patch does a check with db_is_active() so simply dropping the tables is not caught.

Looks like I'll have to revert list_themes() and separate out the part listing the themes without calling the database. It'll be a simple fix.

dvessel’s picture

Status: Active » Needs review
FileSize
733 bytes

Well, I opted to just check for the table. Not sure it's the best way to go.

list_themes() is called in many places but the call from theme_get_settings() prevented me from reverting list_themes.

Gábor Hojtsy’s picture

Status: Needs review » Fixed

Great, this looks sensible to me. Thanks for the fix, committed.

sun’s picture

Status: Fixed » Needs review
FileSize
807 bytes
1.19 KB

If list_themes() is called in many places, we should perhaps cache the database check. (first patch)

Or, at least add some notes to this non-obvious check. (second patch)

merlinofchaos’s picture

Please understand that I am trying to watch the best interest of the community, and that sometimes conflicts with the interest of (your) customers. I would not like to offend highly valued people who work hard
on completing a big fix they think is important. But at the same time I would not like to offend others who postponed their important fixes to D7 understanding that the community needs to agree on common rules on
deadlines and focusing on stabilizing what is already there instead of looking into what is missing, to have a release in a reasonable timeframe.

Goba: Sorry if I came off as upset about this one; when I read your comment I felt that this patch was teetering on the brink, and was trying to make a case that it should go in. I am still a little upset about this patch from way back, as I had the original patch RTBC for 2 months before the initial code freeze, and it was ignored. So if there's a deadline that was never met, it wasn't on my part; I had the original in well in advance, with a cushion for going back and making necessary changes, but without any real understanding of what changes needed to be made, nothing happened. It is at that point that frustration set in. I had actually emailed Dries directly about this patch, and he said he would look at it...and still no new commentary came.

All that said, my comment was not intended to reflect that frustration, but my belief that this patch is just as big of a usability enhancement as some of the drag & drop stuff that's going in. This one has been in process for a long, long time, and I felt that given your comment about maybe/maybe not, I wanted to add a little push toward 'yes, please commit'.

dvessel did a good job of redoing the whole thing from scratch and getting something workable in; I actually had quit working on it, myself, once the code freeze was well past, so at this point I am merely being a cheerleader for dvessel's hard work.

dvessel’s picture

The theme list is already cached so caching the db check isn't needed. It's only checked once unless it needs a refresh.. not a common thing.

More docs the better but I still don't think that's clear.

... + if settings are configured but database is empty.

Now one would ask, why would this situation arise? I know now but if I didn't I'd have no clue.

merlinofchaos’s picture

sun: I like patch #1 -- the caching makes sense.

merlinofchaos’s picture

Er. Ok, posted too soon. I withdraw my comment based on dvessel's. =)

sun’s picture

@dvessel: I regularly encounter this situation when "re-setting" a local Drupal test site, for example. This is all about an edge case, absolutely. So I'd say, it's sufficient to just explain why we're doing this second check without giving any other reason than the one included in the patch.

webernet’s picture

Priority: Normal » Critical
Status: Needs review » Active

This broke updates badly.

Gábor Hojtsy’s picture

webernet: Please elaborate. I tried to run update.php (although without actual updates to run) and seen the progressbar go through to 100%, and then a message that my site is up to date, just as before. I would not commit this patch, if there would be an obvious bug which does not need explanation.

webernet’s picture

- First load of update.php throws a fatal error.

<!--[if lt IE 7]>
Fatal error: Call to undefined function phptemplate_get_ie_styles() in /themes/garland/maintenance-page.tpl.php on line 23

- Not all updates are run -- only those for system module.

- Updates fail at system update 6027.

An HTTP error 200 occurred. /update.php?id=1&op=do
Gábor Hojtsy’s picture

Uh, huh. This could very well be closely related to the "developer edge case" I found. The error message is the same. Seems like although the database is set up, the system table is there, this code does not play nice with the tables not updated yet. Basically, it should use the file based theme code, not the database based theme code.

system_update_6027() looks like modifying both the global $theme and $custom_theme, and although $theme is restored, $custom_theme is not. So the theme is modified in the update code, and again, that breaks the update. Looks like the $custom_theme needs to be restored.

dvessel’s picture

Crap.. it's because of the use of module_list() inside _drupal_maintenance_theme(). It needs to be more selective.

It's needed for off-line mode and dead db's. install.php repeats that function. I didn't realize that update cannot have it run that way.

Sorry.. patch coming right up.

dvessel’s picture

Status: Active » Needs review
FileSize
6.57 KB

Okay, I tested and it works for me.

Removed all the redundant calls to drupal_maintenance_theme() from install.php also. All the install functions go through install_main() so this is safe.

The db table check from the previous fix was swapped for the "MAINTENANCE_MODE" constant. Just to be on the safe side, have it read from the file system even when updating.

I also had to add in $theme->status to prevent notices. It didn't happen before due to the order it was run. Without it, notices occur from system_menu() where it registers theme config paths.

dvessel’s picture

Status: Needs review » Needs work

er, broken on install..

dvessel’s picture

Status: Needs work » Needs review
FileSize
7.44 KB

I mean, revisiting the install page after it's already been installed caused a fatal error..

Works now.

Gábor Hojtsy’s picture

Awaiting some testing. Would love to see what webernet has to say on this.
Edit: funny crosspost. :)

webernet’s picture

#87 seems to fix things for me after a quick test. Needs further testing/review though.

Gábor Hojtsy’s picture

Status: Needs review » Fixed

I tested this on a 4.6 -> 6 upgrade which worked before this patch (yes, 1 have 2(!) custom modifications in the update code to make this run well, and a few lines of DB preparation SQL code). Also worked with the patch, so it seems the update is fixed. Committed, thanks.

Senpai’s picture

Hooray for all of us on this one. Good work, gang!

dvessel’s picture

Indeed.. I only wish I could have been more focused. Bad timing when Merlin rolled his original patch and now. I wasn't around when it initially appeared but all wasn't lost since I learned from his example. Not exactly the same but still, it gave me a clue.

Time to let this issue die, finally..

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

Dave Cohen’s picture

Version: 6.x-dev » 5.x-dev
Assigned: dvessel » Unassigned
Category: bug » feature
Priority: Critical » Minor
Status: Closed (fixed) » Needs review
FileSize
470 bytes

I hope it's OK etiquette to resurrect this thread. I wrote about this issue on the developer's email list and I wanted to post my patch somewhere. I submit it for consideration for Drupal 5.x, but I understand if this get's resolved as won't fix, since it appears to be addressed differently in Drupal 6.

My problem is that I needed the maintenance pages to be custom branded, especially when the database is unreachable. The attached patch to bootstrap.inc solves the problem. With the patch in place, I can write something like the following in my settings.php. This gives me control of the maintenance pages.


$conf['custom_maintenance_theme'] = 'custom_maintenance';

function custom_maintenance_maintenance_page($content, $messages = TRUE, $partial = FALSE) {
  // My custom code goes here (replaces theme_maintenance_page from theme.inc)
}
dvessel’s picture

It looks reasonable but the install and update pages could have problems with custom themes. Accounting for that would require further changes. Alas, it is a feature so I doubt this would happen.

Anonymous’s picture

Version: 5.x-dev » 6.x-dev
Category: feature » bug
Priority: Minor » Critical
Status: Needs review » Closed (fixed)

Please create a new issue.

webchick’s picture

Version: 6.x-dev » 7.x-dev
Status: Closed (fixed) » Active

hook_system_info_alter() was never documented. Please fix.

dvessel’s picture

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

Aren Cambre’s picture

Looks like this patch may have caused a new issue: http://drupal.org/node/281997

EDIT: Disregard. Further investigation suggests a function provided by the result of this issue may be the first victim of a different bug and not a cause of the problem in the other issue.