Whenever I go to upload a file with the Media Browser enabled, the "My Files" and the "Library" tabs in the pop-up overlay are always blank, even though I have uploaded dozens of files through this widget.

When I edit that view (the one that the overlay uses for those two tabs), the files show up properly. Just not when viewed in the overlay.

I should mention that I am viewing all this as the administrator, so it shouldn't be a permissions problems (I have all permissions enabled).

Comments

amaisano’s picture

Issue summary: View changes
amaisano’s picture

Turns out the View properly shows the results when accessing the overlay > Library through CKEditor's WYSIWYG plugin. It's just the field that finds no results...

nickbumgarner’s picture

I was having a similar issue earlier. Make sure you have those file types allowed in your Media Browser Settings.

Go to /admin/config/media/browser , and make sure your file types are checked off under "Allowed types in WYSIWYG".

Good luck!

devin carlson’s picture

Category: Bug report » Support request
Status: Active » Fixed

As @nickBumgarner mentioned, make sure that your field settings are permitting the appropriate files. You can also try updating to the latest -dev which includes fixes for a number of library restriction issues.

Feel free to reopen this issue if the suggestions don't fix the issue.

amaisano’s picture

Status: Fixed » Needs work

@nickBumgarner - The settings on the page you indicated have everything checked as recommended. The WYSIWYG editor "Library" and "My Files" browsers have always worked, it's the CCK field that uses "Media Browser" that isn't working - showing no results.

@Devin - I doublechecked the configuration for the field at /admin/structure/types/manage/resource/fields/field_upload_file and everything is enabled there as well - all plugins and all file types for Media Browser.

To clarify the problem again:

The Media Browser Views in the content type > field for "Library" and "My Files" are rendering, but are returning "No files available."

The Media Browser Views in the content type > body > WYSIWYG editor for "Library" and "My Files" properly return all the files I've uploaded using any upload button (both from the above content field and via the WYSIWYG editor plugin), as expected.

I will in the meantime try the most recent dev version, as you suggest.

amaisano’s picture

Status: Needs work » Fixed

Devin, I confirm that the rev.73 of Media 2.x dev fixed this glitch. Thanks.

PI_Ron’s picture

I'm seeing this exact issue with latest media dev.

; Information added by Drupal.org packaging script on 2014-03-13
version = "7.x-2.0-alpha3+73-dev"
core = "7.x"
project = "media"
datestamp = "1394718506"
PI_Ron’s picture

zhuber’s picture

StatusFileSize
new1021 bytes

The Query tags appear to be the culprit.

I've attached a patch that fixes this issue.

Here is my author info, for attribution:
--author="zhuber <zhuber@1437276.no-reply.drupal.org>"

If my patch is committed, please attribute. Thanks

antonyanimator’s picture

don't think the patch works on the current media dev

antonyanimator’s picture

can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/drupal/sites/all/modules/contrib/media/views/media_default.view.inc b/drupal/sites/all/modules/contrib/media/views/media_default.view.inc
|index f4ba4b9..2420a41 100644
|--- a/drupal/sites/all/modules/contrib/media/views/media_default.view.inc
|+++ b/drupal/sites/all/modules/contrib/media/views/media_default.view.inc
--------------------------
File to patch:

netbek’s picture

StatusFileSize
new865 bytes

Still an issue for me too in most recent 7.x-2.x-dev. I've attached a patch because #2215619-9: Library and My Files in Overlay empty if there is more than one scheme did not apply cleanly.

jmuzz’s picture

Status: Fixed » Needs work

If you make this change you will see the files in your media library but they won't necessarally be filtered correctly anymore. For example if you have a separate image and video field then both images and videos will appear in the media browser for each of them.

Here are some details about what the line is doing. This is my view query and arguments when logged from hook_views_pre_execute()

'SELECT file_managed.timestamp AS file_managed_timestamp, file_managed.fid AS fid, SUM(file_usage.count) AS file_usage_count
FROM 
{file_managed} file_managed
LEFT JOIN {file_usage} file_usage ON file_managed.fid = file_usage.fid
WHERE (( (file_managed.status IN  (:db_condition_placeholder_0)) ))
GROUP BY file_managed.timestamp, file_managed.fid
ORDER BY file_managed_timestamp DESC
LIMIT 25 OFFSET 0'
----------------------------------------------------------------------
array (
  ':db_condition_placeholder_0' => '1',
)

