From 6c550895ef0f27bf84b8a5d7917eeee3e3122f67 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 10 Aug 2017 10:37:51 +0200 Subject: The SQL queries for the HTTP ETag header generation have been combined into one single query. In addition, some meaningless code was removed. --- core/application.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'core/application.php') diff --git a/core/application.php b/core/application.php index 0a53350..72f854a 100644 --- a/core/application.php +++ b/core/application.php @@ -89,25 +89,22 @@ catch(PDOException $Exception) { # Check if "304 Not Modified" and ETag header should be send #=============================================================================== if(Application::get('CORE.SEND_304') === TRUE AND !defined('ADMINISTRATION')) { + #=========================================================================== # Select edit time from last edited items (page, post, user) #=========================================================================== - $execute = 'SELECT time_update FROM %s ORDER BY time_update DESC LIMIT 1'; + $execute = '(SELECT time_update FROM %s ORDER BY time_update DESC LIMIT 1) AS %s'; + + $pageSQL = sprintf($execute, Page\Attribute::TABLE, Page\Attribute::TABLE); + $postSQL = sprintf($execute, Post\Attribute::TABLE, Post\Attribute::TABLE); + $userSQL = sprintf($execute, User\Attribute::TABLE, User\Attribute::TABLE); - $PageStatement = $Database->query(sprintf($execute, Page\Attribute::TABLE)); - $PostStatement = $Database->query(sprintf($execute, Post\Attribute::TABLE)); - $UserStatement = $Database->query(sprintf($execute, User\Attribute::TABLE)); + $Statement = $Database->query("SELECT {$pageSQL}, {$postSQL}, {$userSQL}"); #=========================================================================== # Define HTTP ETag header identifier #=========================================================================== - $HTTP_ETAG_IDENTIFIER = sha1(implode(NULL, [ - serialize(Application::getConfiguration()), - $PageStatement->fetchColumn(), - $PostStatement->fetchColumn(), - $UserStatement->fetchColumn(), - 'CUSTOM-STRING-0123456789' - ])); + $HTTP_ETAG_IDENTIFIER = md5(implode($Statement->fetch(PDO::FETCH_ASSOC))); #=========================================================================== # Send ETag header within the HTTP response -- cgit v1.2.3