The view unpublished module has a conflict with the latest version of the file_entity module.

This is because the view_unpublished_query_alter() function is not specific enough in what it alters and it alters and breaks the file entity listing sql.

To reproduce, go to admin/content/files, with an admin that is allowed to see it (not user 1) and you get the message:

"The website encountered an unexpected error. Please try again later."

And this error:
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'n.type' in 'where clause': SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {file_managed} f INNER JOIN {users} u ON f.uid = u.uid WHERE (f.status = :db_condition_placeholder_0) AND (f.uri NOT LIKE :db_condition_placeholder_1 ESCAPE '\\') AND( (n.type = :db_condition_placeholder_2) OR (n.type = :db_condition_placeholder_3) OR (n.type = :db_condition_placeholder_4) OR (n.type = :db_condition_placeholder_5) OR (n.type = :db_condition_placeholder_6) )) subquery; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => temporary% [:db_condition_placeholder_2] => case_studies [:db_condition_placeholder_3] => documents [:db_condition_placeholder_4] => individual_board_committees [:db_condition_placeholder_5] => page [:db_condition_placeholder_6] => profile ) in PagerDefault->execute() (line 74 of /home/mysite/public_html/includes/pager.inc).

The code that generates the original query that is being altered is in the file entity module in file_entity_admin_files().

Comments

rooby’s picture

Project: File Entity (fieldable files) » View unpublished content
Version: 7.x-2.0-unstable7 »

I've tracked this down to the view_unpublished module being a little to generic in its hook_query_alter() implementation.

rooby’s picture

Project: View unpublished content » View Unpublished
Version: » 7.x-1.1

Oops, wrong project.

rooby’s picture

Issue summary: View changes

Tweak to the error message.

rooby’s picture

For a fix the code in view_unpublished_query_alter() should probably be in view_unpublished_query_node_access_alter() instead.

rooby’s picture

Title: The website encountered an unexpected error. Please try again later. when viewing admin/content/files » Unknown column 'n.type' in 'where clause' when viewing admin/content/files
Status: Active » Needs review
StatusFileSize
new607 bytes

Here is a patch that makes the change mentioned in #3.

highfellow’s picture

Just confirming that this patch worked for me. Thanks.

yang_yi_cn’s picture

#4 does't apply cleanly. I re-rolled it.

larowlan’s picture

+1 for patch 4

larowlan’s picture

StatusFileSize
new607 bytes

Re-roll without the duplication and whitespace

genjohnson’s picture

I applied the patch in 8 (manually) and it worked for me. Thank you!

genjohnson’s picture

Issue summary: View changes

Updating the description to better describe the problem.

reubenavery’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Looks good, someone please commit!

nathan.bolin’s picture

I applied the patch in 8 (manually) and it worked for me.

It took a little digging before I found the error, and the solution here.

My error was found by an editor on a production site, where logging was disabled for performance. Only editors encountered an error message when trying to access /admin/content/files. The good ol' generic "website encountered an unexpected error".

Users with the administrator role were able to access the page, no problem.

Thanks!

  • Commit b93bfb5 on 7.x-1.x authored by rooby, committed by entendu:
    Issue #1857656 by rooby, yang_yi_cn, larowlan: Unknown column 'n.type'...
entendu’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Thanks for the patch!