From: Tim Düsterhus Date: Sun, 2 Feb 2020 14:59:10 +0000 (+0100) Subject: Cache request information for SQL queries X-Git-Tag: 5.2.2~11^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b4f1aa53b4da6241e031baba61cd85187f49c03c;p=GitHub%2FWoltLab%2FWCF.git Cache request information for SQL queries --- diff --git a/wcfsetup/install/files/lib/system/database/Database.class.php b/wcfsetup/install/files/lib/system/database/Database.class.php index 8fd5af789d..b2d1650554 100644 --- a/wcfsetup/install/files/lib/system/database/Database.class.php +++ b/wcfsetup/install/files/lib/system/database/Database.class.php @@ -259,13 +259,16 @@ abstract class Database { // Note: This is meant to be run unconditionally in production to be // useful. Thus the code to retrieve the request information // must be absolutely lightweight. - $requestInformation = ''; - if (defined('ENABLE_PRODUCTION_DEBUG_MODE') && ENABLE_PRODUCTION_DEBUG_MODE && isset($_SERVER['REQUEST_URI'])) { - $requestInformation = substr($_SERVER['REQUEST_URI'].(\wcf\getRequestId() ? ' ('.\wcf\getRequestId().')' : ''), 0, 90); - if (isset($_REQUEST['className']) && isset($_REQUEST['actionName'])) { - $requestInformation .= ' ('.$_REQUEST['className'].':'.$_REQUEST['actionName'].')'; + static $requestInformation = null; + if ($requestInformation === null) { + $requestInformation = ''; + if (defined('ENABLE_PRODUCTION_DEBUG_MODE') && ENABLE_PRODUCTION_DEBUG_MODE && isset($_SERVER['REQUEST_URI'])) { + $requestInformation = substr($_SERVER['REQUEST_URI'].(\wcf\getRequestId() ? ' ('.\wcf\getRequestId().')' : ''), 0, 90); + if (isset($_REQUEST['className']) && isset($_REQUEST['actionName'])) { + $requestInformation .= ' ('.$_REQUEST['className'].':'.$_REQUEST['actionName'].')'; + } + $requestInformation = substr($requestInformation, 0, 180); } - $requestInformation = substr($requestInformation, 0, 180); } $pdoStatement = $this->pdo->prepare($statement.($requestInformation ? " -- ".$this->pdo->quote($requestInformation) : ''));