Upgrade from rc4 to rc5 (CCK is at rc10).
Table view is giving
warning: Invalid argument supplied for foreach() in /srv/www/www.rscounselling.co.uk/htdocs/sites/all/modules/views/theme/views-view-... on line 22.
Seems like $rows is empty? The SQL that the view is running is:
SELECT node.nid AS nid FROM node node WHERE (node.status <> 0) AND (node.type in ('link'))
And in the db that is showing me
+-----+
| nid |
+-----+
| 27 |
| 28 |
| 29 |
| 30 |
+-----+.
View cache has been cleared - no change.
Here's the view:
$view = new view;
$view->name = 'Links';
$view->description = 'External Links';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
'field_url_url' => array(
'label' => '',
'link_to_node' => 0,
'label_type' => 'none',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_url_url',
'table' => 'node_data_field_url',
'field' => 'field_url_url',
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => 1,
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'type' => array(
'id' => 'type',
'table' => 'node',
'field' => 'type',
'value' => array(
'link' => 'link',
),
),
));
$handler->override_option('access', array(
'type' => 'none',
'role' => array(),
'perm' => '',
));
$handler->override_option('title', 'Links');
$handler->override_option('header_format', '1');
$handler->override_option('footer_format', '1');
$handler->override_option('empty_format', '1');
$handler->override_option('items_per_page', '10');
$handler->override_option('use_pager', TRUE);
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
'grouping' => '',
'override' => 1,
'sticky' => 0,
'order' => 'asc',
'columns' => array(
'field_url_url' => 'field_url_url',
),
'info' => array(
'field_url_url' => array(
'sortable' => 0,
'separator' => '',
),
),
'default' => '-1',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'links');
$handler->override_option('menu', array(
'type' => 'normal',
'title' => 'Links',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => NULL,
'weight' => NULL,
));
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | 318944-table_error.patch | 392 bytes | dawehner |
Comments
Comment #1
chrissearle commentedCould well be a link field issue - see http://drupal.org/node/319463
Comment #2
merlinofchaos commentedYea, I can't get this to happen with another field. If it only happens with the link field, something may be broken in the handler causing the field to not appear. Because there are no OTHER fields it's causing an error.
Comment #3
chrissearle commentedOK - we'll follow it on http://drupal.org/node/319463
Do I understand you correctly that you did manage to repeat it with link?
Comment #4
merlinofchaos commentedI didn't; I don't have link.module installed. =)
Comment #5
smithmb commentedI can still reproduce this with 6.x-2.2 without using any extra modules except CCK, Views 2, and some content types. It appears to happen when the visitor doesn't have access to view any of the resulting rows in the view. It only comes up in table style. I'm using nodereference for the fields to display in the view.
Also, changing permissions on the referenced nodes (to allowing anonymous views of the ref'd nodes) doesn't make the problem go away until I rebuild the permissions cache.
I think this is probably somewhat widespread, given the results to:
http://www.google.com/search?q=views-view-table.tpl.php+"line+22"
Comment #6
smithmb commentedComment #7
tomsherlock commentedI too am experiencing the invalid argument in views-view-table.tpl.php.
I first experienced the error in 6.x-2.5, then i upgraded to 6.x-2.6 thinking the upgrade might clear up the problem. I have Drupal 6.12.
I created a view displaying fields from node type 'profile'. I did not realized that i had a problem until i attempted to display the view with an authenticated user without admin rights. In other words, when i display the view from userid 1, i have no problem.
I do NOT have the link.module enabled.
I have read http://drupal.org/node/319463. Doesn't apply.
I have traced the code once with eclipse and got lost. I will try again. I cannot find in the code the text: "warning: Invalid argument supplied for foreach()".
I have the view accessible only to authenticated users. So that the menu item does not show when logged out. Originally i had set permission for anonymous to access all views. Thinking this was the problem i removed that permission from anonymous. I move that permission to authenticated user. I still had the problem. I removed the permission from authenticated user and have it set only for the editor role. I still have the problem.
I thought clearing the cache might help. It didn't.
I thought the data might be corrupt. The profile type i created has a firstname field and lastname field. I had one profile in which these fields were blank. I got rid of that profile. i still have the problem.
The view and sql appear to reference a table that does not exist on the database: node_data_field_firstname. Is this a placeholder for the table
content_type_profile and field field_firstname_value?
Hopefully someone can assist.
-Tom
Comment #8
tomsherlock commentedOne difference i've noticed is that the $header variable is uninitialized when the user's role is authorized user only. However, $header is initialized with two elements (one for each column header) for userid 1 (admin).
I'm trying now to figure out where $header is declared and initialized and why the difference in user should matter.
Comment #9
tomsherlock commentedSigh.
I figured out the cause of my problem.
Comment #10
tomsherlock commentedO.K.
I just couldn't help myself. So often i see solution seekers saying "figured it out. I don't need your help anymore" and leaving the rest of us high and dry.
Well i am deservedly embarrassed (and grateful [greatful]) to say that my mountain is but a molehill: i simply forgot to set the correct view permissions for the fields under User Management >> Permissions.
I would be nice if eventually, the error thrown in this case would be something along the lines of "permission to view field denied. Check permissions under User Management or check with the webmaster/administrator". Not sure where such an error would be generated, views or core. Perhaps this requires another level of abstraction, or coding to check for such things such as that permission set for a role, etc.
Thanks for all your past and ongoing efforts and contributions, Earl. It's miles above anything i may ever be able to do Drupal. That i may be proven erroneous.
Tom
Comment #11
merlinofchaos commentedThanks very much for the explanation. It's always very helpful to know why things went wrong.
You're right that table should possibly be a little nicer about this kind of failure. It shouldn't be too difficult. Changing title to update status. This could use a patch.
Comment #12
tjjacobsen commentedJust did the same thing! I wouldve wasted a couple of hours trying to figure it out. Thanks a ton.
-Todd
Comment #13
merlinofchaos commentedAdding a tag.
Comment #14
ThaiGringo commentedI found I had done the same thing and forgot to assign permissions to my CCK fields. Your documentation of your issue helped save me time, also. Thanks.
Comment #15
dawehnerI think this should fix the php error problem
Comment #16
merlinofchaos commentedCommitted to all branches.