What does this unhappy pair of errors mean? I get them each time I run the update script:

* warning: Invalid argument supplied for foreach() in /home/ncdponli/public_html/main/includes/common.inc on line 779.
* warning: strtr() [function.strtr]: The second argument is not an array in /home/ncdponli/public_html/main/includes/common.inc on line 796.

Comments

irdom’s picture

i have same problem

TimAlsop’s picture

I have the same problem

zeta ζ’s picture

It means there is something wrong with translations.

Either you are using a translation with an error, or a custom module that is calling t() incorrectly. Second argument should be an array.

What language or modules are you using?
___________________
It’s in the detaιls…

demonstration portfolio

Jerimee’s picture

I be using english! I'm using the views, cck, date, calendar and webform modules

zeta ζ’s picture

At what point in the script do you get the warning?
What is it trying to print?
___________________
It’s in the detaιls…

demonstration portfolio

Jerimee’s picture

Once update.php is finished I am invited to view errors in the log. I click through to see the errors, and this error is displayed in red at top (you know, the typical error display) as well as in the log proper.

zeta ζ’s picture

Which update(s) is it attempting? (I think they have numbers.)

To help find the cause, can you edit line 796 of inc/common.inc to read;

     if (!is_array($args)) return $string . (is_string($args)? ' Args: ' . $args: '');
     return strtr($string, $args);

instead of just the second line?

This will highlight in red the line that causes this.

Of course, you shouldn’t hack core like this on a production site.
___________________
It’s in the detaιls…

demonstration portfolio

TimAlsop’s picture

I am getting the exact same error when I use a webform, so I changed the common.inc file as suggested, and in dblog I see red entries. When I select one of the red entries in log I see a message:

	Invalid argument supplied for foreach() in /data01/csafe/public_html/drupal/includes/common.inc on line 779.

I didn't see the argument which is causing the error.

In case of any doubt that I changed the code correctly, I have included a section of the code in common.inc:

...
        case '%':
        default:
          // Escaped and placeholder.
          $args[$key] = theme('placeholder', $value);
          break;

        case '!':
          // Pass-through.
      }
    }
    if (!is_array($args)) return $string . (is_string($args)? ' Args: ' . $args: '');
       return strtr($string, $args);
  }
}
...

What now ?

eagereyes’s picture

I have the same problem, and I added your code, but I wasn't seeing any additional information. So I put a print_r(debug_backtrace()) in the else branch of the ? operator, and that showed that the problem came from the Flickr module complaining about the default user not existing. Since that module is buggy right now anyway, I turned it off, and the problem disappeared.

So perhaps the Flickr module should be the first thing to try, perhaps that also helps others.

EagerEyes.org

tjg’s picture

I am getting the same errors here when I submit a webform (using the webform module, I mean) with file attachments:

# warning: Invalid argument supplied for foreach() in /www/htdocs/includes/common.inc on line 779.
# warning: strtr() [function.strtr]: The second argument is not an array. in /www/htdocs/includes/common.inc on line 796.

If I submit a webform that does not have file attachments, I do not get this error. When I get this error, the file uploads are not saved.

Can anyone comment on what may be causing this?

zeta ζ’s picture

W00t!

You get the errors in completely different circumstances.

The error is reported in common.inc: It’s called common for a reason – virtually everything uses it!

So how do we find out what is wrong? What is the string that the function is trying to return? We don’t know because the second error is preventing the string from being returned. My modification (posted 2 weeks ago) will at least return something in these circumstances: Have you tried it?

Why do you ask

Can anyone comment on what may be causing this?

Haven’t you read my comments?
___________________
It’s in the detaιls…

demonstration portfolio

damienmckenna’s picture

This is a message that was tripping up one of my sites:

stdClass Object
(
    [wid] => 89
    [uid] => 1
    [severity] => 5
    [type] => imageapi imagema
    [timestamp] => 1230482036
    [message] => The specified ImageMagick path /usr/bin/convert does not exist.
    [variables] => i:3;
    [link] => 
    [name] => Damien
)

That's part of imageapi_imagemagick.module:

function _imageapi_imagemagick_check_path($path) {
  $errors = array();
  if (!is_file($path)) {
    $errors[] = t('The specified ImageMagick path %file does not exist.', array('%file' => $path));
  }
...

Obviously nothing incorrect there. Not sure why that error would be turning up.

Here's a minor tweak I made as a workaround:

Index: modules/dblog/dblog.admin.inc
===================================================================
--- modules/dblog/dblog.admin.inc	(revision 1)
+++ modules/dblog/dblog.admin.inc	(working copy)
@@ -248,7 +248,11 @@
   }
   // Message to translate with injected variables
   else {
-    return t($dblog->message, unserialize($dblog->variables));
+    $v = unserialize($dblog->variables);
+    if (!is_array($v)) {
+      $v = array($v);
+    }
+    return t($dblog->message, $v);
   }
 }

--
Damien McKenna | Mediacurrent

vtsaran’s picture

I do not have imagemenu or imagemagic active and started getting this message after installing and enabling Google custom search module.
From looking at common.inc it seems that the problem is either related to Drupal not parsing certain characters or lack of language code that should be passed as one of the arguments.
I tried changing all possible settings in the module itself but to no avail. I am totally confused as to what to do next.
Any suggestions at all?

Thx,
V

HS’s picture

I am faced with the same issue...not sure if it's the adsense module or something else..totally lost here..