Bring back DBG_USER (old debug method), fixed bugsnag handler (#1701)

* Rollback some changes

* Updated

* Updated

* Updated

* Update SqlDb.php

* Updated

* Update Ajax.php

* Update Redis.php

* Update Redis.php

* Update Memcached.php

* Update File.php

* Updated

* Updated

* Update CHANGELOG.md

* Update Sqlite.php

* Update SqlDb.php

* Update common.php

* Update Dev.php

* Update config.php

* Update User.php

* Update defines.php

* Updated

* Update User.php

* Update User.php

* Update User.php

* Update User.php

* Update config.php

* Update Dev.php

* Updated

* Update Dev.php

* Update Dev.php

* Update SqlDb.php

* Revert "Update SqlDb.php"

This reverts commit d7c05d85ec.

* Update Dev.php

* Update Dev.php

* Update Dev.php

* Update Dev.php

* Update CHANGELOG.md
This commit is contained in:
Roman Kelesidis 2024-12-08 21:28:35 +07:00 committed by GitHub
commit f71deed544
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 160 additions and 141 deletions

View file

@ -1,5 +1,4 @@
# Common params
APP_ENV=local
APP_CRON_ENABLED=true
APP_DEMO_MODE=false

View file

@ -21,6 +21,7 @@
- Show torrent unregister action in log actions [\#1696](https://github.com/torrentpier/torrentpier/pull/1696) ([belomaxorka](https://github.com/belomaxorka))
- Show torrent status changes in actions log [\#1688](https://github.com/torrentpier/torrentpier/pull/1688) ([belomaxorka](https://github.com/belomaxorka))
- Show torrent type (gold / silver) changes in actions log [\#1689](https://github.com/torrentpier/torrentpier/pull/1689) ([belomaxorka](https://github.com/belomaxorka))
- Bring back `DBG_USER` (old debug method), fixed bugsnag handler [\#1701](https://github.com/torrentpier/torrentpier/pull/1701) ([belomaxorka](https://github.com/belomaxorka))
- Merged some fixes from `new-attachments` branch [\#1700](https://github.com/torrentpier/torrentpier/pull/1700) ([belomaxorka](https://github.com/belomaxorka))
- Changed database encoding to `utf8mb4_unicode_ci` [\#1684](https://github.com/torrentpier/torrentpier/pull/1684) ([belomaxorka](https://github.com/belomaxorka))
- Demo mode: Save user language in cookies [\#1584](https://github.com/torrentpier/torrentpier/pull/1584) ([belomaxorka](https://github.com/belomaxorka))

View file

@ -89,7 +89,8 @@ if (is_file(BB_PATH . '/library/config.local.php')) {
/**
* Error reporting
*/
$debug = new \TorrentPier\Dev();
define('DBG_USER', isset($_COOKIE[COOKIE_DBG]));
(new \TorrentPier\Dev());
/**
* Server variables initialize

View file

@ -484,6 +484,10 @@ $bb_cfg['telegram_sender'] = [
];
// Special users
$bb_cfg['dbg_users'] = [
// Syntax: 'user_id' => 'username'
2 => 'admin',
];
$bb_cfg['unlimited_users'] = [
// Syntax: 'user_id' => 'username'
2 => 'admin',

View file

@ -35,6 +35,7 @@ define('UPDATER_FILE', INT_DATA_DIR . '/updater.json');
define('API_IP_URL', 'https://freeipapi.com/api/json/');
define('CHECKSUMS_FILE', INT_DATA_DIR . '/checksums.md5');
define('RESTORE_CORRUPT_CONFIRM_FILE', INT_DATA_DIR . '/rescorrupt.integrity');
define('COOKIE_DBG', 'bb_dbg');
// Templates
define('ADMIN_TPL_DIR', TEMPLATES_DIR . '/admin/');
@ -68,6 +69,8 @@ define('LOG_MAX_SIZE', 1048576); // bytes
// Error reporting
ini_set('error_reporting', E_ALL); // PHP error reporting mode | https://www.php.net/manual/en/errorfunc.constants.php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
define('MYSQLI_ERROR_REPORTING', MYSQLI_REPORT_ERROR); // MySQL error reporting mode | https://www.php.net/manual/mysqli-driver.report-mode.php
ini_set('log_errors', 1); // Enable logging (For native & Whoops)
ini_set('error_log', LOG_DIR . '/php_errors.log'); // path to log file enabled only if log_errors == 1 (native)

View file

@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
global $bb_cfg, $debug, $userdata, $template, $DBS, $lang;
global $bb_cfg, $userdata, $template, $DBS, $lang;
if (!empty($template)) {
$template->assign_vars([
@ -25,7 +25,7 @@ if (!empty($template)) {
$template->pparse('page_footer');
}
$show_dbg_info = (!$debug->isProduction && !(isset($_GET['pane']) && $_GET['pane'] == 'left'));
$show_dbg_info = (DBG_USER && !(isset($_GET['pane']) && $_GET['pane'] == 'left'));
if (!$bb_cfg['gzip_compress']) {
flush();

View file

@ -71,7 +71,7 @@ if (!empty($_COOKIE['explain'])) {
}
}
$sql_log = !empty($_COOKIE['sql_log']) ? $debug->getSqlLog() : false;
$sql_log = !empty($_COOKIE['sql_log']) ? \TorrentPier\Dev::getSqlLog() : false;
if ($sql_log) {
echo '<div class="sqlLog" id="sqlLog">' . $sql_log . '</div><!-- / sqlLog --><br clear="all" />';

View file

@ -174,11 +174,10 @@ class Ajax
*/
public function send(): void
{
global $debug;
$this->response['action'] = $this->action;
if ($debug->sqlDebugAllowed()) {
$this->response['sql_log'] = $debug->getSqlLog();
if (Dev::sqlDebugAllowed()) {
$this->response['sql_log'] = Dev::getSqlLog();
}
// sending output will be handled by $this->ob_handler()
@ -194,12 +193,8 @@ class Ajax
*/
public function ob_handler($contents): string
{
global $debug;
if (!$debug->isProduction) {
if ($contents) {
$this->response['raw_output'] = $contents;
}
if (DBG_USER && $contents) {
$this->response['raw_output'] = $contents;
}
$response_js = json_encode($this->response, JSON_THROW_ON_ERROR);

View file

@ -10,7 +10,6 @@
namespace TorrentPier;
use Bugsnag\Client;
use Bugsnag\Handler;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\BrowserConsoleHandler;
@ -32,20 +31,6 @@ use Exception;
*/
class Dev
{
/**
* Environment type
*
* @var string
*/
private string $envType;
/**
* In production mode
*
* @var bool
*/
public bool $isProduction = false;
/**
* Whoops instance
*
@ -58,33 +43,22 @@ class Dev
*/
public function __construct()
{
$this->envType = strtolower(env('APP_ENV', 'production'));
$this->whoops = new Run;
switch ($this->envType) {
case 'prod':
case 'production':
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
$this->getWhoopsProduction();
$this->isProduction = true;
break;
case 'dev':
case 'local':
case 'development':
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
$this->getWhoops();
break;
if (DBG_USER) {
$this->getWhoopsOnPage();
} else {
$this->getWhoopsPlaceholder();
}
$this->getBugsnag();
$this->getWhoopsLogger();
$this->getTelegramSender();
$this->getBugsnag();
$this->whoops->register();
}
/**
* Bugsnag debug driver
* [Whoops] Bugsnag handler
*
* @return void
*/
@ -96,11 +70,14 @@ class Dev
return;
}
Handler::register(Client::make($bb_cfg['bugsnag']['api_key']));
$bugsnag = Client::make($bb_cfg['bugsnag']['api_key']);
$this->whoops->pushHandler(function ($e) use ($bugsnag) {
$bugsnag->notifyException($e);
});
}
/**
* Telegram debug driver
* [Whoops] Telegram handler
*
* @return void
*/
@ -108,37 +85,26 @@ class Dev
{
global $bb_cfg;
if ($bb_cfg['telegram_sender']['enabled']) {
$telegramSender = new PlainTextHandler();
$telegramSender->loggerOnly(true);
$telegramSender->setLogger((new Logger(
APP_NAME,
[(new TelegramHandler($bb_cfg['telegram_sender']['token'], (int)$bb_cfg['telegram_sender']['chat_id'], timeout: (int)$bb_cfg['telegram_sender']['timeout']))
->setFormatter(new TelegramFormatter())]
)));
$this->whoops->pushHandler($telegramSender);
if (!$bb_cfg['telegram_sender']['enabled']) {
return;
}
$telegramSender = new PlainTextHandler();
$telegramSender->loggerOnly(true);
$telegramSender->setLogger((new Logger(
APP_NAME,
[(new TelegramHandler($bb_cfg['telegram_sender']['token'], (int)$bb_cfg['telegram_sender']['chat_id'], timeout: (int)$bb_cfg['telegram_sender']['timeout']))
->setFormatter(new TelegramFormatter())]
)));
$this->whoops->pushHandler($telegramSender);
}
/**
* Whoops production debug driver
* [Whoops] On page handler (in debug)
*
* @return void
*/
private function getWhoopsProduction(): void
{
$this->whoops->pushHandler(function () {
global $bb_cfg;
echo $bb_cfg['whoops']['error_message'];
});
}
/**
* Whoops debug driver
*
* @return void
*/
private function getWhoops(): void
private function getWhoopsOnPage(): void
{
global $bb_cfg;
@ -164,20 +130,42 @@ class Dev
->setFormatter((new LineFormatter(null, null, true)))]
)));
$this->whoops->pushHandler($loggingInConsole);
}
/**
* Log errors in file
*/
if ((int)ini_get('log_errors') === 1) {
$loggingInFile = new PlainTextHandler();
$loggingInFile->loggerOnly(true);
$loggingInFile->setLogger((new Logger(
APP_NAME,
[(new StreamHandler(WHOOPS_LOG_FILE))
->setFormatter((new LineFormatter(null, null, true)))]
)));
$this->whoops->pushHandler($loggingInFile);
/**
* [Whoops] Logger handler
*
* @return void
*/
private function getWhoopsLogger(): void
{
if ((int)ini_get('log_errors') !== 1) {
return;
}
$loggingInFile = new PlainTextHandler();
$loggingInFile->loggerOnly(true);
$loggingInFile->setLogger((new Logger(
APP_NAME,
[(new StreamHandler(WHOOPS_LOG_FILE))
->setFormatter((new LineFormatter(null, null, true)))]
)));
$this->whoops->pushHandler($loggingInFile);
}
/**
* [Whoops] Placeholder handler (non debug)
*
* @return void
*/
private function getWhoopsPlaceholder(): void
{
global $bb_cfg;
$this->whoops->pushHandler(function ($e) use ($bb_cfg) {
echo $bb_cfg['whoops']['error_message'];
echo "<hr>Error: {$e->getMessage()}.";
});
}
/**
@ -186,28 +174,28 @@ class Dev
* @return string
* @throws Exception
*/
public function getSqlLog(): string
public static function getSqlLog(): string
{
global $DBS, $CACHES, $datastore;
$log = '';
foreach ($DBS->srv as $srv_name => $db_obj) {
$log .= !empty($db_obj->dbg) ? $this->getSqlLogHtml($db_obj, "database: $srv_name [{$db_obj->engine}]") : '';
$log .= !empty($db_obj->dbg) ? self::getSqlLogHtml($db_obj, "database: $srv_name [{$db_obj->engine}]") : '';
}
foreach ($CACHES->obj as $cache_name => $cache_obj) {
if (!empty($cache_obj->db->dbg)) {
$log .= $this->getSqlLogHtml($cache_obj->db, "cache: $cache_name [{$cache_obj->db->engine}]");
$log .= self::getSqlLogHtml($cache_obj->db, "cache: $cache_name [{$cache_obj->db->engine}]");
} elseif (!empty($cache_obj->dbg)) {
$log .= $this->getSqlLogHtml($cache_obj, "cache: $cache_name [{$cache_obj->engine}]");
$log .= self::getSqlLogHtml($cache_obj, "cache: $cache_name [{$cache_obj->engine}]");
}
}
if (!empty($datastore->db->dbg)) {
$log .= $this->getSqlLogHtml($datastore->db, "cache: datastore [{$datastore->db->engine}]");
$log .= self::getSqlLogHtml($datastore->db, "cache: datastore [{$datastore->db->engine}]");
} elseif (!empty($datastore->dbg)) {
$log .= $this->getSqlLogHtml($datastore, "cache: datastore [{$datastore->engine}]");
$log .= self::getSqlLogHtml($datastore, "cache: datastore [{$datastore->engine}]");
}
return $log;
@ -218,9 +206,9 @@ class Dev
*
* @return bool
*/
public function sqlDebugAllowed(): bool
public static function sqlDebugAllowed(): bool
{
return (SQL_DEBUG && !$this->isProduction && !empty($_COOKIE['sql_log']));
return (SQL_DEBUG && DBG_USER && !empty($_COOKIE['sql_log']));
}
/**
@ -232,13 +220,13 @@ class Dev
* @return string
* @throws Exception
*/
private function getSqlLogHtml(object $db_obj, string $log_name): string
private static function getSqlLogHtml(object $db_obj, string $log_name): string
{
$log = '';
foreach ($db_obj->dbg as $i => $dbg) {
$id = "sql_{$i}_" . random_int(0, mt_getrandmax());
$sql = $this->shortQuery($dbg['sql'], true);
$sql = self::shortQuery($dbg['sql'], true);
$time = sprintf('%.4f', $dbg['time']);
$perc = '[' . round($dbg['time'] * 100 / $db_obj->sql_timetotal) . '%]';
$info = !empty($dbg['info']) ? $dbg['info'] . ' [' . $dbg['src'] . ']' : $dbg['src'];
@ -261,7 +249,7 @@ class Dev
* @param bool $esc_html
* @return string
*/
public function shortQuery(string $sql, bool $esc_html = false): string
public static function shortQuery(string $sql, bool $esc_html = false): string
{
$max_len = 100;
$sql = str_compact($sql);

View file

@ -9,6 +9,8 @@
namespace TorrentPier\Legacy\Cache;
use TorrentPier\Dev;
use MatthiasMullie\Scrapbook\Adapters\Apc;
/**
@ -52,11 +54,9 @@ class APCu extends Common
*/
public function __construct(string $prefix)
{
global $debug;
$this->apcu = new Apc();
$this->prefix = $prefix;
$this->dbg_enabled = $debug->sqlDebugAllowed();
$this->dbg_enabled = Dev::sqlDebugAllowed();
}
/**

View file

@ -9,6 +9,8 @@
namespace TorrentPier\Legacy\Cache;
use TorrentPier\Dev;
/**
* Class Common
* @package TorrentPier\Legacy\Cache
@ -70,8 +72,6 @@ class Common
public function debug($mode, $cur_query = null)
{
global $debug;
if (!$this->dbg_enabled) {
return;
}
@ -82,7 +82,7 @@ class Common
switch ($mode) {
case 'start':
$this->sql_starttime = utime();
$dbg['sql'] = $debug->shortQuery($cur_query ?? $this->cur_query);
$dbg['sql'] = Dev::shortQuery($cur_query ?? $this->cur_query);
$dbg['src'] = $this->debug_find_source();
$dbg['file'] = $this->debug_find_source('file');
$dbg['line'] = $this->debug_find_source('line');

View file

@ -9,6 +9,8 @@
namespace TorrentPier\Legacy\Cache;
use TorrentPier\Dev;
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;
use MatthiasMullie\Scrapbook\Adapters\Flysystem;
@ -55,13 +57,11 @@ class File extends Common
*/
public function __construct(string $dir, string $prefix)
{
global $debug;
$adapter = new LocalFilesystemAdapter($dir, null, LOCK_EX);
$filesystem = new Filesystem($adapter);
$this->file = new Flysystem($filesystem);
$this->prefix = $prefix;
$this->dbg_enabled = $debug->sqlDebugAllowed();
$this->dbg_enabled = Dev::sqlDebugAllowed();
}
/**

View file

@ -9,6 +9,8 @@
namespace TorrentPier\Legacy\Cache;
use TorrentPier\Dev;
use Memcached as MemcachedClient;
use MatthiasMullie\Scrapbook\Adapters\Memcached as MemcachedCache;
@ -75,12 +77,10 @@ class Memcached extends Common
*/
public function __construct(array $cfg, string $prefix)
{
global $debug;
$this->client = new MemcachedClient();
$this->cfg = $cfg;
$this->prefix = $prefix;
$this->dbg_enabled = $debug->sqlDebugAllowed();
$this->dbg_enabled = Dev::sqlDebugAllowed();
}
/**

View file

@ -9,6 +9,8 @@
namespace TorrentPier\Legacy\Cache;
use TorrentPier\Dev;
use Redis as RedisClient;
use MatthiasMullie\Scrapbook\Adapters\Redis as RedisCache;
@ -75,12 +77,10 @@ class Redis extends Common
*/
public function __construct(array $cfg, string $prefix)
{
global $debug;
$this->client = new RedisClient();
$this->cfg = $cfg;
$this->prefix = $prefix;
$this->dbg_enabled = $debug->sqlDebugAllowed();
$this->dbg_enabled = Dev::sqlDebugAllowed();
}
/**

View file

@ -9,6 +9,8 @@
namespace TorrentPier\Legacy\Cache;
use TorrentPier\Dev;
use MatthiasMullie\Scrapbook\Adapters\SQLite as SQLiteCache;
use PDO;
@ -54,12 +56,10 @@ class Sqlite extends Common
*/
public function __construct(string $dir, string $prefix)
{
global $debug;
$client = new PDO("sqlite:$dir.db");
$this->sqlite = new SQLiteCache($client);
$this->prefix = $prefix;
$this->dbg_enabled = $debug->sqlDebugAllowed();
$this->dbg_enabled = Dev::sqlDebugAllowed();
}
/**

View file

@ -463,8 +463,22 @@ class User
*/
public function set_session_cookies($user_id)
{
global $bb_cfg;
$debug_cookies = [
COOKIE_DBG,
'explain',
'sql_log',
'sql_log_full'
];
if ($user_id == GUEST_UID) {
$delete_cookies = [COOKIE_DATA, 'torhelp', 'user_lang'];
$delete_cookies = [
COOKIE_DATA,
'torhelp',
'user_lang'
];
$delete_cookies = array_merge($delete_cookies, $debug_cookies);
foreach ($delete_cookies as $cookie) {
if (isset($_COOKIE[$cookie])) {
@ -472,6 +486,22 @@ class User
}
}
} else {
if (!isset($bb_cfg['dbg_users'][$this->data['user_id']]) && DBG_USER) {
bb_setcookie(COOKIE_DBG, null);
} elseif (isset($bb_cfg['dbg_users'][$this->data['user_id']]) && !DBG_USER) {
bb_setcookie(COOKIE_DBG, hash('xxh128', $bb_cfg['dbg_users'][$this->data['user_id']]), COOKIE_SESSION);
}
// Unset sql debug cookies if SQL_DEBUG is disabled or DBG_USER cookie not present
if (!SQL_DEBUG || !DBG_USER) {
foreach ($debug_cookies as $cookie) {
if (isset($_COOKIE[$cookie])) {
bb_setcookie($cookie, null);
}
}
}
// Set bb_data (session) cookie
$c_sdata_resv = !empty($_COOKIE[COOKIE_DATA]) ? $_COOKIE[COOKIE_DATA] : null;
$c_sdata_curr = ($this->sessiondata) ? json_encode($this->sessiondata) : '';

View file

@ -9,6 +9,8 @@
namespace TorrentPier\Legacy\Datastore;
use TorrentPier\Dev;
use MatthiasMullie\Scrapbook\Adapters\Apc;
/**
@ -45,11 +47,9 @@ class APCu extends Common
*/
public function __construct(string $prefix)
{
global $debug;
$this->apcu = new Apc();
$this->prefix = $prefix;
$this->dbg_enabled = $debug->sqlDebugAllowed();
$this->dbg_enabled = Dev::sqlDebugAllowed();
}
/**

View file

@ -9,6 +9,8 @@
namespace TorrentPier\Legacy\Datastore;
use TorrentPier\Dev;
/**
* Class Common
* @package TorrentPier\Legacy\Datastore
@ -155,8 +157,6 @@ class Common
public function debug($mode, $cur_query = null)
{
global $debug;
if (!$this->dbg_enabled) {
return;
}
@ -167,7 +167,7 @@ class Common
switch ($mode) {
case 'start':
$this->sql_starttime = utime();
$dbg['sql'] = $debug->shortQuery($cur_query ?? $this->cur_query);
$dbg['sql'] = Dev::shortQuery($cur_query ?? $this->cur_query);
$dbg['src'] = $this->debug_find_source();
$dbg['file'] = $this->debug_find_source('file');
$dbg['line'] = $this->debug_find_source('line');

View file

@ -9,6 +9,8 @@
namespace TorrentPier\Legacy\Datastore;
use TorrentPier\Dev;
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;
use MatthiasMullie\Scrapbook\Adapters\Flysystem;
@ -48,13 +50,11 @@ class File extends Common
*/
public function __construct(string $dir, string $prefix)
{
global $debug;
$adapter = new LocalFilesystemAdapter($dir, null, LOCK_EX);
$filesystem = new Filesystem($adapter);
$this->file = new Flysystem($filesystem);
$this->prefix = $prefix;
$this->dbg_enabled = $debug->sqlDebugAllowed();
$this->dbg_enabled = Dev::sqlDebugAllowed();
}
/**

View file

@ -9,6 +9,8 @@
namespace TorrentPier\Legacy\Datastore;
use TorrentPier\Dev;
use Memcached as MemcachedClient;
use MatthiasMullie\Scrapbook\Adapters\Memcached as MemcachedCache;
@ -68,12 +70,10 @@ class Memcached extends Common
*/
public function __construct(array $cfg, string $prefix)
{
global $debug;
$this->client = new MemcachedClient();
$this->cfg = $cfg;
$this->prefix = $prefix;
$this->dbg_enabled = $debug->sqlDebugAllowed();
$this->dbg_enabled = Dev::sqlDebugAllowed();
}
/**

View file

@ -9,6 +9,8 @@
namespace TorrentPier\Legacy\Datastore;
use TorrentPier\Dev;
use Redis as RedisClient;
use MatthiasMullie\Scrapbook\Adapters\Redis as RedisCache;
@ -68,12 +70,10 @@ class Redis extends Common
*/
public function __construct(array $cfg, string $prefix)
{
global $debug;
$this->client = new RedisClient();
$this->cfg = $cfg;
$this->prefix = $prefix;
$this->dbg_enabled = $debug->sqlDebugAllowed();
$this->dbg_enabled = Dev::sqlDebugAllowed();
}
/**

View file

@ -9,6 +9,8 @@
namespace TorrentPier\Legacy\Datastore;
use TorrentPier\Dev;
use MatthiasMullie\Scrapbook\Adapters\SQLite as SQLiteCache;
use PDO;
@ -47,12 +49,10 @@ class Sqlite extends Common
*/
public function __construct(string $dir, string $prefix)
{
global $debug;
$client = new PDO("sqlite:$dir.db");
$this->sqlite = new SQLiteCache($client);
$this->prefix = $prefix;
$this->dbg_enabled = $debug->sqlDebugAllowed();
$this->dbg_enabled = Dev::sqlDebugAllowed();
}
/**

View file

@ -11,6 +11,8 @@ namespace TorrentPier\Legacy;
use mysqli_result;
use TorrentPier\Dev;
/**
* Class SqlDb
* @package TorrentPier\Legacy
@ -55,10 +57,10 @@ class SqlDb
*/
public function __construct($cfg_values)
{
global $DBS, $debug;
global $DBS;
$this->cfg = array_combine($this->cfg_keys, $cfg_values);
$this->dbg_enabled = ($debug->sqlDebugAllowed() || !empty($_COOKIE['explain']));
$this->dbg_enabled = (Dev::sqlDebugAllowed() || !empty($_COOKIE['explain']));
$this->do_explain = ($this->dbg_enabled && !empty($_COOKIE['explain']));
$this->slow_time = SQL_SLOW_QUERY_TIME;
@ -830,8 +832,6 @@ class SqlDb
*/
public function log_query($log_file = 'sql_queries')
{
global $debug;
$q_time = ($this->cur_query_time >= 10) ? round($this->cur_query_time, 0) : sprintf('%.4f', $this->cur_query_time);
$msg = [];
$msg[] = round($this->sql_starttime);
@ -839,7 +839,7 @@ class SqlDb
$msg[] = sprintf('%-6s', $q_time);
$msg[] = sprintf('%05d', getmypid());
$msg[] = $this->db_server;
$msg[] = $debug->shortQuery($this->cur_query);
$msg[] = Dev::shortQuery($this->cur_query);
$msg = implode(LOG_SEPR, $msg);
$msg .= ($info = $this->query_info()) ? ' # ' . $info : '';
$msg .= ' # ' . $this->debug_find_source() . ' ';
@ -903,8 +903,6 @@ class SqlDb
*/
public function explain($mode, $html_table = '', array $row = [])
{
global $debug;
$query = str_compact($this->cur_query);
// remove comments
$query = preg_replace('#(\s*)(/\*)(.*)(\*/)(\s*)#', '', $query);
@ -950,7 +948,7 @@ class SqlDb
</tr>
<tr><td colspan="2">' . $this->explain_hold . '</td></tr>
</table>
<div class="sqlLog"><div id="' . $htid . '" class="sqlLogRow sqlExplain" style="padding: 0;">' . $debug->shortQuery($dbg['sql'], true) . '&nbsp;&nbsp;</div></div>
<div class="sqlLog"><div id="' . $htid . '" class="sqlLogRow sqlExplain" style="padding: 0;">' . Dev::shortQuery($dbg['sql'], true) . '&nbsp;&nbsp;</div></div>
<br />';
break;