xowiki::Page instproc www-delete-revision (public)

 <instance of xowiki::Page[i]> www-delete-revision

Defined in packages/xowiki/tcl/xowiki-www-procs.tcl

This web-callable method deletes a single revision of a Page, which is actually performed by the "delete_revision" method of the package, which is responsible for caching. Since we instantiate the Page based on the "revision_id" query parameter, it is sufficient to delete here just based on the current instance variable of the revision_id.

Partial Call Graph (max 5 caller/called nodes):
%3 export_vars export_vars (public) xowiki::url xowiki::url (private) xowiki::Page instproc www-delete-revision xowiki::Page instproc www-delete-revision xowiki::Page instproc www-delete-revision->export_vars xowiki::Page instproc www-delete-revision->xowiki::url

Testcases:
No testcase defined.
Source code:
set item_id ${:item_id}
::xo::dc 1row -prepare integer get_revision {
  select latest_revision,live_revision from cr_items where item_id = :item_id
}

# do real deletion via package
${:package_id} delete_revision -revision_id ${:revision_id} -item_id $item_id

if {$live_revision == ${:revision_id}} {
  # latest revision might have changed by delete_revision, so we have to fetch here
  xo::dc 1row -prepare integer get_revision {select latest_revision from cr_items where item_id = :item_id}
  if {$latest_revision eq ""} {
    # we are out of luck, this was the final revision, delete the item
    ${:package_id} delete -name ${:name} -item_id $item_id
  } else {
    # Fetch fresh instance from db so that we have actual values
    # from the latest revision for e.g. the update of the
    # item_index.
    set page [::xo::db::CrClass get_instance_from_db -item_id $item_id -revision_id $latest_revision]
    $page set_live_revision -revision_id $latest_revision
  }
}
if {$latest_revision ne ""} {
  # otherwise, "delete" did already the redirect
  ${:package_id} returnredirect [:query_parameter return_url:localurl  [export_vars -base [${:package_id} url] {{m revisions}}]]
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: