I get the following errors below and not sure how to fix.
Using Views 3.0 Alpha 3
Any help would be appreciated.
* warning: Invalid argument supplied for foreach() in /private/var/www/drupal-6.16/sites/all/modules/views/plugins/views_plugin_display.inc on line 679.
* warning: Invalid argument supplied for foreach() in /private/var/www/drupal-6.16/sites/all/modules/views/plugins/views_plugin_display.inc on line 679.
* warning: Invalid argument supplied for foreach() in /private/var/www/drupal-6.16/sites/all/modules/views/plugins/views_plugin_display.inc on line 679.
* warning: Invalid argument supplied for foreach() in /private/var/www/drupal-6.16/sites/all/modules/views/plugins/views_plugin_display.inc on line 679.
* warning: Invalid argument supplied for foreach() in /private/var/www/drupal-6.16/sites/all/modules/views/plugins/views_plugin_display.inc on line 679.
****
AND
****
* warning: Invalid argument supplied for foreach() in /private/var/www/drupal-6.16/sites/all/modules/views/includes/admin.inc on line 1312.
* warning: Invalid argument supplied for foreach() in /private/var/www/drupal-6.16/sites/all/modules/views/includes/admin.inc on line 1312.
* warning: Invalid argument supplied for foreach() in /private/var/www/drupal-6.16/sites/all/modules/views/includes/admin.inc on line 1312.
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | views-3-plugin_display-option_defaults-792184.patch | 1.16 KB | mgriego |
| #24 | view.txt | 5.57 KB | agentrickard |
| #22 | 792184-display.patch | 388 bytes | agentrickard |
| #13 | Picture 1.png | 71.41 KB | agentrickard |
| #13 | exported.txt | 1 KB | agentrickard |
Comments
Comment #1
agentrickardThis happened to me, too. After I cloned a view and removed some of its displays. Not sure what's going on.
Comment #2
dawehnerSadly i cannot reproduce the problem
Agentrickard: Are you using views plugins, or is this a problem for views, too?
Comment #3
hase jsea commentedI also have same problem.
I only tried to clone Calendar view... then same warning appear.
Comment #4
keva commentedsame issue as op and #1, not sure what the question in #2 refers to. The Views Plugins module has no releases.
header, footer, empty text, relationships: no
fields, arguments, sort criteria, filters: yes
EDIT:
the original view had a block display. When I deleted the block display from the cloned view, the Invalid Argument messages went away.
Comment #5
dawehnerCould you please provide an export where this error appears?
When its reproducible this should be fixable
Comment #6
keva commentedthis is the cloned view, still containing the Block Display:
Comment #7
dawehnerupdate status
Comment #8
agentrickardBit us again when exporting Views to code. Investigating.
Comment #9
agentrickardStill not sure of the cause, but this makes the errors go away:
This is happening primarily when using a style plugin that overrides the default display. Which I see is also the case in #6.
$handler->display->display_options['defaults']['style_plugin'] = FALSE;Comment #10
agentrickardAnother patch attempt. Unfortunately, our test server is down, so I can't roll a proper patch.
Line 588 of views_plugin_display.inc:
In the tests I was running on @keva's view, the display element for the block handler was returning NULL for the 'arguments' option of the display_handler. Returning an empty array here eliminates the error and allows the display to return correctly.
Comment #11
agentrickardComment #12
agentrickardDoing that can expose other errors, as arrays get passed to t(), so that's not right either.
Comment #13
agentrickardIt looks like some elements of the option definition are not getting exported correctly. In my case, we're using Mapstraction plugin, and it breaks whenever cloned or exported.
On export, several of the field definitions are simply dropped by Views.
Picture 1, below, shows the plugin options as defined by the View when it is stored in the database.
The attachment shows how that data is exported by Views.
I wonder if this is an API change that hasn't filtered down yet, but I suspect it is also happening in other cases of this issue.
Comment #14
agentrickard@keva
Are any settings definitions missing from your exported View?
Comment #15
merlinofchaos commentedTook a quick peek at mapstraction's style.
That option_definition() code is invalid.
Compare to the one from Views' on table style:
There's a couple of items in mapstraction that are properly using the 'default' keyword. The rest are not. Also, the 'initial_point' should be using the 'contains' keyword so that Views will properly drilldown.
Views 3.x will be much more sensitive to these incorrect definitions than 2.x was.
Comment #16
agentrickardAnd I notice that @keva is using node_hierarchy, so I wonder if that module has the same API problem.
@merlinofchaos
So you mean something like:
/me is looking for good sample code or API docs.
views_plugin_display_pageseems to be a good example.Comment #17
agentrickardMoving to support request, unless the maintainers want to allow for V2 => V3 exception handling. mapstraction issue moved #810240: Views3 API changes
Comment #18
keva commentedagentrickard, what are "settings definitions"? (#14)
these are the steps:
- cloned the original view
- edited $view->name and $view->description
- removed a field from the default display only (broken/missing handler)
- even with above field removed, both error messages are still generated
Comment #19
agentrickardThe forms you use to set display options, particularly for the display style itself. Make sure each option in the UI form is present in the exported View.
In my case, 5 or 6 settings were getting dropped because they were not using the API correctly.
I would look here, in particular:
Comment #20
keva commentedthe only thing missing is the entire broken/missing handler field that I deleted.
otherwise, the code for both views are identical. It only had one block display.
Comment #21
agentrickardI'm seeing this behavior with block displays as well.
Comment #22
agentrickardThe problem is that the options are not defaulted, but also not set, so the call to get_options() method fails.
Patch fixes the symptoms, but not the cause of the issue. In my case, the following calls to get_options() fail:
This is for a block display, using default values.
Comment #23
agentrickardThis patch, of course, ends up passing an empty array to check_plain(), for some %$#@! reason, throwing a different error.
Comment #24
agentrickardHere's a view that is erroring out for me.
Comment #25
merlinofchaos commentedNone of these items are valid for a block display in Views 3.x:
Pager options have moved to the pager plugin. You should probably retrieve those options via the plugin: $pager = $display->get_plugin('pager'); $pager->get_items_per_page();
header and footer are now pluggable handlers. I think they're now $display->get_option('headers')
Block displays have no 'path'.
Comment #26
agentrickardRight, but why is the block display handler asking for these items?
Comment #27
mgriego commentedWe're seeing this problem for an exported view that has no arguments in the default display. When $this->get_option($plural) is called is get_handlers(), where $plural == "arguments", get_option() does not return anything, so the foreach() in get_handlers() errors out.
Comment #28
agentrickardThe items above are a red herring. The problem seems to be:
1) Create a view with multiple displays.
2) Create default arguments, filters, or empty text (a handler) and add some values.
3) Override the defaults in a display.
4) Remove all default elements (so that, say, the block display has no filter, but the default does).
5) Watch error appear.
/me goes to test.
Still cannot replicate on a newly created view. May be related to import/export definitions. I just don't know.
Comment #29
mgriego commentedActually, I found the issue. Took a fair amount of digging.
It turns out the problem is the fact that _set_option_defaults() is overridden for views_plugin_display. This method attempts to intelligently control whether the default option is applied based on the defaults set in the option_definition(). This, however, is completely unnecessary, and the default options should still be applied to avoid issues later (like this one). Since get_option() *first* checks to see if the option is defaulted or not, it will apply the default_display option if the option is defaulted, so having _set_option_defaults() try to selectively apply the option defaults is unnecessary. In addition, as I said, it causes problems later (which is what this issue is about), because _set_option_defaults() doesn't apply the option default. If the option is *not* defaulted, but it's set to the default *for* that option (such as an empty array for arguments, etc), then the default is not applied, which causes it to become an undefined option which then causes problems that expect at least the default to be available (such as get_handlers() does).
As it turns out, because get_option() is intelligent enough to use the default_display option when the option is defaulted, the default _set_option_defaults() from the views_object defined in base.inc is exactly what should be used. So all that's needed is to remove the _set_option_defaults() override for views_plugin_display. Patch to do so is attached.
Comment #30
cannedbrain commentedConfirmed. I also started getting errors after cloning a view that had a block module. Deleted the block on the cloned view nd recreated it manually made the errors dissapear.
Comment #31
stroobl commentedThe patch in #29 fixed it for me.
Comment #32
jlmeredithThe patch in #29 fixed it for me.
Comment #33
nycm commentedThe patch in #29 fixed it for me.
Comment #34
mgriego commentedEnough to mark this as RTBC?
Comment #35
mrgoltra commentedsubscribing
Comment #36
dtarc commentedThe patch in #29 worked for me on the Aug 1st dev snapshot. Thanks for the patch mgriego.
Comment #37
jrabeemer commentedThis needs to get patched ASAP. Are we happy this is RTBC?
Comment #38
sgabe commentedSame problem here, it seems the patch in #29 fixed it.
Comment #39
merlinofchaos commentedThat's quite a few tests saying this works, and there's no actual code to review. Committing, let's see if this comes back to bite us.
Comment #41
luthien commentedI'm using Views 6.x-3.0-alpha3, the code that needs to be removed as per patch #29 is still there. Was this patch committed for Views 3?
Comment #42
luthien commentedI think this patch needs to be committed for the 3.0-alpha3 version.
Comment #43
dawehnerIt's commited against the dev version of views3, so it's not part of 6.x-3.0-alpha3
Comment #44
summit commentedbookmarking, waiting for alpha4 in production site.
greetings, Martijn
Comment #45
dcarr commentedsubscribing
Comment #46
jasloe commentedSubscribing
Comment #47
aiphesthis append after upgrade from views 2..the error appear after that..
suscribe for a patch
Invalid argument supplied for foreach() dans /sites/all/modules/views/plugins/views_plugin_display.inc à la ligne 824.