Hi,
I'm having issues getting managed files working. No matter what I do, I can't get Linkit to return any results for the the files that have been uploaded, either using the Media uploader or the default upload widget.

All the files are in the file_managed table in the db and the option for Managed files is set in the Linkit config. Node, taxonomy and user options work fine.

Testing on a fresh install with the latest devs of Linkit, Media 2, File Entity 2, Ctools, Views, Entity and WYSIWYG w/ CKEditor library.

Any idea what I could be doing wrong?

Comments

anon’s picture

From the info you give me, I cant say whats wrong.

Make sure you have access to the files (test with user 1).

chris_h’s picture

Yep, it's with user 1, no matter what I do I can't return any results for files. Is there any other info I could provide to help debug this?

anon’s picture

Try searching for something that will not return any files and see if you get results.
If you get results here, then its something with the file plugin.

Can you check the JSON response in Firebug or something else and see if you get any errors when files should be included in the search results?

chris_h’s picture

No results at all, even when trying not to return any files.

No errors. I get these responses:
Example successful response for a node: Object { title="Photo", path="/node/556", group="Node"}
Example unsuccessful response (same whether there should be a file returned or not): Object { title="No results", addClass="status-notice", disabled=true}

anon’s picture

This means that you dont have any errors and you clearly get results back.

What you also can do is to check the watchdog log and see if you find anything.

What browser and theme are you using? Try running some default theme like garland, bartik, or seven and see if that helps.
Also, clear the cache.

mallezie’s picture

I'm having the same problem.
Tested under Chromium and Firefox.
Tried further to debug this.
The query-object is executed, but doesn't give any result.
This is the object which returns:

... (Object) EntityFieldQuery
  altered (Boolean) FALSE
  entityConditions (Array, 1 element)
    entity_type (Array, 2 elements)
      value (String, 4 characters ) file | (Callback) file();
      operator (NULL)
  fieldConditions (Array, 0 elements)
  fieldMetaConditions (Array, 0 elements)
  propertyConditions (Array, 2 elements)
    0 (Array, 3 elements)
      column (String, 6 characters ) status
      value (Integer) 1
      operator (NULL)
  1 (Array, 3 elements)
      column (String, 8 characters ) filename
      value (String, 6 characters ) %aanb%
      operator (String, 4 characters ) LIKE
  order (Array, 1 element)
    0 (Array, 3 elements)
      type (String, 8 characters ) property
      specifier (String, 8 characters ) filename
      direction (String, 3 characters ) ASC
  range (Array, 0 elements)
  pager (Array, 0 elements)
  deleted (Boolean) FALSE
  fields (Array, 0 elements)
  count (Boolean) FALSE
  age (String, 18 characters ) FIELD_LOAD_CURRENT
  tags (Array, 3 elements)
    linkit_entity_autocomplete (String, 26 characters ) linkit_entity_autocomplete
    linkit_file_autocomplete (String, 24 characters ) linkit_file_autocomplete
    file_access (String, 11 characters ) file_access
  metaData (Array, 0 elements)
  orderedResults (Array, 0 elements)
  executeCallback (String, 0 characters )
mallezie’s picture

I found out, results are given.
It's the entity_acces call which causes the results to disappear.
linkit-plugin-entity.class.php line 192

 if (!entity_access('view', $this->plugin['entity_type'], $entity)) {
        continue;
 }

removes results. Since file_entity doesn't has a file access entity API (yet)
#1227706

gooddesignusa’s picture

I'm guessing your talking about Add a file entity access API - http://drupal.org/node/1227706
Is there a fix for this or do we have to apply the patch from http://drupal.org/node/1227706#comment-5934038

mallezie’s picture

StatusFileSize
new809 bytes

I am indeed referring to #1227706: Add a file entity access API.
Patch attached overrides access check for files. But could be a temporary fix.

chris_h’s picture

This patch works as a temporary fix for me, but it links to the page (eg /file/1) rather than the file itself. Is that intended? If so, it seems strange.

mallezie’s picture

I used media V1 and adressed this with file_create_url() (which isn't a very good solution either.
It should be solved in linkit. I think best would be to override BuildPath for the file-entity-plugin.

chris_h’s picture

Not ideal by any means, but I ended up using a mix of the temporary patch and a page manager override to redirect file/1 to the %file:url token.

mrfelton’s picture

Status: Active » Needs work

Confirm that the patch in #9 does get it to work - can locate media at least, but as mentioned by others, the link goes to the file entity which is not the wanted behavior.

mrfelton’s picture

Status: Needs work » Needs review
StatusFileSize
new1.41 KB

Attached file fixes up the path so that it links to the actual file, and not the file entity.

anon’s picture

Version: 7.x-2.3 » 7.x-2.x-dev
Component: User interface » Code
Category: support » bug
Status: Needs review » Fixed
StatusFileSize
new1.25 KB

Commited this patch. Seems to work.

gooddesignusa’s picture

I needed relative paths for file links. I've added an option 'Link to file using relative path' inside the fieldset 'Managed files plugin settings' on the linkit profile config page. Not sure if this is the best way to do it but it works.

mrfelton’s picture

What we really need is to suport something more portable. Ie, a filter that works using the fid, rather than any url to the file. The Portable Path module aims to do something like this, although currently fails in my opinion. However, there is a module on Github referenced in the ticket #1647980: Use fid rather than stream wrapper. which looks promising.

Status: Fixed » Closed (fixed)

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