When Seven is used as the install theme (#547068: D7UX: use Seven for installation / updates), I noticed that messages are not shown, for instance when form values do not validate. The reason is that the $show_messages variable is not set during the installation process. I think that $show_messages should not be checked at all in maintenance-page.tpl.php (just like minnelli). Patch attached.

Comments

Status: Needs review » Needs work

The last submitted patch failed testing.

marcvangend’s picture

Status: Needs work » Needs review
StatusFileSize
new628 bytes

@testbot: I'm sorry.

Status: Needs review » Needs work

The last submitted patch failed testing.

cweagans’s picture

Status: Needs work » Needs review
StatusFileSize
new856 bytes

It was missing the -p flag.

marcvangend’s picture

Status: Needs review » Needs work

Disregard #4, cweagans kindly rerolled it, but against page.tpl.php instead of maintenance-page.tpl.php.

cweagans’s picture

Status: Needs work » Needs review
StatusFileSize
new801 bytes

Just noticed that. This one is against the maintenance page.

marcvangend’s picture

StatusFileSize
new635 bytes

Dear testbot, here is a new patch, now with -p flag and unix line endings. Thank you for your patience :-)

marcvangend’s picture

LOL
@cweagans: I thought you went to sleep?

cweagans’s picture

Well ya' know....I code in my sleep sometimes. I actually got called back to my workstation to quickly deploy a Drupal site that I built this morning and I noticed emails coming in =P

Status: Needs review » Needs work

The last submitted patch failed testing.

marcvangend’s picture

Status: Needs work » Needs review
StatusFileSize
new801 bytes

I still don't get it. Re-submitting cweagans' #6 to see if that does pass the test.

yched’s picture

Status: Needs review » Needs work

No go. update.php uses this variable to ensure messages are not displayed on batch progress pages, where they'll be overlooked, but delayed at the end of the process.

marcvangend’s picture

Status: Needs work » Needs review

@yched: OK, so in that case, Minnelli was "wrong" all this time for not checking for the $show_messages variable? Anyway, if the check for $show_messages is needed, we should set $show_messages = TRUE for the installation process.

yched’s picture

Oops, I was too quick:
template_preprocess_maintenance_page() does:

$variables['messages']          = $variables['show_messages'] ? theme('status_messages') : '';

So it seems that the $show_messages variable is indeed irrelevant in the template itself.

marcvangend’s picture

I'm probably missing something, but here is what I don't understand:
The code in template_preprocess_maintenance_page() means that $message will only have a value (and return TRUE in an if statement) if $show_messages is TRUE.
In that case, this line of code in maintenance-page.tpl.php
<?php if ($show_messages && $messages): ?>
would be checking if (TRUE == TRUE), right?

yched’s picture

Not exactly. template_preprocess_maintenance_page() makes it so that $messages will never be true if $show_messages is false.
So if ($show_messages && $messages): is logically equivalent to if ($messages): .

It looks as if the logic of checking $show_messages has been moved up into the preprocessor at some point, but the template not updated accordingly.

Note that garland's page.tpl.php, and seven's page.tpl.php and maintenance-page.tpl.php all check $show_messages, so the 3 of them should be fixed, I think. system.module's own page templates (i.e Stark) just print $messages.

webchick’s picture

Priority: Normal » Critical

This is pretty bad. :P

marcvangend’s picture

@yched #16: I understand. Maybe my explanation wasn't clear enough, but that's exactly my point. If <?php if ($show_messages && $messages): ?> is logically equivalent to <?php if ($messages): ?>, then why would the patch solve the problem?

marcvangend’s picture

Title: Messages not shown in installation process » Incorrect template logic around $messages
StatusFileSize
new2.49 KB

OK I found it. The key to understanding the messages in the installation process is in theme.maintenance.inc, function theme_install_page(), around line 133:

  // Delay setting the message variable so it can be processed below.
  $variables['show_messages'] = FALSE;
  // Variable processors invoked manually since this function and theme_update_page()
  // are exceptions in how it works within the theme system.
  template_preprocess($variables, 'install_page');
  template_preprocess_maintenance_page($variables);
  template_process($variables, 'install_page');

  // Special handling of error messages
  $messages = drupal_set_message();

That means that the messages for the install pages are not processed in template_preprocess_maintenance_page() at all, but in theme_install_page().

I think we can be sure that $show_messages is always processed correctly before the tpl.php is processed, so $show_messages should never be checked in a page template. I'm attaching a new patch which corrects this in both Seven and Garland. (Fingers crossed, I think this patch will pass! :-))

marcvangend’s picture

StatusFileSize
new2.47 KB

One more patch; in garland/page.tpl.php, print $messages doesn't need to be wrapped in an if-statement at all.

marcvangend’s picture

Title: Incorrect template logic around $messages » No messages in install / template logic for $messages

(just a better title)

chx’s picture

Status: Needs review » Reviewed & tested by the community
  $variables['messages']          = $variables['show_messages'] ? theme('status_messages') : '';

in page preprocess already deals with this var so no need to use it in the template.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Awesome work! Not only does this fix a bug, it cleans up the template files significantly!

Committed to HEAD. :D

marcvangend’s picture

Nice, thanks everyone. Now we only have to do #638430: Error in error message not readable so the error message will actually be readable :-)

Status: Fixed » Closed (fixed)

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