<defaultvalue>0</defaultvalue>
</option>
- <option name="debug_mode">
+ <option name="enable_debug_mode">
<categoryname>module.system</categoryname>
- <optiontype>radiobuttons</optiontype>
- <!-- TODO: change to 'production' later -->
- <defaultvalue><![CDATA[debug]]></defaultvalue>
- <selectoptions>
- <![CDATA[debug:wcf.acp.option.debug_mode.debug
-production:wcf.acp.option.debug_mode.production]]>
- </selectoptions>
+ <optiontype>boolean</optiontype>
+ <!-- TODO: change to '0' (production mode) later -->
+ <defaultvalue>1</defaultvalue>
+ </option>
+
+ <option name="enable_benchmark">
+ <categoryname>module.system</categoryname>
+ <optiontype>boolean</optiontype>
+ <!-- TODO: change to '0' (production mode) later -->
+ <defaultvalue>1</defaultvalue>
</option>
<!-- general.page -->
--- /dev/null
+<p style="margin-top: 10px; font-size: .85em" id="benchmark">Execution time: {@$__wcf->getBenchmark()->getExecutionTime()}s ({#($__wcf->getBenchmark()->getExecutionTime()-$__wcf->getBenchmark()->getQueryExecutionTime())/$__wcf->getBenchmark()->getExecutionTime()*100}% PHP, {#$__wcf->getBenchmark()->getQueryExecutionTime()/$__wcf->getBenchmark()->getExecutionTime()*100}% SQL) | SQL queries: {#$__wcf->getBenchmark()->getQueryCount()}</p>
+
+{if ENABLE_DEBUG_MODE}
+ <ul id="benchmarkDetails" style="display: none; max-height: 500px; overflow: auto">
+ {foreach from=$__wcf->getBenchmark()->getItems() item=item}
+ <li style="margin-bottom: 8px;"{if $item.use >= 0.01} class="hot"{/if}>{if $item.type == 1}(SQL Query) {/if}{$item.text}<br /><small style="font-size: .85em">Execution time: {@$item.use}s</small></li>
+ {/foreach}
+ </ul>
+
+ <script type="text/javascript">
+ //<![CDATA[
+ $(function() {
+ $('#benchmark').click(function() {
+ WCF.showDialog('benchmarkDetails', true);
+ return false;
+ });
+ });
+ //]]>
+ </script>
+{/if}
\ No newline at end of file
<!-- FOOTER -->
<footer id="pageFooter" class="pageFooter">
<div>
- {include file=footerMenu}
+ {include file='footerMenu'}
</div>
- <p style="margin-top: 10px; font-size: .85em" id="benchmark">Execution time: {@$__wcf->getBenchmark()->getExecutionTime()}s ({#($__wcf->getBenchmark()->getExecutionTime()-$__wcf->getBenchmark()->getQueryExecutionTime())/$__wcf->getBenchmark()->getExecutionTime()*100}% PHP, {#$__wcf->getBenchmark()->getQueryExecutionTime()/$__wcf->getBenchmark()->getExecutionTime()*100}% SQL) | SQL queries: {#$__wcf->getBenchmark()->getQueryCount()}</p>
-
- <ul id="benchmarkDetails" style="display: none; max-height: 500px; overflow: auto">
- {foreach from=$__wcf->getBenchmark()->getItems() item=item}
- <li style="margin-bottom: 8px;{if $item.use >= 0.01} color: #b00{/if}">{if $item.type == 1}(SQL Query) {/if}{$item.text}<br /><small style="font-size: .85em">Execution time: {@$item.use}s</small></li>
- {/foreach}
- </ul>
-
- <script type="text/javascript">
- //<![CDATA[
- $(function() {
- $('#benchmark').click(function() {
- WCF.showDialog('benchmarkDetails', true);
- return false;
- });
- });
- //]]>
- </script>
+ {if ENABLE_BENCHMARK}{include file='benchmark'}{/if}
{event name='copyright'}
</footer>
//]]>
</script>
-{if DEBUG_MODE == 'debug'}
+{if ENABLE_DEBUG_MODE}
<!--
{$name} thrown in {$file} ({@$line})
Stracktrace:
background-color: rgba(255, 170, 34, .7);
}
+.hot {
+ color: #b00;
+}
+
/* ############## Body ############## */
--- /dev/null
+<p style="margin-top: 10px; font-size: .85em" id="benchmark">Execution time: {@$__wcf->getBenchmark()->getExecutionTime()}s ({#($__wcf->getBenchmark()->getExecutionTime()-$__wcf->getBenchmark()->getQueryExecutionTime())/$__wcf->getBenchmark()->getExecutionTime()*100}% PHP, {#$__wcf->getBenchmark()->getQueryExecutionTime()/$__wcf->getBenchmark()->getExecutionTime()*100}% SQL) | SQL queries: {#$__wcf->getBenchmark()->getQueryCount()}</p>
+
+{if ENABLE_DEBUG_MODE}
+ <ul id="benchmarkDetails" style="display: none; max-height: 500px; overflow: auto">
+ {foreach from=$__wcf->getBenchmark()->getItems() item=item}
+ <li style="margin-bottom: 8px;"{if $item.use >= 0.01} class="hot"{/if}>{if $item.type == 1}(SQL Query) {/if}{$item.text}<br /><small style="font-size: .85em">Execution time: {@$item.use}s</small></li>
+ {/foreach}
+ </ul>
+
+ <script type="text/javascript">
+ //<![CDATA[
+ $(function() {
+ $('#benchmark').click(function() {
+ WCF.showDialog('benchmarkDetails', true);
+ return false;
+ });
+ });
+ //]]>
+ </script>
+{/if}
\ No newline at end of file
</ul>
</nav>
</div>
- <adress class="copyright"><a href="http://www.woltlab.com" title="Go to the WoltLab website">Copyright © 2001-2011 WoltLab® GmbH</a></adress>
+
+ {if ENABLE_BENCHMARK}{include file='benchmark' sandbox=false}{/if}
+
+ <address class="copyright"><a href="http://www.woltlab.com" title="Go to the WoltLab website">Copyright © 2001-2011 WoltLab® GmbH</a></address>
</footer>
<!-- /FOOTER -->
<a id="bottom"></a>
return null;
}
+
+ /**
+ * Returns true if the debug mode is enabled, otherwise false.
+ *
+ * @return boolean
+ */
+ public static function debugModeIsEnabled() {
+ if (defined('ENABLE_DEBUG_MODE') && ENABLE_DEBUG_MODE) return true;
+ return false;
+ }
+
+ /**
+ * Returns true if benchmarking is enabled, otherwise false.
+ *
+ * @return boolean
+ */
+ public static function benchmarkIsEnabled() {
+ // benchmarking is enabled by default
+ if (!defined('ENABLE_BENCHMARK') || ENABLE_BENCHMARK) return true;
+ return false;
+ }
}
define('HTTP_GZIP_LEVEL', 0);
define('CACHE_SOURCE_TYPE', 'disk');
define('MODULE_MASTER_PASSWORD', 1);
-define('DEBUG_MODE', 'debug');
+define('ENABLE_DEBUG_MODE', 1);
+define('ENABLE_BENCHMARK', 1);
/**
* WCFSetup executes the installation of the basic wcf systems.
use wcf\system\benchmark\Benchmark;
use wcf\system\database\Database;
use wcf\system\database\DatabaseException;
+use wcf\system\WCF;
/**
* This is an implementation of prepared statements based upon pdo statements.
$this->database->incrementQueryCount();
try {
- Benchmark::getInstance()->start($this->query, Benchmark::TYPE_SQL_QUERY);
+ if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->start($this->query, Benchmark::TYPE_SQL_QUERY);
if (!count($parameters)) $result = $this->pdoStatement->execute();
else $result = $this->pdoStatement->execute($parameters);
- Benchmark::getInstance()->stop();
+ if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->stop();
return $result;
}
<?php
namespace wcf\system\exception;
+use wcf\system\WCF;
use wcf\util\JSON;
/**
public function __construct($message, $stacktrace = null) {
if ($stacktrace === null) $stacktrace = $this->getTraceAsString();
- if (DEBUG_MODE == 'debug') {
+ if (WCF::debugModeIsEnabled()) {
$responseData = array(
'message' => $message,
'stacktrace' => nl2br($stacktrace)
<?php
namespace wcf\system\exception;
+use wcf\system\WCF;
/**
* A logged exceptions prevents information disclosures and provides an easy
* @see \Exception::getMessage()
*/
public function _getMessage() {
- if (DEBUG_MODE == 'production') {
+ if (!WCF::debugModeIsEnabled()) {
return 'An error occured. Sorry.';
}
<?php
namespace wcf\system\exception;
+use wcf\system\WCF;
use wcf\util\StringUtil;
/**
<div class="systemException">
<h1>Fatal error: <?php echo StringUtil::encodeHTML($this->_getMessage()); ?></h1>
- <?php if (DEBUG_MODE == 'debug') { ?>
+ <?php if (WCF::debugModeIsEnabled()) { ?>
<div>
<p><?php echo $this->getDescription(); ?></p>
<?php
namespace wcf\system\exception;
+use wcf\system\WCF;
/**
* A UserException is thrown when a user gives invalid input data.
* @see wcf\system\exception\IPrintableException::show()
*/
public function show() {
- if (DEBUG_MODE == 'debug') {
+ if (WCF::debugModeIsEnabled()) {
echo '<pre>' . $this->getTraceAsString() . '</pre>';
}
else {
define('SESSION_VALIDATE_USER_AGENT', 0);
define('CACHE_SOURCE_TYPE', 'disk');
-define('MODULE_MASTER_PASSWORD', 1);
+define('MODULE_MASTER_PASSWORD', 0);
define('TIMEZONE', 'Europe/Berlin');
-// TODO: Change to 'production' later
-define('DEBUG_MODE', 'debug');
+define('ENABLE_DEBUG_MODE', 1);
+define('ENABLE_BENCHMARK', 1);