Notice: Undefined offset: 0 in views_handler_field_field->set_items() (line 725 of /home/admin/domains/ ... /sites/all/modules/views/modules/field/views_handler_field_field.inc).
I have a simple content type named "Resource." It has a Title, a Description (body), a Link (7.x-1.0-alpha3) and a File. Whenever I try to display a Views Page that includes a record that does not have a File in it, I get the error above. It happens whether I use a table view or an unformatted list view for the page. If I add a File to the record the error disappears. If there is only a File in the record and no Link, the error disappears, so it's only an issue if I have a Link and no File. Also, I have both Link and File set to "Hide if empty" in the "No Results Behavior" section.
I have tried the latest dev version as well as 7.x-3.0-beta3 and it's the same in both. Please let me know if you need any further info.
Thanks!
Tim
| Comment | File | Size | Author |
|---|---|---|---|
| #41 | views-7.x-3.x-dev-1153066-a-1.patch | 931 bytes | thekevinday |
| #41 | views-7.x-3.x-dev-1153066-b-1.patch | 759 bytes | thekevinday |
| #28 | views-7.x-3.x-dev-1153066-12.patch | 641 bytes | thekevinday |
| #5 | 1153066_Undefined offset in views_handler_field_field-set_items.patch | 1.01 KB | johnv |
Comments
Comment #1
dawehnerThis seems to be a duplicate of #1070744: Undefined index: es en views_handler_field_field->get_items()
Comment #2
trgreen17 commentedI thought so too at first, but this one is "set_items()" and the other one is "get_items()." Don't know if that matters in this situation, but I also noticed that the steps to reproduce the error are quite different.
Comment #3
johnvSame here, using views 7.x-3.x-dev (2011-Apr-16) with a GMap display.
I have the Office hours field, which is not filled. Does error occur only on 'complex' fields? An empty integr/text-field never gave this message.
Comment #4
johnvThe message is raised when the field definition has no content defined in hook_field_load(). You can try putting the following in the line before the raising-line: dpm($entity->{$this->definition['field_name']});
A 'normal' field returns e.g.:
a term:
... (Array, 1 element)
\en (Array, 1 element)
\\0 (Array, 1 element)
\\\tid (String, 2 characters ) 85
a text field:
... (Array, 1 element)
\und (Array, 1 element)
\\0 (Array, 3 elements)
\\\value (String, 4 characters ) content of field
\\\format (String, 10 characters ) plain_text
\\\safe_value (String, 4 characters ) content of field
Office_hours only shows:
... (Array, 0 elements)
trgreen23, how does your field look like?
dereine, should the contibuting field be fixed/amended, or should Views catch this exception?
Comment #5
johnvSince the code already contains some tests for !empty($entity->{$this->definition['field_name']}, I guess this can be solved in Views itself.
Here is a small patch. (Needs fixing indentation and comments, but it's better readable this way)
Comment #6
dawehnerThanks for finding out the real reason. This is a great peace of information.
Please take care that drupal code style is still valid in this file.
Comment #7
johnvthanks dereine. I know. But without indentation it was harder to see the differences, and a ref to the issue is for my own bookkeeping. I'm happy to provide a clean patch if the solution is OK.
Comment #8
dawehnerIn general i'm wondering whether we should fix the bug here, or in the field modules. Because this error shows a bug in this field modules, which is good from my perspective. The developers should know this.
Comment #9
johnvIn the case of OfficeHours, they did not implement hook_field_load() and other hook_field_.. functions. I don't think that omitting functionality is an error?
Comment #10
bojanz commentedA brief chat with DamZ points to Views actually handling the formatter output wrong (or rather, not flexible enough), because there's no rule saying the rendered structure needs to be keyed by $delta.
In general, not implementing hook_field_load() is fine, but as I said above, we have a different problem.
EDIT: Actually, the docs for hook_field_formatter_view() do say that the rendered structure needs to be keyed by $delta.
The problem is that the office hours module doesn't implement hook_field_formatter_view() at all :P So the problem is definitely in the module.
Will think a bit on whether Views can be a bit smarter here.
We can at least check if $render_array is empty.
Comment #11
mariagwyn commentedAny movement on this? I am getting this warning in views that display "Field Collections" (http://drupal.org/project/field_collection). If I remove the field from the view, the error disappears. Note I am also opening an issue on field collections since it seems very field-type specific.
Comment #12
thekevinday commentedI get this same error with the custom formatters module enabled (version 7.x-2.0-beta2) module.
The patch from #5 does silence the errors.
If there is no content, then shouldn't raw just be set to an empty string?
<?php $items[$count]['raw'] = isset($render_array['#items'][$count]) ? $render_array['#items'][$count] : ''; ?>Instead of the current:
<?php $items[$count]['raw'] = $render_array['#items'][$count]; ?>Comment #13
mariagwyn commentedapplied the patch in #5, seems to work for me.
Comment #14
seanfitzpatrick commentedThe patch in #5 silences the error for me, but my fields disappear (a couple text fields and fivestar). Haven't had time to investigate too much yet.
Edit: actually, I should say the *content* of the fields disappears, but the fields' div tags are rendering.
Comment #15
thekevinday commentedSean, can you try just making the change I mentioned in #12 only?
This change only silences the message.
Does the problem you mention in #14 still happen after that change?
Comment #16
anruethersubscribe
Comment #17
seanfitzpatrick commentedKevin, I'm afraid #12 gives some different errors:
EDIT: nevermind... I was applying the code in #12 to an older version of the file. The errors are gone now.
Notice: Undefined index: base table in views_handler_field_field->query() (line 80 of /var/aegir/platforms/drupal-7.0/sites/all/modules/views/modules/field/views_handler_field_field.inc).Notice: Undefined index: in views_handler_field_field->query() (line 110 of /var/aegir/platforms/drupal-7.0/sites/all/modules/views/modules/field/views_handler_field_field.inc).Notice: Undefined index: entity keys in views_handler_field_field->query() (line 115 of /var/aegir/platforms/drupal-7.0/sites/all/modules/views/modules/field/views_handler_field_field.inc).Comment #18
anruether#12 worked for me, using dev from june 17. Seems that the code has changed since then. If I remember right, i didn't apply #5 if that makes sense...anyways, thank you so far, kevin!
Comment #19
mariagwyn commentedI am using the dev from july 02. The fix from #12 works. Any possibility this can be committed to the dev? Or are we not certain this is the solution?
Comment #20
mariagwyn commentedAgain, on most recent dev, applied #12. If this is the best solution, can it please please be committed? I get a FLOOD of errors every time I upgrade views.
Comment #21
anruetherI get this error with rc1, but only on one particular site.
Comment #22
stevieb commentedsubscribe
Comment #23
dawehnerSet status back
Comment #24
stevieb commentedI updated to the new dev today and still have the error
Comment #25
merlinofchaos commentedReporting that you continue to get the error doesn't do anyone any good:
1) There is a patch
2) the patch is marked 'needs work'
3) We will not commit bad patches. dereine explicitly said the patch does not meet code style requirements. Setting this issue back to 'needs review' without addressing what is needed to be done is disrespectful. I am in awe that later responses ignore dereine entirely. :/
There are three choices:
1) Run your patched Views with the uncommittable patch
2) Fix the coding style in the patch
3) If you're unable, get someone who can.
I am, however, not at all happy with the idea that we should commit a patch that does not conform to our requirements to fix your bug. What kind of maintainers do you think we are? If you wish to participate, please help. If you do not wish to help or are not able to help, then absolutely positively do not make demands that we change our procedures for you.
Comment #26
johnvWell, I don't think we are ignoring dereines' comments.
A short recap:
- johnv's patch #5 is effective, but merely hides symptoms, and definitely needs work to meet coding standards.
- thekevinday's patch #12 is an addition or a replacement - I really can't say. thekevinday??
- But the discussion in #8-#10 is still open: "should we fix the bug here, or in the field modules?"
Other participants, can you pinpoint your message to any contrib causing the message? See #4 for help on analyzing this.
Comment #27
mariagwyn commentedAt this point, I am a bit unclear where we are in this process, and I apologize if my request to commit something is jumping the gun. Here is where I think things in my testing process:
1. The patch in #5 doesn't apply to the most recent dev.
2. The manual fix in #12 seems to work, in that it silences the errors, and I do see any errors that I can trace to this original error in my site. I am getting other views errors, but I have no reason to think they are related.
3. I haven't the foggiest idea how to create a patch that incorporated #12. That said, I will happily test a new patch on a git version of dev as soon as one is available, and I will report back as clearly as I can my results.
Maria
Comment #28
thekevinday commented#12 is intended to be a replacement to #5.
But please keep in mind, its purpose was to directly solve the problems being reported.
There is always the possibility that the root cause is something else. (which brings you to the decision from #8 & #10)
And as a personal note, I tend to favor using watchdog to report problems so that they are reported without costing end-user experience as these here errors certainly do.
Comment #29
rfabbri commented#12 fixes the problem for me for 7.x-3.0-rc1 version.
The stange thing is I don't have this notice on my production site but only on my backup of the site...
Which is very weird... (sql + file dump mounted on a windows machine instead of a linux one)
Comment #30
dawehnerUpdate status.
So i'm wondering whether some kind of watchdog entry should be thrown here, as this seems to be a real bug somewhere else in the process.
Comment #31
W.M. commentedThe patch at #28 by thekevinday solves a similar issue I had (more information here: http://drupal.org/node/1247792#comment-4883974).
Comment #32
bvanmeurs commentedHad the same problem. Subscribing..
Comment #33
emergencyofstate commentedSubscribing
Comment #34
CarbonPig commentedsubscribe - same error mesage
Comment #35
jdcollier commentedsubscribe
Comment #36
NickWebman commentedNot sure if this is helpful: For me, the issue appears if I drop a particular Computed Field into a View. The site uses two Computed Fields - one works fine and one kicks back that error.
Comment #37
sneeuwgetsie commented#28 worked for me
txs
Comment #38
johnv@ sneeuwgetsie, You can help use finding the root cause. Which field gave you the problem? If you know some debugging, #4 might give you a hint.
Comment #39
henrijs.seso commentedMy root cause was that I had field collections in nodes view was listing and some of those nodes had fields in field collections empty.
Patches above seem to address same lines, my solution is similar
Comment #40
dawehnerAs some parts of the code there changed this patch doesn't apply anymore.
Comment #41
thekevinday commentedI am not sure what the correct behavior is, so I made two different patches.
patch a:
- This is a remake of my patch from #28.
- I am also wondering, should raw be set to an empty string or not set at all?
patch b:
- This is a remake based on #39.
- The behavior here is if the count does not exist, then completely skip the field.
- Mine is different from #39 in that I only skip if the specific count is not present, not if the items array is empty.
Comment #42
awolfey commentedPatch b-1 eliminates the notice for me, which was also caused by an empty field_collection.
Comment #43
kwongkkt commented#41 patch b-1 works for me
Comment #44
alexku commented#41 one b works for me. thank you
Comment #45
thekevinday commentedThis has been fixed upstream.
I noticed that in 3.0, the code now looks like:
Which is pretty much the same fix supplied by the patches here plus a few more checks.