when going to the URL: /admin/content/media if no media is available and the display mode is thumbnail view, the errors

  * Notice: Undefined index: media in media_admin_thumbnails() (line 165 of /Users/mwesten/Sites/drup7max/dlmax/sites/default/modules/contrib/media/media.admin.inc).
  * Warning: array_keys(): The first argument should be an array in media_admin_thumbnails() (line 165 of /Users/mwesten/Sites/drup7max/dlmax/sites/default/modules/contrib/media/media.admin.inc).

are shown.

The patch for this error is attached to the next comment.

Files: 
CommentFileSizeAuthor
#4 1056718-media-empty-list-error-2.patch453 bytesMaxWesten
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
#1 1056718-media-empty-list-error.patch561 bytesMaxWesten
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1056718-media-empty-list-error.patch.
[ View ]

Comments

MaxWesten’s picture

StatusFileSize
new561 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1056718-media-empty-list-error.patch.
[ View ]

The patch to fix this problem.

MaxWesten’s picture

Status:Active» Needs review

Forgot to change the issue status.

Status:Needs review» Needs work

The last submitted patch, 1056718-media-empty-list-error.patch, failed testing.

MaxWesten’s picture

StatusFileSize
new453 bytes
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

retrying patch with removed relative paths.

MaxWesten’s picture

Status:Needs work» Needs review

trying again

JacobSingh’s picture

Status:Needs review» Fixed

Committed something similar to this. Thanks for helping out!

cvs diff -u -r1.27 -r1.28 media.admin.inc
Index: media.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/media/media.admin.inc,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- media.admin.inc 1 Feb 2011 17:44:42 -0000 1.27
+++ media.admin.inc 16 Feb 2011 03:39:24 -0000 1.28
@@ -1,5 +1,5 @@
<?php
-// $Id: media.admin.inc,v 1.27 2011/02/01 17:44:42 JacobSingh Exp $
+// $Id: media.admin.inc,v 1.28 2011/02/16 03:39:24 JacobSingh Exp $

/**
* @file
@@ -162,7 +162,7 @@
$query->entityCondition('entity_type', 'media');

$result = $query->execute();
- $ids = array_keys($result['media']);
+ $ids = key_exists('media', $result) ? array_keys($result['media']) : FALSE;
if ($ids) {
$media_entities = entity_load('media', $ids);

Status:Fixed» Closed (fixed)

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

anniegreens’s picture

Version:7.x-1.x-dev» 7.x-2.x-dev
Status:Closed (fixed)» Active

This issue still appears to be unresolved, as it still exists in 7.x-1.0-beta5 and in recently upgraded 7.x-2.x-dev.

Notice: Undefined index: file in media_admin_thumbnails() (line 165 of /Applications/XAMPP/xamppfiles/htdocs/drupal-7.4/sites/all/modules/media/includes/media.admin.inc).
Warning: array_keys() expects parameter 1 to be array, null given in media_admin_thumbnails() (line 165 of /Applications/XAMPP/xamppfiles/htdocs/drupal-7.4/sites/all/modules/media/includes/media.admin.inc).

Neither the 7.x-1.0-dev nor 7.x-2.x-dev snapshots include the above conditional. Was this patch ever applied?

echoz’s picture

Seeing this with Media 7.x-2.x-dev from Aug 16 and Drupal7.7
I'm also not finding that code in media.admin.inc

kervi’s picture

http://localhost/admin/content/media/thumbnails

    Notice: Undefined index: file in media_admin_thumbnails() (line 165 of /home/u4388/domains/yoga.u4388.citrine.vps-private.net/sites/all/modules/media/includes/media.admin.inc).
    Warning: array_keys() [function.array-keys]: The first argument should be an array in media_admin_thumbnails() (line 165 of /home/u4388/domains/yoga.u4388.citrine.vps-private.net/sites/all/modules/media/includes/media.admin.inc).

same here. last dev. version

rszrama’s picture

Getting the same error. I also just closed a duplicate report that proposed a solution (but without a patch): #1244280: Undefined index: file in media_admin_thumbnails()

rszrama’s picture

Status:Active» Needs review

I've committed a fix for this to my sandbox that does a little better than the issue I linked above. We want to keep the $form['files'] array with its container div and ul, so I put a "No media available." message inside of an li in $form['files']['message'] of the EntityFieldQuery returns no file results.

I'm going to be doing some investigation into Media for a client, so I've created a sandbox for my development. I use issue specific branches (though I did screw up a bit and duplicate this commit in my 7.x-2.x branch :-/). You can add me as a remote:

git remote add rszrama http://git.drupal.org/sandbox/rszrama/1275404.git

Create an issue branch locally:

git checkout -b rszrama-1056718

Pull and rebase from me (in case something gets committed before you review this):

git pull rszrama 1056718
git rebase 7.x-2.x

Test and confirm the fix then merge back into your dev branch and push:

git checkout 7.x-2.x
git merge rszrama-1056718
git push
git branch -d rszrama-1056718

Lemme know if I screwed up the instructions. ; )

Commit diff: http://drupalcode.org/sandbox/rszrama/1275404.git/commitdiff/4fa0cea9e6f...

mallezie’s picture

I can confirm this bug for media 1 RC

BAM5’s picture

Version:7.x-2.x-dev» 7.x-1.0-rc2

This bug still exists in 7.x-1.0-rc2

rszrama’s picture

Version:7.x-1.0-rc2» 7.x-2.x-dev

Hmm, my patch is actually against the 2.x branch, b/c at the time I didn't realize 1.x was where all the activity was. It probably won't work as is on 1.x and would need to be rerolled. I could be wrong, but perhaps it should be fixed in 2.x first then backported?

Dave Reid’s picture

Assigned:Unassigned» Dave Reid

Assigning for review.

Dave Reid’s picture

Status:Needs review» Fixed

Ok this is officially fixed with 7.x-2.x and 7.x-1.x with the following commits:
http://drupalcode.org/project/media.git/commit/910aa75
http://drupalcode.org/project/media.git/commit/3555e85

Status:Fixed» Closed (fixed)

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