Index: openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl,v diff -u -r1.23 -r1.24 --- openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl 27 Oct 2014 16:39:11 -0000 1.23 +++ openacs-4/packages/acs-content-repository/tcl/content-item-procs.tcl 27 Apr 2015 15:28:16 -0000 1.24 @@ -241,6 +241,12 @@ return [db_0or1row get_item_folder "" -column_array local_array] } set table_name [db_string get_table_name "select table_name from acs_object_types where object_type=:content_type"] + while {$table_name eq ""} { + acs_object_type::get -object_type $content_type -array typeInfo + ns_log notice "no table for $content_type registered, trying '$typeInfo(supertype)' instead" + set content_type $typeInfo(supertype) + set table_name [db_string get_table_name "select table_name from acs_object_types where object_type=:content_type"] + } set table_name "${table_name}x" # get attributes of the content_item use the content_typex view return [db_0or1row get_item "" -column_array local_array] @@ -1055,21 +1061,21 @@ } } - # Get the mime type, decide if we want the text - content::item::get -item_id $item_id -array_name item_info - - if { [info exists item_info(mime_type)] - && $item_info(mime_type) ne "" - && [string match "text/*" $item_info(mime_type)] - } { + # Get the "mime_type" from the revision to decide if we want the + # "text" in the result. The "content_type" is needed for obtaining + # the table_name later. + db_1row get_mime_and_content_type_from_revision { + select mime_type, object_type as content_type + from cr_revisionsx + where revision_id = :revision_id + } + + if { $mime_type ne "" && [string match "text/*" $mime_type]} { set text_sql [db_map grc_get_all_content_1] } else { set text_sql "" } - # Get the content type - set content_type $item_info(content_type) - # Get the table name set table_name [db_string grc_get_table_names { select table_name from acs_object_types