Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
As mentioned briefly in this comment, when working with a text field (the body) in my view, I'm getting the following error:
Notice: Undefined index: format in _text_sanitize() (line 319 of /public_html/modules/field/modules/text/text.module).
This also is most likely the reason that I'm seeing tags when viewing a textfield in my view. For example, instead of html formatted output, I'm seeing something like
<p>my text shows here, including the paragraph tags</p>
Comment | File | Size | Author |
---|---|---|---|
#41 | Screen shot 2012-07-20 at 11.00.07 AM.png | 33.91 KB | ahimsauzi |
#23 | views_fix.txt | 16.93 KB | hedel |
#21 | views_exp.txt | 16.9 KB | hedel |
#19 | view-export.txt | 5.48 KB | neoglez |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedDoes this happen only when aggregating a field?
Comment #2
Rob_Feature CreditAttribution: Rob_Feature commentedHonestly, I'm still figuring out what "aggregating" a field means :) The fields are grouped and the field does say "Aggregation Settings" next to it...so yeah, I suppose it's aggregated.
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedAggregating means taking the results of several fields in a group and running an aggregation function on them, such as sum or count or average. It's required when 'aggregation' setting is checked in the advanced settings.
Comment #4
mradcliffeSee comment #5 and #6 in #1203054: Aggregating a field gives lots of errors.
Comment #5
dawehnerCan you describe how to reproduce the problem easy?
This would really help to fix the problem.
Comment #6
Rob_Feature CreditAttribution: Rob_Feature commentedDereine: I had a fields based view where I used the "Group by" functionality. Then, as merlin mentioned, you choose the 'aggregate' checkbox under advanced to see this behavior.
I unchecked aggregate and the error went away...my tag problem also was resolved.
Comment #7
Rob_Feature CreditAttribution: Rob_Feature commentedComment #8
jason89s CreditAttribution: jason89s commented+1
Happens when I enable aggregation while "Content: Body" is a displayed field.
Comment #9
Bernieman CreditAttribution: Bernieman commentedHello all,
I have the same error.
Everything went fine until i added a Taggingfield to my Block-View and did some rearranging.
Comment #10
Bernieman CreditAttribution: Bernieman commentedAnd after I did some Work with the fields, like Rewrite Output and things like that - the Error-message disappeared.
Comment #11
e5sego CreditAttribution: e5sego commentedNote: I got same error after adding computes field to the content type and view.
Changing the field formatter to plain text the notices disappeared.
Comment #12
sun-fire CreditAttribution: sun-fire commentedThe same error. Subscribe.
Comment #13
khiminrm CreditAttribution: khiminrm commentedsubscribe
Comment #14
mpcm CreditAttribution: mpcm commentedsubscribe
Comment #15
mpcm CreditAttribution: mpcm commentedBy isolating the field that was causing the error, due to the lack of that field I was able to correct this.
I went into views, edited the field's properties, and saved. It is now supplying the needed index, so the errors go away.
In my case this was a field that was once a text field, then was changed into a list. I am fairly certain that I did the view edits that `caused` this after it became a list, but hopefully that will help someone else resolve the root cause of this.
Comment #16
dawehnerActually no wonder that this caused an error :)
Comment #17
crashtest_ CreditAttribution: crashtest_ commentedI am getting this error, and I did not convert a text field to a list, it is simply happening when I have a body field in a view that has aggregation turned on.
Comment #18
crashtest_ CreditAttribution: crashtest_ commentedSeems to actually happen when choosing "value" as the group by characteristic for body field.
Comment #19
neoglez CreditAttribution: neoglez commentedBased on this info i've tried to reproduce the problem and i couldn't.
Could someone preovide an export?? (see, for example the file att.)
Comment #20
ataxia CreditAttribution: ataxia commentedI created a View that pulled several fields from a content type, which worked great. Then I had to change one of the fields in the content type from a free-text field to a text selection list, using the same field name.
After that, I was seeing this error everywhere the View was displayed.
I deleted the original field from the View and added it back in (even though it was the same name and was still a text field) and the error was gone.
Not sure if that helps you identify the problem, but it fixed my issue.
Comment #21
hedel CreditAttribution: hedel commentedHere is a print screen of the problem: http://imageshack.us/photo/my-images/502/viewserror.jpg/
and attach the export of the view
Comment #22
hedel CreditAttribution: hedel commentedAtaxia is right. I delete the field and add it again to the view and the problem is gone.
Comment #23
hedel CreditAttribution: hedel commentedAtaxia is right, I deleted the field I change and add it again to the view and the problem is gone.
Here is attach the export of the fix view and the problem was here:
$handler->display->display_options['fields']['field_cena']['type'] = 'text_default';
and now look like:
I hope this can help for understand where is the problem and how to fix it.
Greetings
Comment #24
Reg CreditAttribution: Reg commentedI had the same problem after adding the date field to the article content type and it wouldn't go away. I do have a backtrace which will hopefully help. Here's the result:
Comment #25
Reg CreditAttribution: Reg commentedI've changed this to active as I suspect I've tracked down at least some of variables that are the root cause of this bug but if you still can't duplicate it let me know what I can do next.
I tried deleting then adding the content body field as mentioned above and no effect but left the aggregate settings and body field at their defaults. I then looked a little closer and saw that it defaulted grouping on "value" which didn't make any sense to me since value would be the body text (at least in my case it makes no sense). I then changed the grouping from the default to Item ID and the error went away (I assume Item ID's are unique so there was no grouping that could happen).
I then looked at the field side and noticed that formatter was set to default. I changed it to plain text, changed the grouping back to value in the on the aggregation side and no error. I think what this is saying that somehow the body text is being left without a formatter when it's on default and therefore the grouping when set to value doesn't have enough information to work with since there is no formatter to go through and this lack of information goes all the way through to where the error happens.
Does this work for anyone else?
I tracked this down to the $entity variable in set_items() in views_handler_field_field.inc on the content body field (line 764). This $entity variable gets passed (at least in part) all the way through to _text_sanitize() . The variable in _text_sanitize() that causes the error looks like this for the body field:
Comment #26
Reg CreditAttribution: Reg commentedTwo more items that I just noticed just:
Comment #27
jcassano CreditAttribution: jcassano commentedI can confirm that I did the same thing in Ataxia's (#20) comment: I created a text field, made a *page* view with the text field, changed the field to a list with the same machine field name and didn't edit the view.
When I removed and re-added the field the problem went away.
It might be specific to page views, if that helps narrow down how to reproduce it. Not sure.
Comment #28
Toddv CreditAttribution: Toddv commentedAre you sure this is a Views related problem? I have a custom content type that after moving from D6 to D7 (running on 7.12) started giving this error: Notice: Undefined index: format in _text_sanitize() (line 319 of ....modules/field/modules/text/text.module). The content type has nothing to do with views, but does have quite a few custom fields.
When I first migrated into D7 I had quite a few problems with these custom fields - fatal errors on the integer fields and I resaved each of them which seemed to clear all that up. But now I get the undefined index: format in the _text_sanitize function.
So, not sure if that adds any pertinent info to the problem but I'll start watching this thread. Thanks for any insights.
Comment #29
John Pitcairn CreditAttribution: John Pitcairn commentedGrouping by value on a text field when using aggregation triggers the problem for me - text field html tags are escaped in both preview and final render, and I get the text format error when the view is rendered. This is a block view, so it's not restricted to pages.
Grouping by entity ID fixes it.
Comment #30
raghukr CreditAttribution: raghukr commentedI had the same issue. Grouping "body" field in the view by "Entity ID" fixed it.
Comment #31
Reg CreditAttribution: Reg commented@Toddv: Regarding,
Have a look at the backtrace in #24, it's clearly going through views. My install also is a clean 7.x install. No upgrading from D6.
Comment #32
Toddv CreditAttribution: Toddv commentedAh, right you are.
Comment #33
batigol CreditAttribution: batigol commentedSame here:
After aggregating body field. #30 doesn't work for me. How ever changing body field Formatter to Plain Text fix it. Off course its not a solution.
Comment #34
kurtzhong CreditAttribution: kurtzhong commentedJust met the same problem with aggregating field. Subscribe.
Comment #35
dawehnerIf you use aggregation you should better change the aggregation setting of the field and add the format field there as well. This should fix the issue here.
Comment #36
Reg CreditAttribution: Reg commentedI agree that the problem seems to be solved through enough people saying what's happening for the issue to be known and understood.
However, shouldn't there be either a code change or at the very least some documentation added to the module somewhere so that when you turn on aggregation you are either programatically locked out from doing the wrong combination of options or at least there is some text to tell you what you need to do right?
To me posting the error in drupal.org or a web search engine to pull up this page to learn what you have to do is not exactly a fix. Even if it's not feasible to change the code wouldn't some warning or info text somewhere when you first turn on aggregation be reasonable and plausible solution?
"Warning, not selecting the appropriate text filter could result in "warning" messages in your log table".
or something like it.
Comment #37
3rdLOF CreditAttribution: 3rdLOF commentedWhen this happens with any text field, simply changing the format from "default" to "plain text" solved this problem.
Comment #38
Reg CreditAttribution: Reg commented@kannary100, Yes, I think we have established that changing the filter from default solves it. But like I said in #36, something that tells people this when they turn on aggregation instead having to search to find out what's going wrong would be appropriate.
Comment #39
Glenmoore CreditAttribution: Glenmoore commentedI have a View with six attachments and I get exactly the same error messages whenever any one of these attachments returns a result. It is fine when no results are returned and if more than one attachment returns a result then I get more than one set of error messages as you might expect.
However, I am not aggregating anything on any of these attachments or, indeed, on the main Page. Changing the format has no effect (most of my fields are hidden anyway).
Comment #40
b8x CreditAttribution: b8x commentedmy problem also was caused by the aggregation of the field.
1 field gave error - field Content: body. so i set another Aggregation Group column, by default there was "format", so i select "Entity ID", thats all.
Comment #41
ahimsauziIn my case it was an aggregation settings for the actual field that solved it. I used a text field in the view that for some reason the default aggregation settings did not included the text format. That obviously offended (at rightfully so) the _text_sanitize function.
To solve this: select the Entity ID on the Group Column menu and tick on the Group Columns (additional) Entity ID, Value and Format options.
Comment #42
petrovnn CreditAttribution: petrovnn commentedThanks for #30 and #41 - this fix my problem!
Comment #43
modulist CreditAttribution: modulist commentedHere's a fix that worked for me. You will need to turn on the "Always show the master display" option at /admin/structure/views/settings
I ran into this issue when I set Use aggregation to Yes in a view with multiple displays. I had applied aggregation to all displays, instead of just narrowing it down to only the one display.
Once I turned on aggregation, this error was appearing in every single display for the view. I went back into the view, turned off aggregation for all displays. I went into the fields, and made sure that these were different than the master display. In this case, I opened the title field and saved it with This page: override selected.
I then reactivated aggregation only on the display that needed it, making sure that the master display did not have aggregation activated. When done properly, the Aggregation settings link will appear in the display's field, but not in the master display.
I saved the display, and that did the trick.
Comment #44
warmth CreditAttribution: warmth commentedI recommend to select "Entity ID" in the Group column of the Aggregation Settings of each of your fields.
Note: This can result in unexpected results but it's the only possible way to bypass the issue.
Comment #45
flefle CreditAttribution: flefle commentedTricky issue and it still in the latest versions of core & Views.
I figured out a solution which might not be ideal but helped me:
Add at line 266 & 320:
$item['format'] = isset($item['format']) ? $item['format'] : 'full_html';
Comment #46
dgastudio CreditAttribution: dgastudio commentedsame here. solved by remove field from views and add it again
Comment #47
gabrielmachadosantos CreditAttribution: gabrielmachadosantos commentedFor me worked when I edit the "Strip HTML tags" checkbox on "REWRITE RESULTS" for the field.
Comment #48
Reg CreditAttribution: Reg commented@frizi (#45): Those lines you mentioned to add. To what file should they be added?
Comment #49
AlfonsoAB CreditAttribution: AlfonsoAB commentedIn my case I was trying to format th field as an URL using "Output this field as a link " in the Rewrite results section of the options. Selecting "Plain text" as formatter solves the issue for me. ¿Maybe the default selection of formatter is not loading correctly?
Comment #50
hoZt CreditAttribution: hoZt commentedAdding the format and value to the aggregation setting for my body field as described in #35 worked for me.
Comment #51
codemuncher CreditAttribution: codemuncher commentedWhen in views, editing a field, the option "Place a colon after the label". When it is unchecked, the error goes away for me.
Comment #52
avlisodraude CreditAttribution: avlisodraude commentedJust in case someone else gets into the same trouble:
In my case this same problem happened when after a created a View I modified the content type of one of the fields (from text to node reference), then I started getting the message.
Solution:
In the View remove the modified field and add it again. After that the problem went away.
Greetings,
Eduardo
Comment #53
GaneshKumar CreditAttribution: GaneshKumar commentedAfter i dig my head more and i got the solution.
Its mainly because of views misconfiguration. If you use Global: custom text and add the html code directly into the text box, you will get this error.
Solution:
Instead of using text box to add html code, use rewrite result and select Output this field as a link then add the link code and select strip html.
You will get rid of this issue.
Comment #54
philsward CreditAttribution: philsward commented@GaneshKumar Can you see if it's still happening when you set the filter to "Full HTML"? I'm not exactly sure if that's fixed it for me or not, but curious what it does for someone else... (For the Global: custom text box)
Comment #55
philsward CreditAttribution: philsward commentedYeah, this issue is NOT specific to views...
If you upgraded from D6 -> D7 and converted fields with option radio/buttons, you might run into this error.
The "Content Migrate" module may not do a very good job of updating the field in the database... I ended up having to manually update the database and fix the affected fields in the field_config_instance table.
Comment #56
philsward CreditAttribution: philsward commentedWooHoo! Just figured out how to fix it! (Ok, for my use-case situation...) Been pulling my hair out the last two days trying to track down exactly what was going on since it wasn't directly a View related issue but I have a feeling my solution might be the cause of other's who ARE experiencing it on views...
As I mentioned before, I narrowed it down to my "Option Checkbox / Radio" fields. Looking into Devel, led me to look into the database. That led me to realize that the way the database was storing the field "Format", wasn't ever updated in the D6->D7 migration. D6 stored the format as "text_default" and D7 stores the format as "list_default" (For the radio buttons at least...)
If you aren't using a view on the page receiving the error, proceed below for my step by step solution. I recommend opening a second page that does show the errors, so you can test it again after doing the following steps. (In a nut shell, change the "Format" on the content display tab to "Key" then back to "Default" for every display that uses a list field.)
What I ended up having to do was:
1) Go to the default display of the content type. At the bottom you can choose to "Customize Display Settings" for the various displays (Teaser, RSS, Search Index etc.)
2) Enable each and every display. (Updating it in the default doesn't replicate to the rest :-/)
3) Start with the Default display and find ALL of your List(text) fields and change the format from "Default" to Key then save that display.
4) Next change them all from Key, back to Default. This will update the database to store it as the correct format.
5) Proceed with each of the remaining displays.
6) Test your page getting the errors.
If that doesn't fix it, you might load up Devel and see if you can figure anything else out... Hope that helps!
Comment #57
grigorym CreditAttribution: grigorym commentedI had a similar problem, when the body field was added to fields list of a view, then the relationship was added, and the grouping turned on. After that in the preview section I saw that the content of the body field in preview data were not turned into html: i saw BR's there, etc.
I deleted the body field from the field list, and added it again. Is asked me whether i want to aggregate over it and i agreed. It asked if I wanted to add some more fields (subfields of body field?) and I included format field as well. The problem disappeared.
Comment #58
Bob123 CreditAttribution: Bob123 commentedSame issue with Drupal 7.19 / Views 7.x-3.7
solution #11 posted by e5sego worked for me...
Thanks.
Comment #59
Wtower CreditAttribution: Wtower commentedI reproduced the same error in a slightly different way (unless I missed something):
In this way, when displaying the view, I get the particular error. To solve it, I followed #15 suggestion to simply update the view's field.
Hope it helps.
Comment #60
RobKoberg CreditAttribution: RobKoberg commentedThis went away for me when I changed the taxonomy term's description field Aggregation settings > Group Column from Value to Entity ID
Comment #61
ressa CreditAttribution: ressa commentedI had deleted a field, to change it from text field type to integer. Removing the field and adding it again fixed the error.
Comment #62
Transmitter CreditAttribution: Transmitter commentedI couldn't even get it working by changing something at the taxonomy field/widget etc.
I had to build the view from scratch and then it worked.
Comment #63
drupalshrek CreditAttribution: drupalshrek commentedThanks for all your posts; I had exactly this problem, and reading what others had done was enough to help me fix the symptom (though it would of course be nice to fix the source of the problem).
I had a new content type with many fields and this error appeared. I found out which field was causing the problem by putting the following line just before the line 319 of the function _text_sanitize():
When I knew the field causing the problem, I simply deleted it and recreated it. This solved the problem.
Comment #64
unstatu CreditAttribution: unstatu commentedThanks for your help. I had this issue and I solved it using #35 solution. It worked perfect for me.
Comment #65
Imaaxa-Cory CreditAttribution: Imaaxa-Cory commentedHad this problem with a default body field. Drupal 7.26 and Views 7.x-3.1 #41 solved the issue.
Comment #66
ouelmart CreditAttribution: ouelmart commented#20 did it for me
Comment #67
DuneBLI have the same problem:
Is appearing for each row of my view (which is a simple view: displaying all full node of a particular content type)
This happens after I deleted a text field in my content type and add a tag field with the same name.
I could not solve this...
I have "shaked" the view as much I could (changing row=field , removing the filter on the content type, showing the teaser,...) but the errors are still there
Comment #68
mctwist CreditAttribution: mctwist commentedI was having the same trouble with the Body field, then attempted #20. It didn't work at first, but then I went back into my Body field's aggregation settings and changed the Group Column from "Value" to "Entity ID." Now it's perfect.
Comment #69
dxx CreditAttribution: dxx commented#68 solved issue for me!
Comment #70
littledynamo CreditAttribution: littledynamo commented+1 for #68
Comment #71
giorgio79 CreditAttribution: giorgio79 commentedI am getting this issue with a programmatically created node in the VIew where text format is set to null.
Also, I am not using aggregation.
Looks like there are thousands of Drupal sites with this issue now
https://www.google.com/search?q=Notice%3A+Undefined+index%3A+text_proces...()+(line+319&oq=Notice%3A+Undefined+index%3A+text_processing+in+_text_sanitize()+(line+319&aqs=chrome..69i57j69i58j69i59l3&sourceid=chrome&es_sm=93&ie=UTF-8#q=Notice:+Undefined+index:+text_processing+in+_text_sanitize()+(line+319&safe=off&start=10
Comment #72
khiminrm CreditAttribution: khiminrm commented#68 helped me too. Thanks!
Comment #73
charlied CreditAttribution: charlied commentedLike others above, my problem was changing the type of a node field from text to date but not updating views. The symptom was one watchdog log message
Notice: Undefined index: text_processing in _text_sanitize() (line 319..
for each row of view displayed.Found it using #63, first checking the number of messages correspond to the number of views query rows and using the debug which showed a null parameter on one field. Went to views, removed offending field, saved, added field (of new type). Worked. Thanks to all !
Comment #74
knalstaaf CreditAttribution: knalstaaf commentedExactly like #73: changed the type of a field but kept the same field machine name (which was already being used in some views). Views found the field (and displayed it correctly) but was confused about the field type apparently. Deleting that field from your view and adding it once again solves it indeed.
Comment #75
kotoponus CreditAttribution: kotoponus commented#73 (@charlied) was spot on and #74 (@knalstaaf)'s solution exactly for me. Thanks.
Comment #76
Reg CreditAttribution: Reg as a volunteer commentedHi All,
This issue has been open since 2011! Does anyone else think it's about time we close it?
We have established without a shadow of a doubt what the cause is -- settings that are incompatible with aggregation. Going back to #36 does anyone have a good recommendation on how to tell people ahead of time what's going on so that we could one day close this issue?
I vote the easiest path for the short term which would be a notice when you first turn on aggregation to the effect of:
"Warning: Some combinations of settings can cause aggregation to throw an error and due to the nature of aggregation not all can be foreseen. If you are seeing errors since using aggregation see issue Undefined index for hints on settings for aggregation.
Not a perfect fix but quick to do because it won't require anyone to dig deep into the code to try and predict when an error will be thrown.
Comment #77
DamienMcKennaI ran into a similar problem, the root cause was that the aggregated text columns didn't include the 'format' field, so the _text_sanitize() function didn't work correctly.
What I did to fix it was go into the aggregation settings for the text fields and check off "format" under "Group columns (additional)", that fixed the problem.
So maybe the logic for that widget should be smart enough to automatically add the "format" item for text fields?
Comment #78
trumanru CreditAttribution: trumanru commented#41 solved my problem.
Comment #79
smurfxx CreditAttribution: smurfxx commented#41 solved the issue also afor me
Comment #80
mchar CreditAttribution: mchar commentedAfter reading #77 which is what #41 says but without the "Entity ID" and "Value" fields included, I solved the issue like this:
Aggregation type: "Group results together"
Group column: "Value"
Group columns (additional): "Format"
That way the field_name_field_format is included in the SELECT clause of the query and _text_sanitize() does not complain anymore.
Adding more fields under the "Group columns (additional)" makes the query longer/slower, so I guess that only the required fields should be added.
Comment #81
joelpittetThere is no patch on this yet so status can remain Active. I agree enough people seem to be running into this that maybe a code solution would be better.
Comment #82
riddhi.addweb CreditAttribution: riddhi.addweb at AddWeb Solution Pvt. Ltd. commentedComment #83
bernardopaulino CreditAttribution: bernardopaulino commented#35 worked for me. Thanks
Comment #84
alisonIn case it helps someone else!
In our case, it turned out there was an integer field in the view output, that didn't have all the necessary pieces of its
display_options
object, in the view config -- maybe the view was just, really old, and newer settings details just so happened to never get re-saved with all the proper pieces?Here's the
display_options
object for the troublemaking field in the view -- "old" / before I re-saved the settings:"new" / after I re-saved the settings:
......................
"re-saving the settings" -- I clicked on the troublemaking field in the view configuration -- the selected "Formatter" was "Default," but, as I discovered after re-saving, it was missing the "thousands marker" and "prefix/suffix" settings. Anyway, so, I changed the "Formatter" to "Unformatted" and then right back to "Default," and then submitted the settings for that field.
Presto-changeo, no more errors.
Comment #85
alisonWell, same issue happened with an integer field rendered with its settings on "Manage display" for the relevant content type -- i.e. it was NOT rendered via Views.
......................
Specifics:
Theme > custom template things for the "resolution" ctype: The integer field in question (field_resolution_number) is rendered in the template like this:
...which seems to use that field's display settings as configured on:
/admin/structure/types/manage/resolution/display
...which was missing the complete settings array in the same way that I explained in my previous comment ("thousands marker" and "prefix/suffix", etc.).
So! Just like with the view field (previous comment), I changed this integer field's "Format" setting to "Unformatted" and then right back to "Default," and then re-saved the "Manage display" screen. No more errors.
Comment #86
delacosta456 CreditAttribution: delacosta456 commentedhi
i would had this issue today too.And on my own side it was after enabling aggregation in a view display that has a body field.
Thnks
Comment #87
srbracelin CreditAttribution: srbracelin commented#41 worked for me!