Hi:

I'm getting the following notices and warnings when submitting an edit form after adding or changing a media field.

    *  Notice: Undefined index: elements in ds_entity_variables() (line 474 of /var/aegir/platforms/bwaslala/build-7.x-x-dev/sites/all/modules/ds/ds.module).
    * Notice: Undefined index: elements in ds_entity_variables() (line 474 of /var/aegir/platforms/bwaslala/build-7.x-x-dev/sites/all/modules/ds/ds.module).
    * Notice: Undefined index: elements in ds_entity_variables() (line 474 of /var/aegir/platforms/bwaslala/build-7.x-x-dev/sites/all/modules/ds/ds.module).
    * Notice: Undefined index: view modes in field_view_mode_settings() (line 630 of /var/aegir/platforms/bwaslala/build-7.x-x-dev/modules/field/field.module).
    * Warning: Invalid argument supplied for foreach() in field_view_mode_settings() (line 630 of /var/aegir/platforms/bwaslala/build-7.x-x-dev/modules/field/field.module).

I've reviewed line 474 in ds.module and can see a lot of references in ds_entity_variables() and ds_render_block_field() to 'elements'... Shouldn't this be 'element'???

Or perhaps I'm missing something.

Thanks.-

CommentFileSizeAuthor
#8 1155148.patch691 bytesswentel

Comments

swentel’s picture

Hrm, that's weird, that would suck if media sends it differently :(

chriz001’s picture

same problem here.

neurojavi’s picture

Media sends a variables array with an 'element' index but DS expects an 'elements' index. So Media is sending it wrong, isn't it?

This is what I'm receiving (it looks like a form field setting array, doesn't it??). How is this happening? I don't know...

I think we should move this issue to media module, do you agree?

#
... (Array, 2 elements)

    *
      element (Array, 22 elements)
          o
            #type (String, 4 characters ) file | (Callback) file();
          o
            #title (String, 17 characters ) Upload a new file
          o
            #description (String, 127 characters ) Allowed file types: <strong>jpg jpeg gif png tx...
                +
                  Allowed file types: <strong>jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp mp3 mov m4v mp4 mpeg avi ogg wmv ico</strong>.
          o
            #upload_validators (Array, 2 elements)
                +
                  file_validate_extensions (Array, 1 element)
                      #
                        0 (String, 89 characters ) jpg jpeg gif png txt doc xls pdf ppt pps odt od...
                            *
                              jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp mp3 mov m4v mp4 mpeg avi ogg wmv ico
                +
                  media_file_validate_types (Array, 1 element)
                      #
                        0 (Array, 1 element)
                            *
                              image (String, 5 characters ) image
          o
            #input (Boolean) TRUE
          o
            #size (Integer) 60
          o
            #theme (String, 4 characters ) file | (Callback) file();
          o
            #theme_wrappers (Array, 1 element)
                +
                  0 (String, 12 characters ) form_element
          o
            #defaults_loaded (Boolean) TRUE
          o
            #tree (Boolean) FALSE
          o
            #parents (Array, 1 element)
                +
                  0 (String, 6 characters ) upload
          o
            #array_parents (Array, 1 element)
                +
                  0 (String, 6 characters ) upload
          o
            #weight (Integer) 0
          o
            #processed (Boolean) FALSE
          o
            #required (Boolean) FALSE
          o
            #attributes (Array, 0 elements)
          o
            #title_display (String, 6 characters ) before
          o
            #id (String, 11 characters ) edit-upload
          o
            #name (String, 13 characters ) files[upload]
          o
            #value (String, 0 characters )
          o
            #sorted (Boolean) TRUE
          o
            #children (String, 0 characters )
    *
      theme_hook_suggestions (Array, 0 elements)
swentel’s picture

Are you getting these errors on display or during node edit form ? If so, somehow DS is triggered, I'll investigate myself also this weekend (which version of media are you using)

nerilka’s picture

Hi,
I got almost the same problem, during the checkout of an order :

