mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 21:33:54 -07:00
Added ability to debug ajax_die() calls (#1023)
This commit is contained in:
parent
c9d223b346
commit
f2fe7d2e0c
5 changed files with 41 additions and 6 deletions
34
src/Ajax.php
34
src/Ajax.php
|
@ -147,6 +147,13 @@ class Ajax
|
|||
$this->response['error_code'] = $error_code;
|
||||
$this->response['error_msg'] = strip_tags($error_msg);
|
||||
|
||||
// Get caller info
|
||||
if (!empty($_COOKIE['explain'])) {
|
||||
$ajax_debug = 'ajax die: ' . $this->debug_find_source();
|
||||
$this->response['error_msg'] .= "\n\n" . $ajax_debug;
|
||||
$this->response['console_log'] = $ajax_debug;
|
||||
}
|
||||
|
||||
$this->send();
|
||||
}
|
||||
|
||||
|
@ -272,6 +279,33 @@ class Ajax
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find caller source
|
||||
*
|
||||
* @param string $mode
|
||||
* @return mixed|string
|
||||
*/
|
||||
function debug_find_source(string $mode = 'all'): mixed
|
||||
{
|
||||
if (empty($_COOKIE['explain'])) {
|
||||
return 'src disabled';
|
||||
}
|
||||
foreach (debug_backtrace() as $trace) {
|
||||
if (!empty($trace['file']) && $trace['file'] !== __FILE__) {
|
||||
switch ($mode) {
|
||||
case 'file':
|
||||
return $trace['file'];
|
||||
case 'line':
|
||||
return $trace['line'];
|
||||
case 'all':
|
||||
default:
|
||||
return hide_bb_path($trace['file']) . '(' . $trace['line'] . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
return 'src not found';
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit user profile actions
|
||||
*
|
||||
|
|
|
@ -91,10 +91,9 @@ class Common
|
|||
* Find caller source
|
||||
*
|
||||
* @param string $mode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function debug_find_source(string $mode = ''): string
|
||||
public function debug_find_source(string $mode = 'all'): string
|
||||
{
|
||||
if (!SQL_PREPEND_SRC_COMM) {
|
||||
return 'src disabled';
|
||||
|
@ -106,6 +105,7 @@ class Common
|
|||
return $trace['file'];
|
||||
case 'line':
|
||||
return $trace['line'];
|
||||
case 'all':
|
||||
default:
|
||||
return hide_bb_path($trace['file']) . '(' . $trace['line'] . ')';
|
||||
}
|
||||
|
|
|
@ -165,10 +165,9 @@ class Common
|
|||
* Find caller source
|
||||
*
|
||||
* @param string $mode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function debug_find_source(string $mode = ''): string
|
||||
public function debug_find_source(string $mode = 'all'): string
|
||||
{
|
||||
if (!SQL_PREPEND_SRC_COMM) {
|
||||
return 'src disabled';
|
||||
|
@ -180,6 +179,7 @@ class Common
|
|||
return $trace['file'];
|
||||
case 'line':
|
||||
return $trace['line'];
|
||||
case 'all':
|
||||
default:
|
||||
return hide_bb_path($trace['file']) . '(' . $trace['line'] . ')';
|
||||
}
|
||||
|
|
|
@ -845,10 +845,9 @@ class SqlDb
|
|||
* Find caller source
|
||||
*
|
||||
* @param string $mode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function debug_find_source(string $mode = ''): string
|
||||
public function debug_find_source(string $mode = 'all'): string
|
||||
{
|
||||
if (!SQL_PREPEND_SRC_COMM) {
|
||||
return 'src disabled';
|
||||
|
@ -860,6 +859,7 @@ class SqlDb
|
|||
return $trace['file'];
|
||||
case 'line':
|
||||
return $trace['line'];
|
||||
case 'all':
|
||||
default:
|
||||
return hide_bb_path($trace['file']) . '(' . $trace['line'] . ')';
|
||||
}
|
||||
|
|
|
@ -343,6 +343,7 @@ Ajax.prototype = {
|
|||
}
|
||||
} else if (response.error_code) {
|
||||
ajax.showErrorMsg(response.error_msg);
|
||||
console.log(response.console_log);
|
||||
$('.loading-1').removeClass('loading-1').html('error');
|
||||
} else {
|
||||
ajax.callback[action](response);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue