Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#4 | 1056718-media-empty-list-error-2.patch | 453 bytes | MaxWesten |
#1 | 1056718-media-empty-list-error.patch | 561 bytes | MaxWesten |
Comments
Comment #1
MaxWesten CreditAttribution: MaxWesten commentedThe patch to fix this problem.
Comment #2
MaxWesten CreditAttribution: MaxWesten commentedForgot to change the issue status.
Comment #4
MaxWesten CreditAttribution: MaxWesten commentedretrying patch with removed relative paths.
Comment #5
MaxWesten CreditAttribution: MaxWesten commentedtrying again
Comment #6
JacobSingh CreditAttribution: JacobSingh commentedCommitted 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);
Comment #8
anniegreens CreditAttribution: anniegreens commentedThis 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.
Neither the 7.x-1.0-dev nor 7.x-2.x-dev snapshots include the above conditional. Was this patch ever applied?
Comment #9
echoz CreditAttribution: echoz commentedSeeing 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
Comment #10
dgastudio CreditAttribution: dgastudio commentedhttp://localhost/admin/content/media/thumbnails
same here. last dev. version
Comment #11
rszrama CreditAttribution: rszrama commentedGetting 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()
Comment #12
rszrama CreditAttribution: rszrama commentedI'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:
Create an issue branch locally:
Pull and rebase from me (in case something gets committed before you review this):
Test and confirm the fix then merge back into your dev branch and push:
Lemme know if I screwed up the instructions. ; )
Commit diff: http://drupalcode.org/sandbox/rszrama/1275404.git/commitdiff/4fa0cea9e6f...
Comment #13
mallezieI can confirm this bug for media 1 RC
Comment #14
BAM5 CreditAttribution: BAM5 commentedThis bug still exists in 7.x-1.0-rc2
Comment #15
rszrama CreditAttribution: rszrama commentedHmm, 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?
Comment #16
Dave ReidAssigning for review.
Comment #17
Dave ReidOk 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