I do not want error messages (for example 30x HTTP errors) to be shown to every user. I need only certain users/roles to be able to see them. Can you please consider adding a permission setting for this?

Comments

alex_b’s picture

I'd rather improve error messages than suppress them - I assume when this error occurs something actually went wrong on the UI and the user needs feedback on 'what happened?' and some idea of 'what's can I do?'

Can you explain better which errors you don't want to show in their existing form to your users?

klonos’s picture

Actually there are also some 503 errors my users are getting, like so:

Download of http://some.site.com/some_file.xml failed with code 503.

This might be happening due to server traffic overload or some other reason and it might be a minor temporary issue. Anyhow, I do not want site visitors to be getting these errors because they might think something is seriously wrong with the site and never come back. I would love to have these errors logged someplace for the admin to see, but I don't want them shown to the visitors.

alex_b’s picture

On which occasion are these errors occurring?

klonos’s picture

They happen on random pages refreshes/loads. It might be in the admin pages or simply viewing the home page or content. I'll try and monitor to see if it happens only in certain of them, but I doubt it.

klonos’s picture

As a side note here I'd like to add that even browsing directly the xml from the source url throughs this 'Service Unavailable' error sometimes. So when I am referring to server load I don't mean the one hosting my drupal site, but the site providing the feed.

In case of success I get a green 'Success... 3 nodes were updated' or something. I don't need that displayed to users either.

klonos’s picture

some love on this?

alex_b’s picture

Well, we need to talk on *very* concrete terms here to move forward...

klonos’s picture

Hi alex_b, if you are joking because I talked about 'love' than... lol.

If you are seriously asking a question, I am going to have to ask you to define what are '*very* concrete terms' to you? I already explained that I have a very serious reason for requesting this feature and it is an actual use case... I do not want site visitors to be getting these errors because they might think something is seriously wrong with the site and never come back.

Plus another one... the people that I build this site for are asking questions about it and no matter how much I've explained the reasons these warnings show, they still think 'it looks ugly' and want them removed.

I could hack something by commending out the lines that display these warnings in the module, but this way if warnings persist I (or whichever admin) wouldn't know something is going wrong. So, what I propose is either have these warnings displayed only to specific users and/or roles by using proper permissions, or have them not be displayed in every page but only logged and displayed later only in admin pages (say the status page). Are you or anyone else thinking of any other approach to this issue?

I think all the above are legit reasons. Thank you in advance for (re)considering this.

klonos’s picture

Title: Permission for showing failure/error messages » Permission for showing failure/error + import success & deletion messages

Actually my needs have changed a bit. Now I also need to suppress successful node creation/deletion messages as well.

I want them shown only for the admin account or selected user roles and not to regular site visitors. Is this possible?

alex_b’s picture

#7 - sorry: with concrete terms I meant which messages should be changed to what for which users.

Again: I am very aware that most messages in Feeds aren't streamlined. I'd love to work on improving them rather than just supporessing them.

That said - do you want to really kill *all* messages whatsoever? I could imagine adding a global killswitch for messages from Feeds. This could be done by using a wrapper feeds_set_message() instead of drupal_set_message() and then adding a killswitch into the wrapper function:

function feeds_set_message() {
  if (variable_get('feeds_show_messages', TRUE)) {
    drupal_set_message();
  }
}  

If you need a quick fix for making your clients happy you can extend the processor and run:

function process() {
  parent::process();
  drupal_get_messages();
}

I continue to be open to improve messaging.

klonos’s picture

with concrete terms I meant which messages should be changed to what for which users.

well... it depends on use cases and I am sure that if I propose something, someone will step up and argue/propose something else.

There's only one way to satisfy all needs and that's by providing permissions per message type (error/success/deleted) per user role. Till this is implemented (lots of time and effort needed, so I guess it will take a looong time), I'd settle for a single permission to show all Feeds-related warnings or not. I am sure that somewhere in the code where messages are to be spat out to the user there could be an if statement that checks for this single permission. At least a hard-coded check for uid=1 (that's the admin, right?) if that's not too much to ask.

