diff --git a/libraries/src/MVC/Model/FormModel.php b/libraries/src/MVC/Model/FormModel.php index ca58b5b85e346..8a62c9a151da0 100644 --- a/libraries/src/MVC/Model/FormModel.php +++ b/libraries/src/MVC/Model/FormModel.php @@ -153,9 +153,31 @@ public function checkout($pk = null) // Check if this is the user having previously checked out the row. if ($table->{$checkedOutField} > 0 && $table->{$checkedOutField} != $user->get('id')) { - $this->setError(\JText::_('JLIB_APPLICATION_ERROR_CHECKOUT_USER_MISMATCH')); - - return false; + // Check if the session of the user that checked out the item is expired. + $db = $this->getDbo(); + $query = $db->getQuery(true); + $query->select($db->quoteName('time')) + ->from($db->quoteName('#__session')) + ->where($db->quoteName('userid') . ' = ' . $table->{$checkedOutField}) + ->order($db->quoteName('time') . ' DESC') + ->limit(1); + $db->setQuery($query); + $result = $db->loadResult(); + + if ($result) + { + $lifetime = \JFactory::getConfig()->get('lifetime', '15'); + + if (((time() - $result) / 60) <= $lifetime) + { + $this->setError(\JText::_('JLIB_APPLICATION_ERROR_CHECKOUT_USER_MISMATCH')); + + return false; + } + } + + // We either found no session or the session was already expired. + $table->checkIn(); } // Attempt to check the row out.