Forum OpenACS Q&A: Search 5.2.3 fails with more than one FAQ package

I just upgraded search and my site to 5.2.3 and I'm still getting a very inconvenient error when I have more than one faq package.
Database operation "0or1row" failed (exception NSINT, "Query returned more than one row.")

SQL: 
      select package_id
      from apm_packages
      where package_key = 'faq'
    
    while executing
"ns_pg_bind 0or1row nsdb0 {
      select package_id
      from apm_packages
      where package_key = :package_key
    }"
    ("uplevel" body line 1)
    invoked from within
"uplevel $ulevel [list ns_pg_bind $type $db $sql]"
    ("postgresql" arm line 2)
    invoked from within
"switch $driverkey {
                oracle {
                    return [uplevel $ulevel [list ns_ora $type $db $sql] $args]
                }
       ..."
    invoked from within
"db_exec 0or1row $db $full_name $sql"
    invoked from within
"set selection [db_exec 0or1row $db $full_name $sql]"
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $code_block "
    invoked from within
"db_with_handle -dbn $dbn db {
        set selection [db_exec 0or1row $db $full_name $sql]
    }"
    (procedure "db_string" line 8)
    invoked from within
"db_string apm_package_id_from_key {
	select package_id from apm_packages where package_key = :package_key
    } -default 0"
    (procedure "apm_package_id_from_key_mem" line 2)
    invoked from within
"apm_package_id_from_key_mem faq"
    ("eval" body line 1)
    invoked from within
"eval $script"
    invoked from within
"ns_cache eval util_memoize $script {
	    list $current_time [eval $script]
	}"
    (procedure "util_memoize" line 20)
    invoked from within
"util_memoize "apm_package_id_from_key_mem $package_key""
    (procedure "apm_package_id_from_key" line 2)
    invoked from within
"apm_package_id_from_key faq"
    (procedure "faq__url" line 3)
    invoked from within
"faq__url $object_id"
    (procedure "AcsSc.ftscontentprovider.url.faq_q_and_a" line 1)
    invoked from within
"AcsSc.ftscontentprovider.url.faq_q_and_a 7160"
    ("uplevel" body line 1)
    invoked from within
"uplevel $func_and_args"
    (procedure "apply" line 3)
    invoked from within
"apply $proc_name $arguments"
    (procedure "acs_sc_call" line 6)
    invoked from within
"acs_sc_call FtsContentProvider url [list $object_id] $object_type"
    ("for" body line 9)
    invoked from within
"for { set __i 0 } { $__i < [expr $high - $low +1] } { incr __i } {

    set object_id [lindex $result(ids) $__i]
    set object_type [acs_object_type ..."
    ("uplevel" body line 121)
    invoked from within
"uplevel {
ad_page_contract {
    @author Neophytos Demetriou
    @creation-date September 01, 2001
    @cvs-id $Id: search.tcl,..."
    (procedure "code::tcl::/var/lib/aolserver/service1/packages/search/www/s..." line 2)
    invoked from within
"code::tcl::$__adp_stub"
    invoked from within
"if { [file exists $__adp_stub.tcl] } {

      # ensure that data source preparation procedure exists and is up-to-date
      adp_init tcl $__adp_stub
..."
    ("uplevel" body line 3)
    invoked from within
"uplevel {

    if { [file exists $__adp_stub.tcl] } {

      # ensure that data source preparation procedure exists and is up-to-date
      adp_init t..."
    (procedure "adp_prepare" line 2)
    invoked from within
"adp_prepare "
    (procedure "template::adp_parse" line 30)
    invoked from within
"template::adp_parse [file root [ad_conn file]] {}"
    (procedure "adp_parse_ad_conn_file" line 5)
    invoked from within
"$handler"
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
                $handler
            } ad_script_abort val {
                # do nothing
            }"
    invoked from within
"rp_serve_concrete_file [ad_conn file]"
    (procedure "rp_serve_abstract_file" line 60)
    invoked from within
"rp_serve_abstract_file "$root/$path""
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
            rp_serve_abstract_file "$root/$path"
            set tcl_url2file([ad_conn url]) [ad_conn file]
            set tcl_url2path_info..."
This seems to appear intermittently with different keywords. Any help would be much appreciated.
The problem seems to be with the implementation of the "faq__url" operation which binds to the "url" operation of the FtsContentProvider package. I don't see why apm_package_id_from_key is being called (apm_package_url_from_id would do the trick).

Check your faq-sc-pros.tcl, where does faq::sc::register_faq_q_and_a_fts_impl *aliases* the "url" operation. The current cvs code points to the proc faq::fts::url which does not seem to have this problem

(disclaimer: only by checking/reading the code -- have not tried it).

Collapse
Posted by Ryan Gallimore on
Thanks, Neophytos. Some the queries are working now, but I can't get any faq objects to show. I'm using a /sql/postgresql/faq-sc-create.sql script I wrote myself and don't fully trust - but I don't see that file in cvs.

My faq-sc-procs.tcl (that I wrote) looks very different than the one in cvs. I tried both and changed apm_package_url_from_key to apm_package_url_from_id, but I still get this error for some keywords:

can't read "datasource(content)": no such element in array
    while executing
"search::content_get txt $datasource(content) $datasource(mime) $datasource(storage_type)"
    ("for" body line 6)
    invoked from within
"for { set __i 0 } { $__i < [expr $high - $low +1] } { incr __i } {

    set object_id [lindex $result(ids) $__i]
    set object_type [acs_object_type ..."
    ("uplevel" body line 121)
    invoked from within
"uplevel {
ad_page_contract {
    @author Neophytos Demetriou
    @creation-date September 01, 2001
    @cvs-id $Id: search.tcl,..."
    (procedure "code::tcl::/var/lib/aolserver/service1/packages/search/www/s..." line 2)
    invoked from within
"code::tcl::$__adp_stub"
    invoked from within
"if { [file exists $__adp_stub.tcl] } {

      # ensure that data source preparation procedure exists and is up-to-date
      adp_init tcl $__adp_stub
..."
    ("uplevel" body line 3)
    invoked from within
"uplevel {

    if { [file exists $__adp_stub.tcl] } {

      # ensure that data source preparation procedure exists and is up-to-date
      adp_init t..."
    (procedure "adp_prepare" line 2)
    invoked from within
"adp_prepare "
    (procedure "template::adp_parse" line 30)
    invoked from within
"template::adp_parse [file root [ad_conn file]] {}"
    (procedure "adp_parse_ad_conn_file" line 5)
    invoked from within
"$handler"
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
                $handler
            } ad_script_abort val {
                # do nothing
            }"
    invoked from within
"rp_serve_concrete_file [ad_conn file]"
    (procedure "rp_serve_abstract_file" line 60)
    invoked from within
"rp_serve_abstract_file "$root/$path""
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
            rp_serve_abstract_file "$root/$path"
            set tcl_url2file([ad_conn url]) [ad_conn file]
            set tcl_url2path_info..."
Collapse
Posted by Dave Bauer on
Ryna,

the error

can't read "datasource(content)": no such element in array

while executing

"search::content_get txt $datasource(content) $datasource(mime) $datasource(storage_type)"

means that the datasource tcl proc did not return the "content" element of the array. One way to test this is to call the datasource proc with the object_id of the item that is not working from the ds/shell page.