diff --git a/include/functions_config.inc.php b/include/functions_config.inc.php index 0d463ede..c8ec467b 100644 --- a/include/functions_config.inc.php +++ b/include/functions_config.inc.php @@ -423,9 +423,16 @@ function serendipity_issueAutologin($array) { $rnd = md5(uniqid(time(), true) . $_SERVER['REMOTE_ADDR']); // Delete possible current cookie. Also delete any autologin keys that smell like 3-week-old, dead fish. + if (stristr($serendipity['dbType'], 'sqlite')) { + $cast = "name"; + } else { + // Adds explicits casting for mysql, postgresql and others. + $cast = "cast(name as integer)"; + } + serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}options WHERE okey = 'l_" . serendipity_db_escape_string($serendipity['COOKIE']['author_information']) . "' - OR (okey LIKE 'l_%' AND name < " . (time() - 1814400) . ")"); + OR (okey LIKE 'l_%' AND $cast < " . (time() - 1814400) . ")"); // Issue new autologin cookie serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}options (name, value, okey) VALUES ('" . time() . "', '" . serendipity_db_escape_string($package) . "', 'l_" . $rnd . "')"); diff --git a/include/functions_entries.inc.php b/include/functions_entries.inc.php index 82567bbd..63c6e6f9 100644 --- a/include/functions_entries.inc.php +++ b/include/functions_entries.inc.php @@ -408,7 +408,7 @@ function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fe {$serendipity['fullCountQuery']} {$cond['group']} {$cond['having']} - ORDER BY {$cond['orderby']} + " . (!empty($cond['orderby']) ? "ORDER BY {$cond['orderby']}" : "") . " $limit"; // DEBUG: diff --git a/include/plugin_internal.inc.php b/include/plugin_internal.inc.php index 8fc8d4a5..362f311c 100644 --- a/include/plugin_internal.inc.php +++ b/include/plugin_internal.inc.php @@ -548,11 +548,11 @@ class serendipity_archives_plugin extends serendipity_plugin { '', false, false, - 'timestamp DESC', + null, '', false, true, - 'count(e.id) AS orderkey', + 'count(DISTINCT e.id) AS orderkey', '', 'single', false, $category_set // the joins used