Problem/Motivation
Symptoms
When configuring Rules to use data from a VBO view an error message appears:
Warning: Invalid argument supplied for foreach() in _views_bulk_operations_get_field() (line 264 of .../sites/all/modules/views_bulk_operations/views_bulk_operations.module
Steps to reproduce
- Create a view of fields containing only a Content pane display.
- Disable the Views content panes module.
- Create a second view with a VBO field.
- Create a Rules component with an action loading entities from the VBO view.
- See the error message.
Original report:
Hi guys, I have a simple view with a VBO field that I am trying to loop through in a rule. Any action or condition referring to the VBO view is throwing out this error:
Warning: Invalid argument supplied for foreach() in _views_bulk_operations_get_field() (line 264 of .../httpdocs/sites/all/modules/views_bulk_operations/views_bulk_operations.module).
Any help please?
Proposed resolution
Insert a check for a non-array value of $view->field
Remaining tasks
Review the patch.
User interface changes
Warning message naming the faulty view instead of an error message apparently connected to the VBO view.
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#4 | invalid_argument-2663056-4.patch | 890 bytes | blackra |
Comments
Comment #2
blackra CreditAttribution: blackra as a volunteer and at SK Plus commentedI am seeing this problem too. The cause is that $view->field is NULL for some views.
The view that is causing this for me has the following interesting properties:
I suspect that $view->field must be an array for any view containing a VBO field in the master display, in which case wrapping the guts of the function in a check for is_array($view->field) should be an adequate fix. However, I don't know enough about views to know what should happen when there is a VBO field in an overridden display.
I have changed the category to Bug report because this is clearly a software problem.
Comment #3
blackra CreditAttribution: blackra as a volunteer and at SK Plus commentedIt turns out that inn my case the cause of the empty $views->field was actually a missing handler. I had created a content pane display and then disabled Views content panes. Reenabling the module caused $views->field to become populated with an array once more.
I think a fix should generate a meaningful error message reporting the problematic view, especially since it will not usually be the VBO view at fault. The meaningful error message might not be able to be very specific, but at least it can report the name of the view that is at fault.
e.g. Configuration problem detected in view "faulty_view". Check for disabled modules and deleted fields.
Comment #4
blackra CreditAttribution: blackra as a volunteer and at SK Plus commentedHere is a patch to check for a non-array value of $view->field and issue a warning. This should allow Rules to correctly populate its list of available VBO fields.
Comment #5
blackra CreditAttribution: blackra as a volunteer and at SK Plus commentedComment #6
blackra CreditAttribution: blackra as a volunteer and at SK Plus commentedComment #7
joseph.olstadSymptom:
Warning: array_unique() expects parameter 1 to be array, null given in views_bulk_operations_modify_action() (line 69 of /www/d754/sites/all/modules/contrib/views_bulk_operations/actions/modify.action.inc).
For us, patch #4 prevents the above warning.
Comment #8
izmeez CreditAttribution: izmeez commentedPatch in #4 continues to apply without difficulty to the 7.x-3.x-dev 2019-05-16