Disable Tracy debug bar in tests
[MAILPOET-2239]
This commit is contained in:
committed by
Rostislav Wolný
parent
09c35d0745
commit
a3411d0a15
@@ -4,6 +4,7 @@ namespace MailPoet\Cron;
|
||||
use MailPoet\Cron\Triggers\WordPress;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
use Tracy\Debugger;
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
@@ -30,6 +31,12 @@ class DaemonHttpRunner {
|
||||
}
|
||||
|
||||
function ping() {
|
||||
// if Tracy enabled & called by 'MailPoet Cron' user agent, disable Tracy Bar
|
||||
// (happens in CronHelperTest because it's not a real integration test - calls other WP instance)
|
||||
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
|
||||
if (class_exists(Debugger::class) && $user_agent === 'MailPoet Cron') {
|
||||
Debugger::$showBar = false;
|
||||
}
|
||||
$this->addCacheHeaders();
|
||||
$this->terminateRequest(self::PING_SUCCESS_RESPONSE);
|
||||
}
|
||||
|
@@ -12,17 +12,21 @@ $tracy_path = __DIR__ . '/tools/tracy.phar';
|
||||
if (WP_DEBUG && PHP_VERSION_ID >= 70100 && file_exists($tracy_path)) {
|
||||
require_once $tracy_path;
|
||||
|
||||
function render_tracy() {
|
||||
ob_start();
|
||||
Debugger::renderLoader();
|
||||
$tracy_script_html = ob_get_clean();
|
||||
if (getenv('MAILPOET_DISABLE_TRACY_BAR')) {
|
||||
Debugger::$showBar = false;
|
||||
} else {
|
||||
function render_tracy() {
|
||||
ob_start();
|
||||
Debugger::renderLoader();
|
||||
$tracy_script_html = ob_get_clean();
|
||||
|
||||
// strip 'async' to ensure all AJAX request are caught
|
||||
// (even when fired immediately after page starts loading)
|
||||
echo str_replace('async', '', $tracy_script_html);
|
||||
};
|
||||
add_action('admin_enqueue_scripts', 'render_tracy', PHP_INT_MAX, 0);
|
||||
session_start();
|
||||
// strip 'async' to ensure all AJAX request are caught
|
||||
// (even when fired immediately after page starts loading)
|
||||
return str_replace('async', '', $tracy_script_html);
|
||||
}
|
||||
add_action('admin_enqueue_scripts', 'render_tracy', PHP_INT_MAX, 0);
|
||||
session_start();
|
||||
}
|
||||
Debugger::enable(Debugger::DEVELOPMENT);
|
||||
}
|
||||
|
||||
|
@@ -42,6 +42,8 @@ services:
|
||||
WORDPRESS_DB_USER: wordpress
|
||||
WORDPRESS_DB_NAME: wordpress
|
||||
WORDPRESS_TABLE_PREFIX: mp_
|
||||
MAILPOET_DISABLE_TRACY_BAR: 1
|
||||
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost"]
|
||||
interval: 1m30s
|
||||
|
Reference in New Issue
Block a user