Feature #14582

RFE: get t3lib_DB->debug_lastBuiltQuery without t3lib_DB->debugOutput

Added by Martin Kutschker over 16 years ago. Updated over 15 years ago.

Status:
Closed
Priority:
Should have
Category:
-
Target version:
-
Start date:
2005-03-01
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

It's annoying to get the last query only when debug output is enabled. The last query should always be stored so it can be retrieved and eg written to the devLog on error.

TYPO3 wastes some many CPU cycles and bytes in RAM, it hardly matters. And of course it's less if-clauses :-)

(issue imported from #M850)


Files

class.t3lib_db.php.diff (1010 Bytes) class.t3lib_db.php.diff Administrator Admin, 2005-04-25 18:16
T3X_stucki_debugdb-1_0_0-z-200504121334.t3x (1.77 KB) T3X_stucki_debugdb-1_0_0-z-200504121334.t3x Administrator Admin, 2005-05-17 23:14
class.t3lib_db.php.patch2_for_380rc1.diff (1.68 KB) class.t3lib_db.php.patch2_for_380rc1.diff Administrator Admin, 2005-05-18 15:31
#1

Updated by Rainer Kuhn over 16 years ago

Refering to a recent discussion on the dev list ("[Typo3-dev] DBAL usage question") : I proposed removing the condition from the line

if ($this->debugOutput) $this->debug_lastBuiltQuery = $query;

in all query building functions (INSERTquery(), UPDATEquery(), DELETEquery andSELECTquery()) to make the last built query always available in $this->debug_lastBuiltQuery. I did a quick try with my TYPO3 3.7.0 installation and it worked as expected, so I attached a unified diff here.
Greetings, Rainer

#2

Updated by Michael Stucki over 16 years ago

I asked Kasper for the reason for not enabling this by default. Answer:

"I think it is because we want to save memory in the 99,9% of cases where
TYPO3 is NOT run under dev-circumstances!

Further, as you can see $this->debug_lastBuiltQuery is not meant to be
accessed from outside but rather presented to people from the
t3lib_db::debug() function. So developers should set the internal flag
->debug of the typo3_db class instead."

For your comfort I donate the fantastic stucki_debugdb extension to you! :-)

#3

Updated by Martin Kutschker over 16 years ago

Ok, then why don't we get an debugQueries switch?

Works likes this: the value defaults to false, if debugOutput is set then it is automatically enabled, but it can of course be set manually.

Then the conditions for debugging should read like this:

if ($this->debugQueries) $this->debug_lastBuiltQuery = $query;

BTW: I don't take memory footprint argument. TYPO3 is a fine and working system that wastes megabytes by copying arrays multiple times by bulidung huge config arrays. I don't care about the few extra bytes as wasting resources is a trait in the complete code.

#4

Updated by Rainer Kuhn over 16 years ago

I support masi's argumentation. Moreover the last query is not only needed under dev-circumstances but also in a production environment, e.g. for logging purposes.

#5

Updated by Michael Stucki over 16 years ago

please change this:

if ($this->debugOutput) $this->debug_lastBuiltQuery = $query;

to something like this:

if ($this->debugOutput || $this->store_lastBuiltQuery) $this->debug_lastBuiltQuery = $query;

I think everybody could live with that...

#6

Updated by Rainer Kuhn over 16 years ago

I asked Kasper for the suggestions posted here and he agreed with stucki's suggestion:

"if ($this->debugOutput || $this->store_lastBuiltQuery)
$this->debug_lastBuiltQuery = $query;

This is fine with me."

So I've attached the resulting unified diff here, this one is based on TYPO3 3.8.0rc1: class.t3lib_db.php.patch2_for_380rc1.diff

#7

Updated by Michael Stucki over 16 years ago

Fixed in 3.8.

Also available in: Atom PDF