While inverstigating #464556: Installer requirements check doesn't appear we found that #310467: Slimmer hook_theme() had broken the installer because drupal_function_exists was unable to include a file with a required theme function because we where in MAINTENANCE_MODE.

The attached patch provides a possible solution to this(as well as an alternate fix for #464556: Installer requirements check doesn't appear) by providing a hook modules can use to setup a basic registry during MAINTENANCE_MODE.

Comments

Anonymous’s picture

Issue tags: +Registry

adding registry tag.

webchick’s picture

Hm. I'm not sure about this...

It's introducing a registry hook. But only for SOME functions, not all of them. And worse, the way that you register functions here is entirely different than how you register functions in things like hook_theme(), which normally is the only place you need to registr theme functions. I thought ftheme_... was a typo, but it turns out that's how you have to do it. :\

I'm trying to envision what the API docs for hook_maintenance_registry() looks like that does not involve lots and lots of head-scratching, and am having a really hard time...

webchick’s picture

Mind you, I'm also not a huge fan of "just move it to theme.maintenance.inc!" proposed at #464556: Installer requirements check doesn't appear since that obviously won't work for contrib. But I wonder if there's a way we can do something like this without needing to expose module developers to the inner-workings of the registry.

neclimdul’s picture

StatusFileSize
new3.77 KB

I got a similar sentiment from chx on irc. I started working toward a more complicated hook and it just got more and more of a mess the more I tried to make it developer friendly.

So, I've tried a bit of a different approach. It also ends up providing additional functionality to people really interested in breaking^w changing things with a full blow alter hook on the registry. To better support this I've expanded the lookup cache to be split out into a structure instead of the compressed key previously used that caused some confusion.

neclimdul’s picture

PS - chx suggested the original hook provide a list of files that will always be included in main mode. I think that will probably end up being its own mess with confusion arising around which maint mode we're in and if the db is available. This might still exists a little in the current patch but its also should be something that can be managed at the alter level.

Status: Needs review » Needs work

The last submitted patch failed testing.

Anonymous’s picture

+  return $lookup_cache[$type][$name] = FALSE;

looks like a typo.

+  drupal_alter('registry', $lookup_cache);

this will get called on every cache miss, which could be expensive. is there a way to do this once per registry build, or at least, once per request?

webchick’s picture

Ok. Call me wacky, but why don't we just include_once 'modules/system/system.admin.inc' before the theme function call in install.php?

neclimdul’s picture

Status: Needs work » Needs review

Bah, aparently the interaction with this and the db system is pretty hairy because it happens when drupal_alter isn't available sometimes and other times when registered modules aren't available so the alter actually fails calling functions that don't currently exist...

I'm not really sure how to deal with this ATM.

johnalbin’s picture

subscribe

moshe weitzman’s picture

I'm not seeing a great solution here either. I think we should fix the installer quickly in #464556: Installer requirements check doesn't appear. this issue is gonna take a while.

catch’s picture

This looks like a pain. I remembered it'd already been discussed before somewhat in http://drupal.org/node/332303#comment-1143991 although that's a very far reaching solution (even if it's just backing up the registry).

chx’s picture

StatusFileSize
new1.35 KB

So what was the problem with the files hook?

webchick’s picture

Well, the first problem is:

Fatal error: Call to undefined function drupal_get_path() in /Users/webchick/Sites/core/modules/system/system.module on line 2347

Status: Needs review » Needs work

The last submitted patch failed testing.

chx’s picture

Status: Needs work » Needs review
StatusFileSize
new1.5 KB

Pffft, i meant theoretically, not the actual implementation, that's a miniscule detail.

chx’s picture

StatusFileSize
new1.5 KB
Anonymous’s picture

this looks good, i'm happy with the idea. one typo:

+ * Provide a list of files to be incldude during maintenance mode.

should be 'included' not 'incldude'.

chx’s picture

StatusFileSize
new1.5 KB
Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

patched my install with the #19, no more notice on the requirements page. RTBC.

webchick’s picture

Status: Reviewed & tested by the community » Needs review

Minor things:

drupal_get_path
theme_status_report

Let's get trailing ()s there so that they hot-link on api.drupal.org.

Non-minor things:

Documentation needs work. Let's flesh out the use case for this hook a bit (under what circumstances does Drupal get into maintenance mode?) and why you might need to use it (providing a theme function which must be called during installation is one. are there others?).

webchick’s picture

Status: Needs review » Needs work
sun’s picture

chx pointed me here. I'll have a look this.

sun’s picture

Since this issue can only be replicated with the patch in #310467-26: Slimmer hook_theme(), I've posted a new patch over there (different approach though). As mentioned over there, I need to know whether I should go back to chx's hook approach.

sun’s picture

Status: Needs work » Closed (duplicate)

Let's move this over there?