I am developing a site using the current HEAD from the CVS, and have created a content type called "Release" that details a release from an artist that we manage.

The date has been saved in the database, but when I try to view the item, I get these two error messages:

Warning: Invalid argument supplied for foreach() in C:\apache2\htdocs\nhm\modules\cck\date.module on line 85

Warning: Invalid argument supplied for foreach() in C:\apache2\htdocs\nhm\modules\cck\content.module on line 878

I've had a look inside the code and it seems to come from an array called $items:

content.module:

foreach ($items as $item) {
    $output .= '<div class="field-item">'. $item['view'] .'</div>';
  }

date.module:

foreach ($items as $delta => $item) {
        $items[$delta]['view'] = content_format($field, $item, 'default', $node);
      }

In the function theme_field in content.module, I can see a reference to an array being passed in (&$items) but NOT in function date_field in date.module, so I am at a lost to what seems to be going on here?

CommentFileSizeAuthor
#5 screenshot2_2.png80.35 KBtanepiper

Comments

tanepiper’s picture

Oh, and I've got devel installed, which shows the array as correct:

field_date_of_release

Array
(
    [0] => Array
        (
            [value] => 2003-06-23
        )

)
tanepiper’s picture

Haha - I still have the problem, but I have narrowed it down. The above errors only seem to appear when Node:Body is used in a view, or at least thats when it happens for me.

I was building a custom list view to show a list of releases, and built it up one field at a time and it was only when I added Node:Body that these error started to appear. Hope this helps in tracking down the problem.

tanepiper’s picture

I've managed to define the problem even more. In a List or Table view, I still get the warning messages - but the date WILL show in the view. However, in a full node view, the date is not displayed on the screen.

karens’s picture

I can't replicate this using latest versions of everything.

Note that the body field is no longer required, thanks to a recent update to core, so in some cases it won't exist. But I tried creating a content type without a body and adding a date field and the body to the view, and then adding a body to the content type and viewing it, and in both cases it worked fine.

Just in case the fact that the handling of body changed has something to do with this, try pulling up your content type and saving it again, then pulling up your view and saving it again, then try to view it and see if there is still a problem.

tanepiper’s picture

StatusFileSize
new80.35 KB

Ok, I've deleted my views and content types and here is what I do step-by-step:

  1. First of all, create my content type Release
  • Name: Release
  • Type: release
  • Title field label:Release Name
  • Body field label:Release Details
  • Add Field
    • Label: Band
    • Field type:Node Reference (Select List)
    • Data settings: Required. Content types that can be referenced: Artist
  • Add Field
    • Label: Date of release
    • Field type: Date
    • Data settings: Required, Granularity:Date

    I then Add a test release, this is without yet defining a view (as I have deleted my previous view) and I still get the error of the date not showing. I've attached a screenshot to show this not working.

    Here is the output from devel load

    
    nid
    17
    vid
    17
    type
    release
    status
    1
    created
    1163605537
    changed
    1163605537
    comment
    0
    promote
    0
    sticky
    0
    revision_timestamp
    1163605537
    title
    Test
    body
    Test
    teaser
    Test
    log
    format
    3
    uid
    1
    name
    admin
    picture
    data
    a:4:{s:2:"op";s:6:"Submit";s:6:"submit";s:18:"Create new account";s:7:"form_id";s:13:"user_register";s:10:"form_token";s:32:"a6fefa7fe8d4ad3747e04c642d53e308";}
    field_band
    
    Array
    (
        [0] => Array
            (
                [nid] => 4
            )
    
    )
    
    field_date_of_release
    
    Array
    (
        [0] => Array
            (
                [value] => 2006-11-15
            )
    
    )
    
    taxonomy
    
    Array
    (
    )
    
    
    karens’s picture

    Are you sure you have latest versions? Your screenshot indicates an error on line 85 of the date module and there is no array on that line in the current version. Also, there is no such thing as Granularity:Date so I don't know what you selected there.

    tanepiper’s picture

    Contributions Directory:
    :pserver:anonymous@cvs.drupal.org:/cvs/drupal
    Repository: contributions
    Sticky tag/date: Head

    Drupal Directory:
    :pserver:anonymous@cvs.drupal.org:/cvs/drupal
    Repository: drupal
    Sticky tag/date: Head

    So I assume, yes I am running the current versions? Tell me if I'm wrong? It's definetly version 5 of Drupal I am running, and CCK and the date.module (from the header: // $Id: date.module,v 1.25 2006/10/24 12:16:16 karens Exp $)

    I am running the date.module from my CCK directory, not from it's own one, could that be affecting it?

    tanepiper’s picture

    Ahh, thats seems to have been the problem all along! I removed the files from my CCK directory and uploaded date to it's own directory in the modules directory, and the admin fields have changed!

    I'll give it a try now.

    tanepiper’s picture

    Assigned: Unassigned » tanepiper
    Priority: Critical » Minor
    Status: Active » Closed (fixed)

    Yep, that fixed the problem

    karens’s picture

    Good. Thanks for reporting back instead of leaving this open!