diff --git wp-includes/wp-db.php wp-includes/wp-db.php
index 46851b14fb..97bb8f0a83 100644
|
|
class wpdb { |
180 | 180 | * @since 1.5.0 |
181 | 181 | * @since 2.5.0 The third element in each query log was added to record the calling functions. |
182 | 182 | * @since 5.1.0 The fourth element in each query log was added to record the start time. |
| 183 | * @since 5.3.0 The fifth element in each query log was added to record custom data. |
183 | 184 | * |
184 | 185 | * @var array[] { |
185 | 186 | * Array of queries that were executed. |
… |
… |
class wpdb { |
191 | 192 | * @type float $1 Total time spent on the query, in seconds. |
192 | 193 | * @type string $2 Comma separated list of the calling functions. |
193 | 194 | * @type float $3 Unix timestamp of the time at the start of the query. |
| 195 | * @type array $4 Custom query data. |
194 | 196 | * } |
195 | 197 | * } |
196 | 198 | */ |
… |
… |
class wpdb { |
2018 | 2020 | $this->num_queries++; |
2019 | 2021 | |
2020 | 2022 | if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) { |
2021 | | $this->queries[] = array( |
| 2023 | $this->log_query( |
2022 | 2024 | $query, |
2023 | 2025 | $this->timer_stop(), |
2024 | 2026 | $this->get_caller(), |
2025 | 2027 | $this->time_start, |
| 2028 | array() |
2026 | 2029 | ); |
2027 | 2030 | } |
2028 | 2031 | } |
2029 | 2032 | |
| 2033 | /** |
| 2034 | * Logs query data. |
| 2035 | * |
| 2036 | * @since 5.3.0 |
| 2037 | * |
| 2038 | * @param string $query The query's SQL. |
| 2039 | * @param float $query_time Total time spent on the query, in seconds. |
| 2040 | * @param string $query_callstack Comma separated list of the calling functions. |
| 2041 | * @param float $query_start Unix timestamp of the time at the start of the query. |
| 2042 | * @param array $query_data Custom query data. |
| 2043 | * } |
| 2044 | */ |
| 2045 | public function log_query( $query, $query_time, $query_callstack, $query_start, $query_data ) { |
| 2046 | /** |
| 2047 | * Filters the query data being logged. |
| 2048 | * |
| 2049 | * Caution should be used when modifying any of this data, it is recommended that any additional |
| 2050 | * information you need to store about a query be added as a new associative entry to the fourth |
| 2051 | * element $query_data. |
| 2052 | * |
| 2053 | * @since 5.3.0 |
| 2054 | * |
| 2055 | * @param array $query_data Custom query data. |
| 2056 | * } |
| 2057 | */ |
| 2058 | $this->queries[] = array( |
| 2059 | $query, |
| 2060 | $query_time, |
| 2061 | $query_callstack, |
| 2062 | $query_start, |
| 2063 | apply_filters( 'log_query_data', $query_data ), |
| 2064 | ); |
| 2065 | } |
| 2066 | |
2030 | 2067 | /** |
2031 | 2068 | * Generates and returns a placeholder escape string for use in queries returned by ::prepare(). |
2032 | 2069 | * |