Ticket #5218: wpdb-get-caller-r6256.diff
File wpdb-get-caller-r6256.diff, 1.2 KB (added by , 18 years ago) |
---|
-
wordpress/wp-includes/wp-db.php
210 210 ++$this->num_queries; 211 211 212 212 if (SAVEQUERIES) 213 $this->queries[] = array( $query, $this->timer_stop() );213 $this->queries[] = array( $query, $this->timer_stop(), $this->get_caller() ); 214 214 215 215 // If there is an error then take note of it.. 216 216 if ( mysql_error($this->dbh) ) { … … 457 457 { 458 458 return ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ); 459 459 } 460 461 /** 462 * Get the name of the function that called wpdb. 463 * @return string the name of the calling function 464 */ 465 function get_caller() { 466 $bt = debug_backtrace(); 467 $caller = ''; 468 469 foreach ($bt as $trace) { 470 if (@$trace['class'] == __CLASS__) 471 continue; 472 elseif (strtolower(@$trace['function']) == 'call_user_func_array') 473 continue; 474 elseif (strtolower(@$trace['function']) == 'apply_filters') 475 continue; 476 elseif (strtolower(@$trace['function']) == 'do_action') 477 continue; 478 479 $caller = $trace['function']; 480 break; 481 } 482 return $caller; 483 } 484 460 485 } 461 486 462 487 if ( ! isset($wpdb) )