Index: openacs-4/packages/new-portal/tcl/portal-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/portal-procs-oracle.xql,v diff -u -N -r1.24.8.1 -r1.24.8.2 --- openacs-4/packages/new-portal/tcl/portal-procs-oracle.xql 8 Jan 2020 11:55:18 -0000 1.24.8.1 +++ openacs-4/packages/new-portal/tcl/portal-procs-oracle.xql 5 Oct 2021 10:17:27 -0000 1.24.8.2 @@ -81,63 +81,4 @@ - - - select sort_key as other_sort_key, - element_id as other_element_id - from (select pem.sort_key, - element_id - from portal_element_map pem, - portal_pages pp - where pp.portal_id = :portal_id - and pem.page_id = :my_page_id - and pp.page_id = pem.page_id - and region = :region - and pem.sort_key < :my_sort_key - and state != 'pinned' - order by pem.sort_key desc) - where rownum = 1 - - - - - - select sort_key as other_sort_key, - element_id as other_element_id - from (select pem.sort_key, - element_id - from portal_element_map pem, portal_pages pp - where pp.portal_id = :portal_id - and pem.page_id = :my_page_id - and pem.page_id = pp.page_id - and region = :region - and pem.sort_key > :my_sort_key - and state != 'pinned' - order by pem.sort_key) - where rownum = 1 - - - - - - select * - from (select page_id - from portal_pages - where portal_id = :portal_id - order by sort_key desc) - where rownum = 1 - - - - - - select * - from (select page_id - from portal_pages - where portal_id = :portal_id - order by sort_key) - where rownum = 1 - - - Index: openacs-4/packages/new-portal/tcl/portal-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/portal-procs-postgresql.xql,v diff -u -N -r1.13.8.1 -r1.13.8.2 --- openacs-4/packages/new-portal/tcl/portal-procs-postgresql.xql 8 Jan 2020 11:55:19 -0000 1.13.8.1 +++ openacs-4/packages/new-portal/tcl/portal-procs-postgresql.xql 5 Oct 2021 10:17:27 -0000 1.13.8.2 @@ -85,61 +85,4 @@ - - - select sort_key as other_sort_key, - element_id as other_element_id - from (select pem.sort_key, - element_id - from portal_element_map pem, - portal_pages pp - where pp.portal_id = :portal_id - and pem.page_id = :my_page_id - and pp.page_id = pem.page_id - and region = :region - and pem.sort_key < :my_sort_key - and state != 'pinned' - order by pem.sort_key desc) as sort_keys - limit 1 - - - - - - select sort_key as other_sort_key, - element_id as other_element_id - from (select pem.sort_key, - element_id - from portal_element_map pem, portal_pages pp - where pp.portal_id = :portal_id - and pem.page_id = :my_page_id - and pem.page_id = pp.page_id - and region = :region - and pem.sort_key > :my_sort_key - and state != 'pinned' - order by pem.sort_key) as sort_keys - limit 1 - - - - - - select page_id - from portal_pages - where portal_id = :portal_id - order by sort_key desc - limit 1 - - - - - - select page_id - from portal_pages - where portal_id = :portal_id - order by sort_key - limit 1 - - - Index: openacs-4/packages/new-portal/tcl/portal-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/portal-procs.tcl,v diff -u -N -r1.216.2.14 -r1.216.2.15 --- openacs-4/packages/new-portal/tcl/portal-procs.tcl 24 Feb 2021 14:29:01 -0000 1.216.2.14 +++ openacs-4/packages/new-portal/tcl/portal-procs.tcl 5 Oct 2021 10:17:27 -0000 1.216.2.15 @@ -789,7 +789,12 @@ # portal db_foreach revert_target_pages {} { if { ! [db_0or1row revert_get_source_page_id {}] } { - set move_to_page_id [db_string revert_min_page_id_select {}] + set move_to_page_id [db_string revert_min_page_id_select { + select min(page_id) + from portal_pages + where portal_id = :portal_id + order by sort_key + }] db_foreach revert_move_elements_for_del {} { portal::move_element_to_page \ @@ -1351,12 +1356,41 @@ if { $dir eq "up" } { # get the sort_key and id of the element above - if {[db_0or1row get_prev_sort_key {}] == 0} { + if {[db_0or1row get_prev_sort_key { + select sort_key as other_sort_key, + element_id as other_element_id + from (select pem.sort_key, + element_id + from portal_element_map pem, + portal_pages pp + where pp.portal_id = :portal_id + and pem.page_id = :my_page_id + and pp.page_id = pem.page_id + and region = :region + and pem.sort_key < :my_sort_key + and state != 'pinned' + order by pem.sort_key desc) as sort_keys + fetch first 1 rows only + }] == 0} { return } } elseif { $dir eq "down"} { # get the sort_key and id of the element below - if {[db_0or1row get_next_sort_key {}] == 0} { + if {[db_0or1row get_next_sort_key { + select sort_key as other_sort_key, + element_id as other_element_id + from (select pem.sort_key, + element_id + from portal_element_map pem, portal_pages pp + where pp.portal_id = :portal_id + and pem.page_id = :my_page_id + and pem.page_id = pp.page_id + and region = :region + and pem.sort_key > :my_sort_key + and state != 'pinned' + order by pem.sort_key) as sort_keys + fetch first 1 rows only + }] == 0} { return } } else {