Notice : Undefined index: elements in ds_entity_variables() (line 474 in C:\wamp\www\drupal-7.0_kickstart\sites\all\modules\ds\ds.module).
Notice : Undefined index: elements in ds_entity_variables() (line 474 in C:\wamp\www\drupal-7.0_kickstart\sites\all\modules\ds\ds.module).
Notice : Undefined index: elements in ds_entity_variables() (line 474 in C:\wamp\www\drupal-7.0_kickstart\sites\all\modules\ds\ds.module).
Notice : Undefined index: view modes in field_view_mode_settings() (line 630 dans C:\wamp\www\drupal-7.0_kickstart\modules\field\field.module).
Warning : Invalid argument supplied for foreach() dans field_view_mode_settings() (ligne 630 dans C:\wamp\www\drupal-7.0_kickstart\modules\field\field.module).

It's a fresh profile install (drupal commerce kickstart), just added a product et 'bought' it. When the checkout was done, no more warning message...

caschbre’s picture

I'm getting a similar error myself. It was weird how I came across it.

1) Navigate to admin/content
2) Click on the media tab (admin/content/media)
3) Click on the + Add file link
4) Click on the Web tab
5) Click cancel
6) Navigate to any page

If I hit refresh or navigate to another page the error messages disappear.

Notice: Undefined index: elements in ds_entity_variables() (line 474 of /example.com/sites/all/modules/contrib/ds/ds.module).
Notice: Undefined index: elements in ds_entity_variables() (line 474 of /example.com/sites/all/modules/contrib/ds/ds.module).
Notice: Undefined index: elements in ds_entity_variables() (line 474 of /example.com/sites/all/modules/contrib/ds/ds.module).
Notice: Undefined index: view modes in field_view_mode_settings() (line 630 of /example.com/modules/field/field.module).
Warning: Invalid argument supplied for foreach() in field_view_mode_settings() (line 630 of /example.com/modules/field/field.module).

heyyo’s picture

I have the same error with Drupal Commerce by creating a product (with Display Suite 7.x-1.1)

swentel’s picture

Status: Active » Needs review
StatusFileSize
new691 bytes

This patch will fix the notices at least.

However, I've looked into media and I think the problem is simple, they have a theme item for their entity and this is part of hook_theme(). As you can see, they're using 'element' , but core (and also entity api) are using 'elements'. Note, I'm not sure if this is causing the error (completely untested), but it might be a hint. I'll try to investigate later (others are welcome too of course), but if this is the case, than those modules should just simple follow core.

    // A preview of the uploaded file.
    'media_thumbnail' => array(
      'render element' => 'element',
      'file' => 'includes/media.theme.inc',
    ),


    'media_element' => array(
      'render element' => 'element',
      'file' => 'includes/media.theme.inc',
    ),
khiminrm’s picture

subscribe

anthonyR’s picture

Confirming the same as in #5 and #7 with Commerce on checkout, using DS 7.x-1.1
New issue post needed to split up the commerce + ds and media + ds issue?

swentel’s picture

@anthonyR maybe not, I think the patch is probably just fine because

a) it fixes the notices
b) ds keeps working for normal displays of entities (and not in obscure places where entities are also used for display but DS has no business being there)

swentel’s picture

Status: Needs review » Fixed

Committed this as is. Found a couple of other minor notices with non core related entities which are gone now too.

betz’s picture

can confirm this patch works

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

moonray’s picture

Status: Closed (fixed) » Needs work

Latest version of DS this error is back... not necessarily related to media module for me. But the patch still works.

swentel’s picture

Status: Needs work » Closed (cannot reproduce)

But that patch is in ... I need exact lines of the notice.

mlncn’s picture

moonray’s picture

Heh... ok, so the patch uses $variables not $vars (which is what's in the file). So... basically not triggering the content of the if statement fixes the problem. Not very helpful, huh? But at least that means the contents of that if statement are where the problem is. Going to see if I can track it down.

moonray’s picture

Well, I can't find it anymore, so I guess that's a good thing.