summaryrefslogtreecommitdiffstats
path: root/core/application.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2017-08-10 10:37:51 +0200
committerThomas Lange <code@nerdmind.de>2017-08-10 10:37:51 +0200
commit6c550895ef0f27bf84b8a5d7917eeee3e3122f67 (patch)
tree160db9e67777a609c5174449efbe1c39015b4dcf /core/application.php
parent5e8032c74cfc65e1028ee00a5a9fc343f8f63bf1 (diff)
downloadblog-6c550895ef0f27bf84b8a5d7917eeee3e3122f67.tar.gz
blog-6c550895ef0f27bf84b8a5d7917eeee3e3122f67.tar.xz
blog-6c550895ef0f27bf84b8a5d7917eeee3e3122f67.zip
The SQL queries for the HTTP ETag header generation have been combined into one single query. In addition, some meaningless code was removed.
Diffstat (limited to 'core/application.php')
-rw-r--r--core/application.php19
1 files changed, 8 insertions, 11 deletions
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