Index: openacs-4/packages/xotcl-core/tcl/cr-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/cr-procs.tcl,v diff -u -N -r1.73 -r1.74 --- openacs-4/packages/xotcl-core/tcl/cr-procs.tcl 24 Jul 2018 18:46:12 -0000 1.73 +++ openacs-4/packages/xotcl-core/tcl/cr-procs.tcl 29 Aug 2018 09:15:30 -0000 1.74 @@ -143,18 +143,27 @@ CrClass ad_proc lookup { -name:required {-parent_id -100} - {-content_type "::%"} + {-content_type} } { Check, whether an content item with the given name exists. - If the item exists, return its item_id, otherwise 0. - - @return item_id + When content_type is provided (e.g. -content_type "::%") + then a like operation is applied on the value. + + @return item_id If the item exists, return its item_id, otherwise 0. } { - return [::xo::dc get_value entry_exists_select { - select item_id from cr_items - where name = :name and parent_id = :parent_id - and content_type like :content_type - } 0] + if {[info exists content_type]} { + set result [::xo::dc get_value lookup_by_name_and_ct { + select item_id from cr_items + where name = :name and parent_id = :parent_id + and content_type like :content_type + } 0] + } else { + set result [::xo::dc get_value lookup_by_name { + select item_id from cr_items + where name = :name and parent_id = :parent_id + } 0] + } + return $result } @@ -1642,6 +1651,7 @@ CrCache::Class instproc lookup { -name:required {-parent_id -100} + {-content_type} } { # We need here the strange logic to avoid caching of lookup fails. # In order to cache fails as well, we would have to flush the fail