I had some visitors the last days that were 'bombarded' with 100s of 'node import' and 'node deleted' messages and had to scroll all the way down till they actually were able to see some true site content :(

Please explain when time permits where the code you mention in your reply should go.

Thank you in advance.

klonos’s picture

I realized just now that a hard-coded check for uid=1 is limiting other people's options. This means people that actually want all messages shown to all users.

How about a quick option... something like a 'Show Feeds-related messages only for the admin account' checkbox in module's settings?

alex_b’s picture

#11: feeds_set_message() should go into feeds.module, every use of drupal_set_message() that is user facing (e. g. not the ones in feeds_ui module) should be replaced with feeds_set_message().

klonos’s picture

Still trying to work this one out...

@Alex: if this is a quick one for you, please advice...

As it is now we get a message with the total of nodes created, but for deletion (expired items) we get one message per deleted feed item. I've located the code that needs to be changed. It sits right at the very end of the FeedsNodeProcessor.inc file. Now, since I don't want to display the title of each feed item node that was deleted, I altered the code like so:

  watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
  //drupal_set_message(t('@type %title has been deleted.', array('@type' => node_get_types('name', $node), '%title' => $node->title)));
  drupal_set_message(t('Deleted expired feed items'));

This got me 1/4 of the way, because now I still get the same message repeated as many times as deletions occurred. I need to have this message displayed only once though.

Now I get:

# Created 3 News Feed item node.
# Created 25 News Feed item nodes.
# Deleted expired feed items
# Deleted expired feed items
# Deleted expired feed items
# Deleted expired feed items
# Deleted expired feed items
... and so on.

While I need it to be:

# Created 3 News Feed item node.
# Created 25 News Feed item nodes.
# Deleted 13 expired feed items
# Deleted 4 expired feed items

I would also love this to be per target node too (case of multiple importers targeting same feed item node). So the above case would be like so:

# Created 28 News Feed item nodes.
# Deleted 17 expired feed items

Around line 88 in the same file there's:

    // Set messages.
    if ($batch->created) {
      drupal_set_message(format_plural($batch->created, 'Created @number @type node.', 'Created @number @type nodes.', array('@number' => $batch->created, '@type' => node_get_types('name', $this->config['content_type']))));
    }
    elseif ($batch->updated) {
      drupal_set_message(format_plural($batch->updated, 'Updated @number @type node.', 'Updated @number @type nodes.', array('@number' => $batch->updated, '@type' => node_get_types('name', $this->config['content_type']))));
    }
    else {
      drupal_set_message(t('There is no new content.'));
    }

...but I thing there is no such thing as $batch->deleted implemented (yet). If it was, the above code would simply change to include an elseif for deleted items:

    elseif ($batch->deleted) {
      drupal_set_message(format_plural($batch->deleted, 'Deleted @number @type node.', 'Deleted @number @type nodes.', array('@number' => $batch->deleted, '@type' => node_get_types('name', $this->config['content_type']))));
    }

Can we please has it?

alex_b’s picture

Can we please has it?

Yes, go for it.

klonos’s picture

...any pointers to the right direction please?

alex_b’s picture

#16 Read FeedsBatch and FeedsImportBatch - should be straightforward to implement.

alex_b’s picture

Status: Active » Closed (won't fix)

Closing after prolonged period of inactivity.

klonos’s picture

Fair enough Alex.

It seems that my skills are not enough yet to get something coded. After all, taking a look at this issue I find only you and me talking about this and saw no interest from enyone else. It stikes me kinda odd though that nobody else has a problem with messages such as these thrown at their site visitors. I mean, they serve no purpose to site visitors since only site admins can benefit from them.

I'll let this to someone else. If they find this feature request useful, they can either code something if they can or change the status to something like postponed I guess.

Hanno’s picture

@kionos do you probably use poormanscron as cron? This module shows messages to anonymous users, see #867054: Suppress status messages to anonymous users when using poormanscron

klonos’s picture

I actually do Hanno. I wasn't aware of this situation and the issue you link to. Thanx.

Hanno’s picture

You can use Poormanscron 6.1 instead of the latest branch. The 6.1 version suppress the messages. Not clear why they removed this feature in the new 6.2 branch (backport from 7). See also the issue in poormanscron #902368: Suppress status messages to anonymous users

klonos’s picture

...or we can push for an actual fix instead of using old versions/branches ;)