I added Viewfield to my Page content type and it works! The only problem is that on the edit/create page of any content type Page the following warning message: "invalid argument supplied for foreach() in /httpdocs/sites/default/modules/viewfield/viewfield.module on line 279" is displayed.
I have searched for a possible cause and/or solution for this warning and have had zero success. I thought I was on to something when I found this previous issue: http://drupal.org/node/646766 but it was marked duplicate of http://drupal.org/node/831574 and closed. However, the warning message in "#831574: Warning in array filter" is not same warning message I am receiving or the same warning message in http://drupal.org/node/646766 which seemingly documents the exact issue I am having.
In other words, I still don't know why I am receiving this warning message.
I am using the latest recommended release 6.x-1.0, but I also tried the development release 6.x-1.x-dev and I still receive the same error message.
Any help would be greatly appreciated.
Thanks in advance!
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | test-for-deleted-view-1048516-11.patch | 805 bytes | keithm |
| #6 | missing_test_view_display_exists-1048516-6.patch | 721 bytes | goz |
Comments
Comment #1
tritof commentedHi
I had the same problem today, it appears first when I was adding new books with root-nodes of secondary links (the 2 content types have the viewfield embedded with CCK, first added to page and then duplicated to bookpage). Not sure, but it may be related...
The warning message disapear when I click once to go somewhere else in the website.
Cheers
Comment #2
sunCan you provide the PHP warning message (including file and line info) when running on 1.x-dev, please?
Comment #3
lel commentedThank you for the responses and I sincerely apologize for taking so long to respond.
The book module is not enable on my website.
The warning for 1.x dev is as follows:
"warning: Invalid argument supplied for foreach() in /var/www/vhosts/domain-name.com/httpdocs/sites/default/modules/viewfield/viewfield.module on line 277."
Comment #4
shane.hairston commentedsubscribing
Comment #5
keithm commentedIn the development version 6.x-1.x, the viewfield.module code around line 277 has been rewritten at this point. Please try this version and reopen if the problem recurs.
Comment #6
goz commentedI have same issue if my view only have default display.
I make a patch to resolve this (i just make git pull so the patch has been done on the last 6.x-1.x commit).
Comment #7
keithm commented@GoZ Thanks for your patch, but I cannot duplicate this problem with viewfield-6.x-1.x-dev and views-6.x-2.12. I don't understand how any view with a single default display can have
isset($view->display) == FALSE. Please provide specific steps to reproduce the problem.EDIT: Corrected
$view->defaultto$view->display.Comment #8
goz commentedProblem is not
isset($view->default) == FALSEbutisset($view->display) == FALSETo reproduce this, make a view with only default display. Don't create displays.
During node creation, in your cck field, choose this view and submit your form. Message appear.
Error message only appear at submission.
The view correctly displays in the node, no error during node display.
Comment #9
keithm commented@GoZ I still cannot reproduce your problem.
This is what I tried.
Created a view 'test_view'. If I don't customize anything, attempting to save the view produces the message 'Display "Defaults" uses fields but there are none defined for it or all are excluded.' so I added single field, Node Title. At this point the test_view can be saved and run; it produces a list of all node titles linked to a node. Then I added a new viewfield to the Story content type. When adding it, I examined the value of
$view->displayin_viewfield_potential_references()using a debugger. Every view, including test_view, had a valid display property, and I received no warning. Then I updated the values in a Story node that existed before the viewfield was created by selecting 'test_view | Defaults' and no argument. Still no warning. Viewing the node shows that the viewfield is running test_view correctly.Comment #10
goz commented@keithm : I found why this error display. In
_viewfield_potential_references(), you make foreach on$field['allowed_views']but if in your cck viewfield (in content type cck settings) you select a view that you delete later, this view always be stored in cck viewfield (until you submit cck viewfield content type again).So you make foreach on
allowed_viewsstored and makeviews_get_viewof a view that doesn't exist anymore.To reproduce :
Make test view.
In your content type cck settings, add this view to your cck viewfield.
Delete this view
Create content of your content type. Error message display.
Go to your content type cck settings, submit your cck viewfield settings (view deleted has disapeard from checkbox)
No more error message.
So you should test
!empty($view)beforeforeach ($view->displayComment #11
keithm commented@GoZ Now this makes sense to me. Thanks for investigating. Patch attached.
Comment #12
sunLooks ready for me. For D7, we should create a separate issue and discuss proper error handling (throwing an error message, watchdog log message, field value validation, implementing views hooks to react on deletion of views, etc)
Comment #13
keithm commentedCommited in http://drupalcode.org/project/viewfield.git/commit/879ca47, http://drupalcode.org/project/viewfield.git/commit/59c79f1, and http://drupalcode.org/project/viewfield.git/commit/450a2cc (D7, for now). Opened new D7 issue #1168386: Handle deleted views in allowed_views list.