User tests: Successful: Unsuccessful:
Using a delete() query:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->delete('#__session')
->where($db->qn('time').' < '.$db->q(JFactory::getDate()->modify('-30 days')->toUnix()))
->setLimit(1);
echo $query->dump();
Produces this:
DELETE
FROM kfdcs_session
WHERE `time` < '1459851698' LIMIT 0, 1
The query is incorrect - DELETE doesn't use an offset http://dev.mysql.com/doc/refman/5.7/en/delete.html
Because specifying an offset is optional in MySQL, LIMIT 0, 1
is the equivalent of LIMIT 1
so changing the processLimit()
function shouldn't cause any issues with existing code. The output should now be:
DELETE
FROM kfdcs_session
WHERE `time` < '1459851698' LIMIT 1
Just use the above code to test - you can add it in a component (eg. open /administrator/components/com_content/content.php and add it after defined('_JEXEC') or die;
. Going to Articles will show the query.
Make sure no other SQL errors are present - pagination should still work, deleting items etc
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
This is only for the mysqli driver does it need to be done for the others as well?
Category | ⇒ | Libraries SQL |
Any driver using MySQL would do - so that includes PDO as well. Haven't tested PDO to be honest
The other MySQL driver query classes extend the MySQLi class, so they have the same change already.
Suggest
if ($limit > 0 )
{
if ($offset > 0)
{
$query .= ' LIMIT ' . $offset . ', ' . $limit;
}
else
{
$query .= ' LIMIT ' . $limit;
}
}
I have tested this item successfully on 2c33fd7
Status | Pending | ⇒ | Ready to Commit |
Thanks @OctavianC looks good to me.
Labels |
Added:
?
|
Milestone |
Added: |
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-05-07 14:08:30 |
Closed_By | ⇒ | wilsonge |
Labels |
Removed:
?
|
I have tested this item successfully on 2c33fd7
Note that i'm not a sql or even joomla session expert.
Just applied the patch, logged in, logged out in the frontend and admin and didn't get any issues.
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10252.