Posted by joostvdl on April 27, 2009 at 9:21pm
| Project: | ImageCache |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
When using Imachecache to create images (thumbnails) the site shows even for an anonymous user the message: The map sites/default/files/imagecache/... is created
Error Reporting is for the site set to write only to the logfile. So it should not be shown.
Comments
#1
#2
Well it's not an error message so that setting wouldn't be honored but it doesn't really make sense to show that to users.
#3
Humm... that's actually a side effect of using core's file_check_directory() to create the directories... I want to keep using that since it's got a bunch of useful checks in there. Maybe we could do some hackery to remove the message.
#4
Subscribing. Working on a site that will be released soon, so I hope you find a solution in a not so distant future :)
#5
Subscribing...
#6
Subscribing.
Until this is properly patched, I guess a quick workaround could be to check the $messages variable in the theme layer for any occurence of the word 'imagecache' in which case you wouldn't show the $messages at all. (But this would also prevent any addditonal messages being possibly displayed at that time)
#7
Subscribing.
#8
jhedstrom, i saw your user name in the email and was thinking to myself "sweet, he'll have posted a patch and i can just put this issue to rest". now i'm disappointed, get on it! ;)
#9
Since the issue is with file_check_directory, a hack is the only way around, and the only one I could think of was to flush all messages. This should be okay though since other messages shouldn't be added during this callback...but it's still a hack. Perhaps it would be less of a hack if it checked only for anonymous users...
#10
subscribe
#11
Subscribe.
#12
subscribing (and using patch #9 for now...)
#13
marked #545068: How to remove "xxx directory was created" message from anonymous user? as a duplicate.
#14
Subscribing.
#15
subscribe
#16
subscribe
#17
Patch works, +1 :).
#18
Same "hack" as per #9, with the addition of only clearing the message for anonymous users.
#19
#20
deffinetly a must, havent looked a the patches, but well, we dont want to have to hide all messages from the user just because of this... imho it should've never gotten in as a normal message, as it is meant to be for either debugging or for the administrator good sleep at night... switching to critical. Perhaps another way about doing it is to allow the admin to switch on/off the messages, or to only write them to the watchdog or something like that.
#21
I believe messages are stored in $_SESSION, so I believe can preg those messages and if find a directory creation, remove it.
Also, I don't see why the message would be important other than for potentially debugging purposes, so dislike for empty($user->uid) :(. Not all users are admin users, ie. community based sites.
#22
Patch in #9 doesn't work for me. fatal error Call to undefined function e_preset_flush - which means broken site!
function imagecache_action_delete($action) {
db_query('DELETE FROM {imagecache_action} WHERE actionid=%d', $action['actionid']);
$preset = imagecache_preset($action['presetid']);
imagecache_preset_flush($preset);
imagecache_presets(TRUE);
}
e_preset_flush($preset);{
imagecache_presets(TRUE);
}
I changed it to
function e_preset_flush($preset){
imagecache_presets(true);
}
that got the fatal error to go away and the site to come back up but... the directory creation messages are still popping up
I am launching my site in a few days and this looks bad when users see this.
Help please
#23
+1
when it will be in dev or beta ?
#24
Not only to anonymous. To everybody. Only user 1 should see that.
#25
+1
#26
Same as #18 but removes the message for all users except uid 1.
This covers the community based site case, but also keeps things simple.
As mentioned above, the other alternative is to create an admin setting to hide/show the message and/or write message to watchdog. Could be a bit overkill?
#27
What about this? It only clear status messages (leaving errors and warnings) from all but imagecache admins.
#28
some might request for all messages to be displayed only to imagecache admins... good enough for me though!
#29
#27 seems like the best solution.
#30
committed to HEAD.
#31
also committed to DRUPAL-6--2.
#32
Thanks a lot guys
#33
Automatically closed -- issue fixed for 2 weeks with no activity.
#34
Just a note for those looking for this fix. It's not in 6.x-2.0-beta10.
Presumably it'll make beta11 (although I'm unsure how to determine this with git)
#35
I know I'm a little late to this thread but I'm not sure I'm a fan of just stomping on any potential status messages in order to suppress these messages. Can we do something like the following patch (d.o wouldn't let me attach it)?
diff -Naur ../orig/imagecache.module imagecache.module
--- ../orig/imagecache.module 2011-02-24 18:06:53.000000000 -0800
+++ imagecache.module 2011-03-24 22:37:40.121577528 -0700
@@ -564,10 +564,17 @@
// file_check_directory() has an annoying habit of displaying "directory ...
// has been created" status messages. To avoid confusing visitors we clear
- // out all the status messages for non-ImageCache admins. This might affect
- // some other messages but errors and warnings should still be displayed.
+ // out this status messages for non-ImageCache admins.
if (!user_access('administer imagecache')) {
- drupal_get_messages('status', TRUE);
+ if ($_SESSION['messages']['status']) {
+ $unwanted_msg = t('The directory %directory has been created.', array('%directory' => rtrim($dir, '/\\')));
+ if (FALSE !== $key = array_search($unwanted_msg, $_SESSION['messages']['status'])) {
+ unset($_SESSION['messages']['status'][$key]);
+ if (empty($_SESSION['messages']['status'])) {
+ unset($_SESSION['messages']['status']);
+ }
+ }
+ }
}
// Simply copy the file if there are no actions.
#36
sub. thank you patch from #27 worked for me.