Posted by SeanBannister on September 28, 2009 at 10:23am
| Project: | Drupal core |
| Version: | 6.x-dev |
| Component: | file system |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
I've noticed when Imagecache creates a new directory it displays a message to the end user "The directory * has been created."
Is there anyway to hide this message as the end user really doesn't need to know that the directory was created.
Comments
#1
Looking for the same issue …
#2
I'd love to see this option too, but after looking through the code I don't see any way to accomplish it without hacking the Drupal core.
From what I can tell, the message is being generated by the core drupal function file_check_directory() in file.inc. (see http://api.drupal.org/api/function/file_check_directory/6)
The message does go through the t() function though, so it may be possible to use one of the translation routines to replace the message with something else.
I'd love to be proven wrong here. :-)
#3
Shawn is right, unfortunately there is nothing we can do about it... until D7, which removed this annoyance.
#4
You can't use string replacements in this case. The only way I've achieved it is:
/**
* Override theme_status_messages() for last minute hack.
* It should be possible to simply return nothing.
*/
function mytheme_status_messages($display = NULL) {
$output = '';
$messages = drupal_get_messages($display);
foreach ($messages as $type => $messages) {
$output .= "<div class=\"messages $type\">\n";
$output .= " <ul>\n";
// This is where you need to check if the message is from imagecache and suppress it.
foreach ($messages as $message) {
$output .= ' <li>'. $message ."</li>\n";
}
$output .= " </ul>\n";
$output .= "</div>\n";
}
return $output;
}
#5
I simply commented out the line in the file.inc and it works fine
#6
This page: http://www.appnovation.com/can-we-modify-drupal-status-messages
includes a more complete example. I found it very helpful and am using it on my site.
#7
Attaching core patch that replaces all drupal_set_message() calls with watchdog() calls in that function.
Hope it helps someone.
#8
Let's try this. I think it's a bug and moving messages into watchdog shouldn't hurt anyone.
#9
subscribe
#10
I found a way to hide these messages using the String Overrides module. The string that needs replacing is:
The directory %directory has been created.Find a more detailed explanation in this blog post.
#11
Applied patch from #7 successfully.
It's quite annoying to have this kind of messages on a production site.
The place for this is inside the watchdog table.
#12
It's possible as well to workaround this by Drupal Tweaks module and hide specified message.
#13
I understand you are not entirely happy with some background actions omitting strange messages on the page. However, we should figure out where core / major contrib uses these and intend to show the user a message and act on displaying messages in that case. An API function displaying messages to the user is not a good idea.
Also, bugs should be fixed in D7 first (if applicable). Looks like @smk-ka says this is not applicable to D7, do I understand that right?
#14
Exactly – see file_prepare_directory().
#15
shubshcribe.
#16
Gábor Hojtsy,
Filefield (or Imagecache) uses the function so this affects really LOT of sites. I don't understand what else is needed ? Setting back to NR because of this.
#17
sub
#18
subscribe
#19
The last submitted patch, file_check_directory_watchdog.patch, failed testing.
#20
Tested the patch and attached a version that not triggers the D7 test bot.
#21
+1 for this change. It's frustrating when you use a token in a filefield path (such as sites/default/files/photos/[uid]).
I think what Gábor is asking is, are there places where this message is actually expected? If so, the appropriate form submit function would need to be updated with a drupal_set_message.
In this case, I'm not sure there is ever a legitimate need for this message. The functions that call file_check_directory are color_scheme_form_submit, drupal_build_css_cache, drupal_build_js_cache, file_check_path, system_check_directory, system_theme_settings, upload_form_alter, user_admin_settings, _locale_rebuild_js. None of them jump out as requiring this message.
#22
Actually the one time when it is useful is in system_file_system_settings(), i.e. the File System settings page.
#23
subs +1
#24
Yes, as discussed, we still need to ensure to have feedback at places where the user should be informed the directory is created. I think system_file_system_settings() is a good example. I did not do a full audit of places where this would be useful, but I'm still vary of removing it entirely.
#25
make it a watchdog please
#26
The very best should be settings form with per role setting: message/watchdog.
With that admin can set messages for his role, but normal users/anonymous will not see that annoying thing and admin can search log.