Forum OpenACS Development: error at item::publish
item::publish -item_id $item_id -revision_id $revision_id
about an item that i want to insert. The context is:
1. First i add the item:
if {![exists_and_not_null item_id]} {
set new_video 1
set item_id [db_nextval "acs_object_id_seq"]
content::item::new \
-item_id $item_id \
-name "video$item_id-$filename" \
-parent_id $package_id \
-content_type videos_object \
-package_id $package_id \
-creation_user $user_id \
-creation_ip $creation_ip
}
2. Then i import its revision
set revision_id [cr_import_content \
-item_id $item_id \
-storage_type file \
-creation_user $user_id \
-creation_ip $creation_ip \
-description $description \
-package_id $package_id \
$package_id \
$tmp_filename \
$n_bytes \
$guessed_file_type \
video-$package_id-$user_id-$suggest_name-$n_bytes]
3. At Last i call the "blessed" API [item::publish -item_id $item_id -revision_id $revision_id], which returns an error of constraint violation.
the version of acs-content-repository is:
version name="5.5.1" url="https://openacs.org/repository/download/apm/acs-content-repository-5.5.1.apm";
Everything seems to be fine. The item has been created in the cr_items table
openacs=# select * from cr_items where item_id = 1023;
item_id | parent_id | name | locale | live_revision | latest_revision | publish_status | content_type | storage_type | storage_area_key | tree_sortkey | max_child_sortkey
---------+-----------+-----------------------------------------------+--------+---------------+-----------------+----------------+---------------+--------------+------------------+------------------------------------------------------------------+-------------------
1023 | 903 | video1023-A_seguir_o_programa...Boa_noite.avi | | | 1025 | | videos_object | file | CR_FILES | 1000000000000000000001110110111110000000000000000000011111100111 |
(1 row)
As well as its revision on cr_revisions table
openacs=# select * from cr_revisions where revision_id = 1025;
revision_id | item_id | title | description | publish_date | mime_type | nls_language | lob | content | content_length
-------------+---------+-------+-------------+-------------------------------+-----------------+--------------+-----+-------------+----------------
1025 | 1023 | | video1 | 2010-05-26 10:43:52.588475-03 | video/x-msvideo | | | /10/23/1025 | 2242178
(1 row)
Why does the say new row relation if i am trying to update a existent column "publish_status" in the cr_items table
Please, see logs bellow.
[26/May/2010:10:00:19][17573.18446744072983849296][-default:1-] Error: POST http://127.0.0.1:8001/videos/videos-new?
referred by "http://127.0.0.1:8001/videos/videos-new";
Database operation "0or1row" failed
(exception ERROR, "ERROR: new row for relation "cr_items" violates check constraint "cr_items_publish_status_ck"
CONTEXT: SQL statement "update cr_items set live_revision = $1 , publish_status = $2 where item_id = (select item_id from cr_revisions where revision_id = $1 )"
PL/pgSQL function "content_item__set_live_revision" line 6 at SQL statement
")
while executing
"ns_pg_bind 0or1row nsdb0 {
select content_item__set_live_revision(:revision_id,:publish_status)
}"
("uplevel" body line 1)
invoked from within
"uplevel $ulevel [list ns_pg_bind $type $db $sql]"
invoked from within
"db_exec 0or1row $db $full_statement_name $sql"
("uplevel" body
item::publish__arg_parser
if { $revision_id eq "" } {
set revision_id [::content::item::get_latest_revision -item_id $item_id]
}
::content::item::set_live_revision -revision_id $revision_id -publish_status 'live'
It just calls content::item::set_live_revision BUT notice it uses single quotes around the publish status! Wow, that's a bug :)
I'll fix that in CVS, but you should most likely just use content::item::publish directly.
I love when i find a bug in the core! 😊
I just can't use it.
content::item::publish is not on acs-content-repository 5.5.1
I will just fix the single quotes
content::item::set_live_revision works.