From: Timo Tijhof Date: Sat, 1 Dec 2012 10:52:23 +0000 (+0100) Subject: (bug 42598) Database: fname was not logged for BEGIN/COMMIT. X-Git-Tag: 1.31.0-rc.0~21453^2 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=5603e1dd95298587355830bc05d1e71aa115e097;p=lhc%2Fweb%2Fwiklou.git (bug 42598) Database: fname was not logged for BEGIN/COMMIT. Relied on presence of whitespace. From git-blame looks like $commentedSql has been this way for a long time. Which is odd since I've seen many commits since then specifically improving callers of commit() and begin() to pass the __METHOD__, which doesn't appear to have been logged anywhere up until now. Change-Id: I48dc8b3f68a6764327b4b1a8f7c06c59a25a31bb --- diff --git a/includes/db/Database.php b/includes/db/Database.php index dfb3469dbc..a638540232 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -904,7 +904,10 @@ abstract class DatabaseBase implements DatabaseType { } else { $userName = ''; } - $commentedSql = preg_replace( '/\s/', " /* $fname $userName */ ", $sql, 1 ); + + // Add trace comment to the begin of the sql string, right after the operator. + // Or, for one-word queries (like "BEGIN" or COMMIT") add it to the end (bug 42598) + $commentedSql = preg_replace( '/\s|$/', " /* $fname $userName */ ", $sql, 1 ); # If DBO_TRX is set, start a transaction if ( ( $this->mFlags & DBO_TRX ) && !$this->mTrxLevel &&