I ran this query manually and it does return results. This is the query as output from hook_views_post_execute() (after the media_browser tag has somehow done its magic.)

'SELECT file_managed.timestamp AS file_managed_timestamp, file_managed.fid AS fid, SUM(file_usage.count) AS file_usage_count
FROM
{file_managed} file_managed
LEFT JOIN {file_usage} file_usage ON file_managed.fid = file_usage.fid
WHERE (( (file_managed.status IN  (:db_condition_placeholder_0)) ))
  AND (file_managed.type IN  (:db_condition_placeholder_1))
  AND(( (file_managed.uri LIKE :db_condition_placeholder_2 ESCAPE \'\\\\\')
     OR (file_managed.uri LIKE :db_condition_placeholder_3 ESCAPE \'\\\\\')
     OR ( (file_managed.uri LIKE :db_condition_placeholder_4 ESCAPE \'\\\\\')
      AND (file_managed.filemime IN  (:db_condition_placeholder_5,
                                      :db_condition_placeholder_6,
                                      :db_condition_placeholder_7,
                                      :db_condition_placeholder_8))
      AND (file_managed.uri LIKE :db_condition_placeholder_9 ESCAPE \'\\\\\')
      AND (file_managed.filemime IN  (:db_condition_placeholder_10,
                                      :db_condition_placeholder_11,
                                      :db_condition_placeholder_12,
                                      :db_condition_placeholder_13)) )))
GROUP BY file_managed.timestamp, file_managed.fid
ORDER BY file_managed_timestamp DESC
LIMIT 25 OFFSET 0'
----------------------------------------------------------------------
array (
  ':db_condition_placeholder_0' => '1',
  ':db_condition_placeholder_1' => 'image',
  ':db_condition_placeholder_2' => 'vimeo://%',
  ':db_condition_placeholder_3' => 'youtube://%',
  ':db_condition_placeholder_4' => 'public://%',
  ':db_condition_placeholder_5' => 'image/png',
  ':db_condition_placeholder_6' => 'image/gif',
  ':db_condition_placeholder_7' => 'image/jpeg',
  ':db_condition_placeholder_8' => 'image/jpeg',
  ':db_condition_placeholder_9' => 'private://%',
  ':db_condition_placeholder_10' => 'image/png',
  ':db_condition_placeholder_11' => 'image/gif',
  ':db_condition_placeholder_12' => 'image/jpeg',
  ':db_condition_placeholder_13' => 'image/jpeg',
)

This query has no results, even though some images have been uploaded. The query seems to be grouped incorrectly after the second OR, where it AND's all the remaining conditions, but a file can't be both public:// and private://, so no uploaded files will be found.

I removed the media_browser tag as recommended and now both videos and images appear in the library tab even though it is for an image field. This is not the correct result either, though they can be filtered to images by using the exposed filter.

The following issues may be related:

https://drupal.org/node/2089697
https://drupal.org/node/1331056

jmuzz’s picture

Version: 7.x-2.0-alpha3 » 7.x-2.x-dev
Category: Support request » Bug report
Status: Needs work » Needs review
StatusFileSize
new632 bytes

I think this should make the query work correctly with the media_browser tag.

socialnicheguru’s picture

the last patch worked for me. thanks.

rbosscher’s picture

Status: Needs review » Reviewed & tested by the community

#14 fixed for me too.

The last submitted patch, 9: media-empty_library-2215619.patch, failed testing.

The last submitted patch, 12: media-empty_library-2215619-12.patch, failed testing.

devin carlson’s picture

Thanks for the patch!

Can someone post the steps to reproduce this using a fresh install of Media 7.x-2.x-dev? The current tests are pretty extensive but aren't catching this issue so it would be great if I could add additional test coverage along with the changes in #14.

aaron’s picture

Status: Reviewed & tested by the community » Needs work
Yuri’s picture

#14 fixed it for me too on a production site. I'm also using media youtube.
I think that if you install older versions and update it until the recent version the issue might to start appearing.
(apart from this issue the Media Browser overlay is a PITA..still tabs and exposed filters redirecting the wrong way etc..for years..)

ahillio’s picture

The patch from #14 fixed the problem on a fresh Drupal 7.28 install with Media 7.x-2.x-dev.

These steps reproduce the problem (@Devin Carlson - is this what you were asking for?):

  1. install fresh drupal 7.28 site using 'standard' installation profile
  2. download media-2.x-dev file_entity ctools views
  3. enable media views_ui
  4. change Article's image field widget to "Media browser".
  5. upload some images at /admin/content/file
  6. add new article node and try to add image from library but it doesn't work, no images show up in the "library" or under "my files" (uploading an image here does work, in case that's relevant)
    • In the media browser when viewing the empty "library", clicking on the contextual link to edit the view... the images added to the library at step 5 show up in the view preview, but they don't show up in the media browser and therefor can't be selected and added to the field.
  7. Apply patch, and it now works properly :)

Not sure if this is sufficiently reviewed by community so I'll refrain from changing the status.

longlivelance’s picture

Status: Needs work » Postponed (maintainer needs more info)

@firestk Thanks for the detailed steps. Unfortunately, I cannot reproduce this error following them. I tried on a fresh install a few times to be certain, and still could not reproduce the issue. Once I get to step 6 in #22, my files are visible in the 'Library' and 'My files' tabs.

If you can think of any additional information to help us try and track this issue down, please let us know.

saltednut’s picture

I tried to reproduce based on #22 but I am unable to also. In my tests, the images show up in the Media Browser without having to apply the patch. I tried this three times but still am not seeing this.

longlivelance’s picture

Status: Postponed (maintainer needs more info) » Needs work

Yesterday afternoon I believe we discovered one extra step required to reproduce this issue. In #22 step 4, rather then changing the existing images widget, create a new image field and give it the media browser widget, this then gives me a blank library even though files are present.

saltednut’s picture

Issue tags: +Media Initiative

The only time I see this is when I add a File field to my content type and set it to use the Media browser, but leave the default extension to txt. Then jpg do not show up or any other format but txt files. If I make the display png then I can only see png in the browser, etc.

Unable to reproduce based on #25.

longlivelance’s picture

Status: Needs work » Reviewed & tested by the community

After @brantwynn and I dug around a little more, we have discovered the exact issue. It only presents itself when you have multiple schemes setup, i.e., private and public.

The query logic before the patch was saying if the file is Public and the file is Private we want it, which is impossible. THe patch is basically, separating the schemes AND statements and appending them with an OR, which makes sense.

So you would get, files with Public OR private scheme instead of the impossible Public AND private scheme.

The patch in #14 correctly splits the conditions. Thanks @jmuzz for the fix, and actually calling out the issue when the patch was provided!

saltednut’s picture

Title: Library and My Files in Overlay always empty » Library and My Files in Overlay empty if there is more than one scheme

I have tested and can confirm this is a legitimate fix per #27 - this only applies when there is more than one file system scheme (ie: both public and private filesystem)

@jmuzz actually pointed this out quite a while ago in #13

The query seems to be grouped incorrectly after the second OR, where it AND's all the remaining conditions, but a file can't be both public:// and private://, so no uploaded files will be found.

Updated instructions:

  1. install drupal 7.28 site using the 'standard' installation profile
  2. ensure a private files url is set at admin/config/media/file-system
  3. download media-2.x-dev file_entity ctools views
  4. enable media views and file_entity
  5. change Article's image field widget to "Media browser".
  6. upload some images at /admin/content/file
  7. try to browse for files - nothing shows up
  8. apply patch and clear caches
  9. try to browse for files - it works

Confirmed RTBC

devin carlson’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new3.2 KB
new2.59 KB

All of the work done to create the patch and test it is very much appreciated!

The attached patch adds a test to demonstrate the issue and prevent similar issues from occurring in the future.

Status: Needs review » Needs work

The last submitted patch, 29: query-alter-with-all-extensions-2215619-29-tests-only.patch, failed testing.

devin carlson’s picture

Status: Needs work » Fixed

Committed #29 to Media 7.x-2.x.

  • Commit 75c98e4 on 7.x-2.x authored by jmuzz, committed by Devin Carlson:
    Issue #2215619 by zhuber, netbek, jmuzz, Devin Carlson: Fixed query...

Status: Fixed » Closed (fixed)

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

The last submitted patch, 29: query-alter-with-all-extensions-2215619-29.patch, failed testing.

dougn7’s picture

Hi guys, im having this same issue on 7.x-2.0-alpha4 and 7.x-2.0-alpha4+25-dev versions. I just did what @PI_Ron on comment #8 did and it worked.

runzipel’s picture

@dougn7 thx, this worked for me too!

kevster’s picture

wow - #8 worked for me too, was banging my head against a wall for hours here... Im running media 7.2 rc5 and the problem is still there.. thx @PI_Ron !