I just upgraded to PHP5.3 and am getting the following:

warning: Invalid argument supplied for foreach() in .../sites/all/modules/wysiwyg_filter/wysiwyg_filter.inc on line 523.

The line number changes depending upon the node I'm on, sometimes I also get:

warning: Invalid argument supplied for foreach() in .../sites/all/modules/wysiwyg_filter/wysiwyg_filter.pages.inc on line 425.

Anybody know if this is easy to fix? I looked through the code, and it looks like it's not getting a variable correctly from the database. I can see if I can dig up more details...

#6 variable.txt16.45 KBpal_ur
Members fund testing for the Drupal project. Drupal Association Learn more


Renee S’s picture

Status: Active » Closed (fixed)

Well, nevermind. I ran cron, it disappeared. The best kind of error - the kind that is easily fixed =)

Renee S’s picture

Status: Closed (fixed) » Active

Ah, spoke too soon. It's still present on node edit pages.

markus_petrux’s picture

Status: Active » Postponed (maintainer needs more info)

Re: "warning: Invalid argument supplied for foreach() in .../sites/all/modules/wysiwyg_filter/wysiwyg_filter.inc on line 523"

hmm... this line looks like this:

  foreach (variable_get('wysiwyg_filter_'. $rule_key .'_'. $format, array()) as $rule) {

Note that variable_get() should return an array when 1) the variable exists, or 2) the variable does not exit (defaults to empty array).

So that PHP warning suggests that the variable exists, but it is NOT an array? Well, that's a different issue that could not be related to PHP 5.3. However, if we look at wysiwyg_filter_settings_filter_submit(), the code that parses the filter settings ensures these variables are stored as arrays. So, it seems that these variables have been corrupted somehow in your database.

Try saving the configuration of your input format and see if that helps. If that does not help, then we need to know what your variables contain, and then try to guess how they were corrupted.

markus_petrux’s picture

Title: PHP5.3 - invalid argument supplied foreach()... » warning: Invalid argument supplied for foreach() in wysiwyg_filter.inc on line 523
Renee S’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

OK, thanks. I rearranged the filters and added some checkboxes to the "allowed" items, and re-saved... and it came back once with the same error; tried it a second time changing a few more things, and it saved fine the second time, no more error anywhere.

Very strange! I hadn't touched it since I set it up a month ago; maybe something in the switch affected it. Who knows. It works now. Sorry. And thanks =)

pal_ur’s picture

16.45 KB

Same problem, the relevant rows exported as CSV and attached as TXT.

alexbk66-’s picture

Same problem, I run cron and get many

Invalid argument supplied for foreach() in ../profiles/drupal_commons/modules/contrib/wysiwyg_filter/wysiwyg_filter.pages.inc on line 425

Any help?

Renee S’s picture

It seems like the wysiwyg entries get corrupted or moved around in a way the filter doesn't understand. Have you tried rearranging the filters or adding/removing things from them? That seemed to fix it for me.

alexbk66-’s picture

Sure I tried everything.

There ere related issues:
#885632: Don't export variables with a default value
#887532: Follow up: Input formats integration
Don't seem to be resolved, even if one of them is closed...

And when I set "Rules for URLs used within inline styles: /*" it doesn't get saved, I keep getting the warning:

The style attribute is used in your HTML elements and attributes rules, and you have enabled one of the following style properties: "background", "background-image", "list-style" or "list-style-image". You should specify the Rules for URLs used within inline styles field in the "Advanced rules" section below. Leaving it unspecified will result in all URLs used within inline styles filtered out.
BarisW’s picture

I'm having the same issue. It seems that all my values are empty strings:

drush vget wysiwyg_filter_valid_classes_4: ""
drush vget wysiwyg_filter_valid_ids_4: ""
drush vget wysiwyg_filter_style_urls_4: ""
drush vget wysiwyg_filter_valid_classes_4: ""
drush vget wysiwyg_filter_valid_ids_4: ""
drush vget wysiwyg_filter_style_urls_4: ""
BarisW’s picture

Version: 6.x-1.x-dev » 6.x-1.5
Status: Closed (fixed) » Active

Setting this back to active because the problem still stands with the latest release 6.x-1.5.
For those who want to use to use it without errors.. (dirty) just add a @ in front of the foreach:

@foreach (variable_get('wysiwyg_filter_'. $rule_key .'_'. $format, array()) as $rule) {

BarisW’s picture

This might be a better/cleaner solution:

  foreach (wysiwyg_filter_get_advanced_rules() as $rule_key => $rule_info) {
    $filter_options[$rule_key] = array();
    $rule_array = variable_get('wysiwyg_filter_'. $rule_key .'_'. $format, array());
    if (is_array($rule_array)) {
      foreach ($rule_array as $rule) {
        $filter_options[$rule_key][] = '`^'. str_replace("\xFF", $rule_info['asterisk_expansion'], preg_quote(str_replace('*', "\xFF", $rule), '`')) .'$`';
freestone’s picture

Same issue but in my 6.x-1.5

Puting an @ in front of that foreach sure does not work....diff error.

Putting the new code into wysiwyg_filter.inc on line 523. does nothing.

I have tried rearranging the filters, adding valid tags etc. Nothing seems to remmidy this issue for me.

I have read on an off about this for months. No solid solution ?

Any help would be appriciated.

freestone’s picture

Used phpadmin to empty all cache tables, changed the filter options, ran cron, ran update. After doing all those the problem went away. Not sure what fixed it but next time I clone the site I will try them one at a time. I am thinking it is a cache issue. At least for me when I clone a site to a new domain.

axel.rutz’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Closing 6.x issues.