Complete message shown :

Notice: Undefined index: 3 in filter_list_format() (line 675 of /.../modules/filter/filter.module).
Warning: Invalid argument supplied for foreach() in filter_list_format() (line 675 of /.../modules/filter/filter.module).

This results because my `filter` SQL table is as follows:

+--------+--------+----------------------+--------+--------+----------+
| format | module | name | weight | status | settings |
+--------+--------+----------------------+--------+--------+----------+
| 1 | filter | filter_autop | 2 | 1 | a:0:{} |
| 1 | filter | filter_html | 1 | 1 | a:0:{} |
| 1 | filter | filter_htmlcorrector | 10 | 1 | a:0:{} |
| 1 | filter | filter_url | 0 | 1 | a:0:{} |
| 2 | filter | filter_autop | 1 | 1 | a:0:{} |
| 2 | filter | filter_htmlcorrector | 10 | 1 | a:0:{} |
| 2 | filter | filter_url | 0 | 1 | a:0:{} |
| 4 | filter | filter_autop | 2 | 1 | a:0:{} |
| 4 | filter | filter_html_escape | 0 | 1 | a:0:{} |
| 4 | filter | filter_url | 1 | 1 | a:0:{} |
+--------+--------+----------------------+--------+--------+----------+
10 rows in set (0.00 sec)

format #3 exists, but doesn't have any filters applied, and filter module doesn't like it.

Comments

ceefour’s picture

Fix, change around line 675 in filters.module :

...
if (!isset($filters[$format_id])) {
$format_filters = array();
foreach ($filters['all'][$format_id] as $name => $filter) {
...

to :

...
if (!isset($filters[$format_id])) {
$format_filters = array();
$filter_map = isset($filters['all'][$format_id]) ? $filters['all'][$format_id] : array();
foreach ($filter_map as $name => $filter) {
...

ceefour’s picture

Title: Warning: Invalid argument supplied for foreach() in filter_list_format() (line 675 of /.../modules/filter/filter.module). » [PATCH] Warning: Invalid argument supplied for foreach() in filter_list_format() (line 675 of /.../modules/filter/filter.module)
greenskin’s picture

Project: Module Filter » Drupal core
Version: 7.x-1.0 » 7.x-dev
Component: Code » filter.module

I believe this belongs here.

alexkb’s picture

I also had this issue right after doing an upgrade from Drupal 6.20 to 7.0. The patch fixed my problem, thanks ceefour.

Starminder’s picture

Status: Active » Needs review

had the same issue, patch above fixes it. please commit.

damien tournoud’s picture

Title: [PATCH] Warning: Invalid argument supplied for foreach() in filter_list_format() (line 675 of /.../modules/filter/filter.module) » Warning: Invalid argument supplied for foreach() in filter_list_format() (line 675 of /.../modules/filter/filter.module)
Version: 7.x-dev » 8.x-dev
Status: Needs review » Active

I have seen that too... but there is no patch in this issue :)

Starminder’s picture

:) ok ok - I just mean the little fix in comment #1.

eporama’s picture

Status: Active » Needs review
StatusFileSize
new976 bytes

Here's a patch for the fix in comment #1 so we can have it tested and reviewed.

bryancasler’s picture

Patch #8 worked for me. I had a duplicate issue being worked on over here #1184186: Warning: Invalid argument supplied for foreach() in filter_list_format() (line 674

NickLitten’s picture

Great stuff. Patch #8 fixed the problem (filter errors after updating a node) for me on Droop7.2

Cheers!

amanaplan’s picture

Status: Needs review » Reviewed & tested by the community

Worked for me. RTBC-ing.

amanaplan’s picture

Issue tags: +Needs backport to D7

Adding tag so that we remember it has to be backported to Drupal 7 to be applied to the 7.x-dev branch.

Mesut58’s picture

it worked thank you

bryancasler’s picture

Since Patch #8 worked on D7, what's preventing it from being committed?

amanaplan’s picture

Issue tags: -Needs backport to D7

Here's the patch in comment #8 backported for D7.

amanaplan’s picture

StatusFileSize
new984 bytes

Forgot to attach. Here's the patch in comment #8 backported for D7.

tlangston’s picture

thank you - worked here too

tlangston’s picture

thank you - worked here too

catch’s picture

Issue tags: +Needs backport to D7

Tagging for backport.

amanaplan’s picture

It already has a patch for D7.

tlangston’s picture

If so, amanaplan, I shouldn't see the issue recur when I upgrade to 7.7. But I do. Are you saying the patch is in dev?

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x and 7.x. Thanks!

Status: Fixed » Closed (fixed)
Issue tags: -Needs backport to D7

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