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

joostvdl’s picture

Title: Message : The map sites/default/files/imagecache/... is created is shown » Message : The map sites/default/files/imagecache/... has been created is shown
drewish’s picture

Title: Message : The map sites/default/files/imagecache/... has been created is shown » Don't show preset create directory messages to anonymous users
Category: bug » feature

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.

drewish’s picture

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.

tsvenson’s picture

Subscribing. Working on a site that will be released soon, so I hope you find a solution in a not so distant future :)

paganwinter’s picture

Subscribing...

askibinski’s picture

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)

jhedstrom’s picture

Subscribing.

drewish’s picture

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! ;)

jhedstrom’s picture

Status: Active » Needs review
StatusFileSize
new446 bytes

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...

donquixote’s picture

subscribe

bonked’s picture

Subscribe.

asak’s picture

subscribing (and using patch #9 for now...)

drewish’s picture

yang_yi_cn’s picture

Subscribing.

OneTwoTait’s picture

subscribe

rc2020’s picture

subscribe

hefox’s picture

Patch works, +1 :).

fenstrat’s picture

StatusFileSize
new807 bytes

Same "hack" as per #9, with the addition of only clearing the message for anonymous users.

fenstrat’s picture

Version: 6.x-2.0-beta9 » 6.x-2.0-beta10
manuel garcia’s picture

Priority: Normal » Critical

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.

hefox’s picture

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.

mherb204’s picture

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

benone’s picture

+1
when it will be in dev or beta ?

benone’s picture

Not only to anonymous. To everybody. Only user 1 should see that.

Kane’s picture

+1

fenstrat’s picture

StatusFileSize
new818 bytes

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?

drewish’s picture

Version: 6.x-2.0-beta10 » 6.x-2.x-dev
StatusFileSize
new1.06 KB

What about this? It only clear status messages (leaving errors and warnings) from all but imagecache admins.

manuel garcia’s picture

some might request for all messages to be displayed only to imagecache admins... good enough for me though!

fenstrat’s picture

Status: Needs review » Reviewed & tested by the community

#27 seems like the best solution.

drewish’s picture

Status: Reviewed & tested by the community » Fixed

committed to HEAD.

drewish’s picture

also committed to DRUPAL-6--2.

manuel garcia’s picture

Thanks a lot guys

Status: Fixed » Closed (fixed)

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

ryan_courtnage’s picture

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)

d.clarke’s picture

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.
gooddesignusa’s picture

sub. thank you patch from #27 worked for me.