Esempio n. 1
0
 public function action_plugins_loaded()
 {
     # Register additional collectors:
     foreach (apply_filters('qm/collectors', array(), $this) as $collector) {
         QM_Collectors::add($collector);
     }
     # Dispatchers:
     QM_Util::include_files($this->plugin_path('dispatchers'));
     # Register built-in and additional dispatchers:
     foreach (apply_filters('qm/dispatchers', array(), $this) as $dispatcher) {
         QM_Dispatchers::add($dispatcher);
     }
 }
Esempio n. 2
0
 public function action_plugins_loaded()
 {
     # Register additional collectors:
     foreach (apply_filters('qm/collectors', array(), $this) as $collector) {
         QM_Collectors::add($collector);
     }
     # Load dispatchers:
     foreach (glob($this->plugin_path('dispatchers/*.php')) as $file) {
         include $file;
     }
     # Register built-in and additional dispatchers:
     foreach (apply_filters('qm/dispatchers', array(), $this) as $dispatcher) {
         QM_Dispatchers::add($dispatcher);
     }
 }
Esempio n. 3
0
        $trace = new QM_Backtrace();
        $filtered = $trace->get_filtered_trace();
        $caller = array();
        foreach ($filtered as $i => $item) {
            if (in_array($item['function'], array('load_plugin_textdomain', 'load_theme_textdomain', 'load_default_textdomain'), true)) {
                $caller = $item;
                $display = $i + 1;
                if (isset($filtered[$display])) {
                    $caller['display'] = $filtered[$display]['display'];
                }
                break;
            }
        }
        if (empty($caller)) {
            if (isset($filtered[1])) {
                $caller = $filtered[1];
            } else {
                $caller = $filtered[0];
            }
        }
        if (!isset($caller['file']) && isset($filtered[0]['file']) && isset($filtered[0]['line'])) {
            $caller['file'] = $filtered[0]['file'];
            $caller['line'] = $filtered[0]['line'];
        }
        $this->data['languages'][] = array('caller' => $caller, 'domain' => $domain, 'mofile' => $mofile, 'found' => file_exists($mofile) ? filesize($mofile) : false);
        return $override;
    }
}
# Load early to catch early errors
QM_Collectors::add(new QM_Collector_Languages());
Esempio n. 4
0
    }
    public function __construct()
    {
        parent::__construct();
        # See http://core.trac.wordpress.org/ticket/24583
        add_action('setted_site_transient', array($this, 'action_setted_site_transient'), 10, 3);
        add_action('setted_transient', array($this, 'action_setted_blog_transient'), 10, 3);
    }
    public function tear_down()
    {
        parent::tear_down();
        remove_action('setted_site_transient', array($this, 'action_setted_site_transient'), 10);
        remove_action('setted_transient', array($this, 'action_setted_blog_transient'), 10);
    }
    public function action_setted_site_transient($transient, $value = null, $expiration = null)
    {
        $this->setted_transient($transient, 'site', $value, $expiration);
    }
    public function action_setted_blog_transient($transient, $value = null, $expiration = null)
    {
        $this->setted_transient($transient, 'blog', $value, $expiration);
    }
    public function setted_transient($transient, $type, $value = null, $expiration = null)
    {
        $trace = new QM_Backtrace(array('ignore_items' => 1));
        $this->data['trans'][] = array('transient' => $transient, 'trace' => $trace, 'type' => $type, 'value' => $value, 'expiration' => $expiration);
    }
}
# Load early in case a plugin is setting transients when it initialises instead of after the `plugins_loaded` hook
QM_Collectors::add(new QM_Collector_Transients());
Esempio n. 5
0
        if (empty($this->display_errors)) {
            return;
        }
        if (empty($e) or !($e['type'] & (E_ERROR | E_PARSE | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_RECOVERABLE_ERROR))) {
            return;
        }
        if ($e['type'] & E_RECOVERABLE_ERROR) {
            $error = 'Catchable fatal error';
        } else {
            if ($e['type'] & E_COMPILE_WARNING) {
                $error = 'Warning';
            } else {
                $error = 'Fatal error';
            }
        }
        if (function_exists('xdebug_print_function_stack')) {
            xdebug_print_function_stack(sprintf('%1$s: %2$s in %3$s on line %4$d. Output triggered ', $error, $e['message'], $e['file'], $e['line']));
        } else {
            printf('<br /><b>%1$s</b>: %2$s in <b>%3$s</b> on line <b>%4$d</b><br />', htmlentities($error), htmlentities($e['message']), htmlentities($e['file']), intval($e['line']));
        }
    }
    public function tear_down()
    {
        parent::tear_down();
        ini_set('display_errors', $this->display_errors);
        restore_error_handler();
    }
}
# Load early to catch early errors
QM_Collectors::add(new QM_Collector_PHP_Errors());
Esempio n. 6
0
            return;
        }
        $silent = apply_filters('qm/collect/silent_http_errors', array('http_request_not_executed', 'airplane_mode_enabled'));
        foreach ($this->data['http'] as $key => &$http) {
            if (!isset($http['response'])) {
                // Timed out
                $http['response'] = new WP_Error('http_request_timed_out', __('Request timed out', 'query-monitor'));
                $http['end'] = floatval($http['start'] + $http['args']['timeout']);
            }
            if (is_wp_error($http['response'])) {
                if (!in_array($http['response']->get_error_code(), $silent)) {
                    $this->data['errors']['error'][] = $key;
                }
                $http['type'] = __('Error', 'query-monitor');
            } else {
                $http['type'] = intval(wp_remote_retrieve_response_code($http['response']));
                if ($http['type'] >= 400) {
                    $this->data['errors']['warning'][] = $key;
                }
            }
            $http['ltime'] = $http['end'] - $http['start'];
            $this->data['ltime'] += $http['ltime'];
            $http['component'] = $http['trace']->get_component();
            $this->log_type($http['type']);
            $this->log_component($http['component'], $http['ltime'], $http['type']);
        }
    }
}
# Load early in case a plugin is doing an HTTP request when it initialises instead of after the `plugins_loaded` hook
QM_Collectors::add(new QM_Collector_HTTP());
 public static function initialize()
 {
     add_filter('qm/outputter/html', array('QMCV_Collector_Variable_Checking', 'register_output'), 10, 2);
     QM_Collectors::add(new QMCV_Collector_Variable_Checking());
 }
Esempio n. 8
0
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
*/
class QM_Collector_Redirects extends QM_Collector
{
    public $id = 'redirects';
    public function name()
    {
        return __('Redirects', 'query-monitor');
    }
    public function __construct()
    {
        parent::__construct();
        add_filter('wp_redirect', array($this, 'filter_wp_redirect'), 999, 2);
    }
    public function filter_wp_redirect($location, $status)
    {
        if (!$location) {
            return $location;
        }
        $trace = new QM_Backtrace();
        $this->data['trace'] = $trace;
        $this->data['location'] = $location;
        $this->data['status'] = $status;
        return $location;
    }
}
# Load early in case a plugin is doing a redirect when it initialises instead of after the `plugins_loaded` hook
QM_Collectors::add(new QM_Collector_Redirects());