Lock not releasing upon hitting back button
codesmith - April 7, 2009 - 23:37
| Project: | Checkout (Content locking) |
| Version: | 6.x-2.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I don't know if I'm missing something but after editing a page and "canceling" by clicking the back button I get
This document is locked for editing by admin since Tue, 04/07/2009 - 16:28.
Click here to check back in now.
Shouldn't the lock be released? And no message?

#1
Well it seems like navigating away from a page using the back button keeps the page locked. This necessitates a cancel button if one doesn't want to save changes. I added this to checkout_form_alter to get a cancel button. This is a newbie hack so go easy on me. Note to other newbies: if the destination 'get' variable isn't set it the default is to take the user back to the 'Hierarchy' edit module "Site Outline" page which I'm using. Set it to something else (like admin%2Fcontent%2Fnode) as desired.
$cancel_url= $_GET['destination'] ? $_GET['destination'] : 'admin%2Fcontent%2Fnodehierarchy';$cancel_link = array(
'#type' => 'markup',
'#value' => l(t('Cancel Changes / Go Back'),$cancel_url),
'#weight' => 100,
);
if (isset($form['submit'])) {
$form['submit'] = array($form['submit'], $cancel_link, '#weight' => 100);
} else {
$form['submit'] = $cancel_link;
}