[TYPO3-dev] #10730: Record Locking leaves Records locked on Logout
Steffen Gebert
steffen at steffen-gebert.de
Wed Aug 26 15:34:06 CEST 2009
On Mon, 24 Aug 2009 13:48:09 +0200, Steffen Ritter <info at rs-websystems.de>
wrote:
> Look at the logout functionality. Opened records are stored in session
> afaik. the warnings for lockings are stored in a table...
> Session is destroyed, table not cleared.
> Locking deletes records if they are older than xy... You might have a
> look at the source there.
> If you wanna change this behavoiur you should extends the logout
> procedure, with clearing the lock table.
> But what if, there are two users within the same username logged in from
> different places?
Yes, this is exactly one of the problems. The opendocs module also only
closes the document in the session (identified by a md5sum), but doesn't
remove the entry in sys_lockedrecords.
Saving the records on a session basis (instead of per user) was no
problem, but removing the entries from the DB is.
The table and uid can be retrieved from the BE session and then
closeDocument() in opendoc class should close the record using
t3lib_BEfunc::lockRecord().
Before doing so, I'd have to understand, how getModuleData() works. I
think, I can't do this until feature freeze.
Steffen
P.S: My patch snippet for afterworld, if s.b. ever wants to try:
Index: t3lib/stddb/tables.sql
===================================================================
--- t3lib/stddb/tables.sql (revision 5826)
+++ t3lib/stddb/tables.sql (working copy)
@@ -297,6 +297,7 @@
CREATE TABLE sys_lockedrecords (
uid int(11) unsigned NOT NULL auto_increment,
userid int(11) unsigned DEFAULT '0' NOT NULL,
+ ses_id varchar(32) DEFAULT '' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
record_table varchar(255) DEFAULT '' NOT NULL,
record_uid int(11) DEFAULT '0' NOT NULL,
Index: t3lib/class.t3lib_befunc.php
===================================================================
--- t3lib/class.t3lib_befunc.php (revision 5826)
+++ t3lib/class.t3lib_befunc.php (working copy)
@@ -2979,6 +2979,7 @@
if ($table && $uid) {
$fields_values = array(
'userid' => $user_id,
+ 'ses_id' =>
$GLOBALS['BE_USER']->user['ses_id'],
'feuserid' => 0,
'tstamp' => $GLOBALS['EXEC_TIME'],
'record_table' => $table,
@@ -2989,7 +2990,7 @@
$GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_lockedrecords',
$fields_values);
} else {
-
$GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_lockedrecords',
'userid='.intval($user_id));
+
$GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_lockedrecords', 'ses_id=' .
$GLOBALS['TYPO3_DB']->fullQuoteStr($ses_id, 'sys_lockedrecords'));
}
}
@@ -3011,7 +3012,7 @@
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*',
'sys_lockedrecords',
-
'sys_lockedrecords.userid!='.intval($GLOBALS['BE_USER']->user['uid']).'
+
'sys_lockedrecords.ses_id != ' .
$GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['BE_USER']->user['ses_id'],
'sys_lockedrecords') . '
AND
sys_lockedrecords.tstamp > '.($GLOBALS['EXEC_TIME']-2*3600)
);
while($row =
$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
More information about the TYPO3-dev
mailing list