Joe
Forum Replies Created
-
Forum: Plugins
In reply to: [Preloader Plus - Wordpress Loading Screen Plugin] VulnerabilityThis closure is temporary, pending a full review. But given the last update was over two years ago I’m not massively optimistic.
I’m pleased you’re enjoying the snippet @generosus !
Hi @cryptoli – the total items data shows a counter of the items within your installation. It’s not something you can, or need to, change. It will go up and down depending on what you add or remove from your installation. If it showed 0 then you would have a problem.
Yes, sure, that’s below. This version also checks if a Memcached server is running. If not, it will show a not running message.
// Hook into the WordPress dashboard setup action to add our widget
add_action('wp_dashboard_setup', 'add_memcached_stats_dashboard_widget');
function add_memcached_stats_dashboard_widget() {
wp_add_dashboard_widget('memcached_stats_dashboard_widget', 'Memcached Stats', 'display_memcached_stats_dashboard_widget');
}
function display_memcached_stats_dashboard_widget() {
// Attempt to connect to your Memcached server
$memcached = new Memcached();
$memcached->addServer('127.0.0.1', 11211);
$stats = $memcached->getStats();
$server = '127.0.0.1:11211';
// Check if we got stats back
if (empty($stats) || !isset($stats[$server])) {
echo "Unable to fetch Memcached stats. Please ensure that the Memcached server is running on " . esc_html($server) . ".";
return;
}
// Assuming $stats is not empty, extract the server stats
$stats = $stats[$server];
$version = $memcached->getVersion();
$version = $version[$server];
// Calculate Cache Hit Ratio
$hitRatio = ($stats['get_hits'] / ($stats['get_hits'] + $stats['get_misses'])) * 100;
// Calculate Uptime
$uptime = gmdate("j \D H \H i \M s \S", $stats['uptime']);
// Display the stats
echo "<strong>Memcached Server Running:</strong> " . esc_html($server) . "<br />";
echo "<strong>Memcached Server Version:</strong> " . esc_html($version) . "<br />";
echo "<strong>Cache Hit Ratio:</strong> " . number_format($hitRatio, 2) . "%<br />";
echo "<strong>Uptime:</strong> " . esc_html($uptime) . "<br />";
echo "<strong>Current Unique Items / Total Items:</strong> " . number_format($stats['curr_items']) . " / " . number_format($stats['total_items']) . "<br /><br />";
// Nonce field for security
$nonce = wp_create_nonce('flush_memcached_cache');
// Flush Cache Button
echo '<form method="post" action="">';
echo '<input type="hidden" name="flush_cache_nonce" value="' . $nonce . '" />';
echo '<input type="submit" name="flush_cache" value="Flush Cache" class="button button-primary" />';
echo '</form>';
}
// Handle the form submission to flush the cache
add_action('admin_init', 'handle_flush_memcached_cache');
function handle_flush_memcached_cache() {
if (isset($_POST['flush_cache']) && check_admin_referer('flush_memcached_cache', 'flush_cache_nonce')) {
$memcached = new Memcached();
$memcached->addServer('127.0.0.1', 11211);
$memcached->flush();
add_action('admin_notices', 'flush_memcached_cache_notice');
}
}
function flush_memcached_cache_notice() {
echo '<div class="notice notice-success is-dismissible">';
echo '<p>Memcached cache has been flushed successfully.</p>';
echo '</div>';
}
// Ensure this PHP code is placed in your theme's functions.php file or a custom plugin.Hi @generosus,
A flush cache button has been added to the dashboard widget – enjoy! This snippet is independent of the Object Cache 4 Everyone plugin, it directly references your Memcached server.
Hiding their plugin listing display elements would be something you need to discuss with @fpuenteonline.
Now for the code:// Hook into the WordPress dashboard setup action to add our widget
add_action('wp_dashboard_setup', 'add_memcached_stats_dashboard_widget');
function add_memcached_stats_dashboard_widget() {
wp_add_dashboard_widget('memcached_stats_dashboard_widget', 'Memcached Stats', 'display_memcached_stats_dashboard_widget');
}
function display_memcached_stats_dashboard_widget() {
// Attempt to connect to your Memcached server
$memcached = new Memcached();
$memcached->addServer('127.0.0.1', 11211);
$stats = $memcached->getStats();
$server = '127.0.0.1:11211';
// Check if we got stats back
if (empty($stats)) {
echo "Unable to fetch Memcached stats.";
return;
}
// Assuming $stats is not empty, extract the server stats
$stats = $stats[$server];
// Calculate Cache Hit Ratio
$hitRatio = ($stats['get_hits'] / ($stats['get_hits'] + $stats['get_misses'])) * 100;
// Calculate Uptime
$uptime = gmdate("j \D H \H i \M s \S", $stats['uptime']);
// Display the stats
echo "<strong>Memcached Server running:</strong> " . esc_html($server) . "<br />";
echo "<strong>Cache Hit Ratio:</strong> " . number_format($hitRatio, 2) . "%<br />";
echo "<strong>Uptime:</strong> " . esc_html($uptime) . "<br />";
echo "<strong>Current Unique Items / Total Items:</strong> " . number_format($stats['curr_items']) . " / " . number_format($stats['total_items']) . "<br /><br />";
// Nonce field for security
$nonce = wp_create_nonce('flush_memcached_cache');
// Flush Cache Button
echo '<form method="post" action="">';
echo '<input type="hidden" name="flush_cache_nonce" value="' . $nonce . '" />';
echo '<input type="submit" name="flush_cache" value="Flush Cache" class="button button-primary" />';
echo '</form>';
}
// Handle the form submission to flush the cache
add_action('admin_init', 'handle_flush_memcached_cache');
function handle_flush_memcached_cache() {
if (isset($_POST['flush_cache']) && check_admin_referer('flush_memcached_cache', 'flush_cache_nonce')) {
$memcached = new Memcached();
$memcached->addServer('127.0.0.1', 11211);
$memcached->flush();
add_action('admin_notices', 'flush_memcached_cache_notice');
}
}
function flush_memcached_cache_notice() {
echo '<div class="notice notice-success is-dismissible">';
echo '<p>Memcached cache has been flushed successfully.</p>';
echo '</div>';
}
// Ensure this PHP code is placed in your theme's functions.php file or a custom plugin.Hi @generosus,
I’m pleased you’ve found it helpful! In case they change the plugin behaviour it might just be easiest to use the uBlock Origin Chrome extension to hide that particular element for now.
JoeIt happened today, 11 days after the previous occurrence though.
[29-Apr-2024 04:37:21 UTC] WordPress database error Deadlock found when trying to get lock; try restarting transaction for query INSERT INTO vo_actionscheduler_actions (
hook
,status
,scheduled_date_gmt
,scheduled_date_local
,schedule
,group_id
,priority
,args
) SELECT 'wp_mail_smtp_queue_process', 'pending', '2024-04-29 04:37:21', '2024-04-29 05:37:21', 'O:32:\"ActionScheduler_IntervalSchedule\":5:{s:22:\"\0*\0scheduled_timestamp\";i:1714365441;s:18:\"\0*\0first_timestamp\";i:1714365441;s:13:\"\0*\0recurrence\";i:60;s:49:\"\0ActionScheduler_IntervalSchedule\0start_timestamp\";i:1714365441;s:53:\"\0ActionScheduler_IntervalSchedule\0interval_in_seconds\";i:60;}', 2, 10, '[null]' FROM DUAL WHERE ( SELECT action_id FROM vo_actionscheduler_actions WHERE status IN ( 'pending', 'in-progress' ) AND hook = 'wp_mail_smtp_queue_process' ANDgroup_id
= 2 LIMIT 1 ) IS NULL made by require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), WP_Hook->do_action, WP_Hook->apply_filters, WPMailSMTP\Core->get_tasks, WPMailSMTP\Tasks\Tasks->init, WPMailSMTP\Tasks\Queue\ProcessQueueTask->init, WPMailSMTP\Tasks\Task->register, WPMailSMTP\Tasks\Task->register_recurring, as_schedule_recurring_action, ActionScheduler_ActionFactory->create, ActionScheduler_ActionFactory->store_unique_action, ActionScheduler_DBStore->save_unique_action, ActionScheduler_DBStore->save_action_to_db [29-Apr-2024 04:40:57 UTC] WordPress database error Deadlock found when trying to get lock; try restarting transaction for query INSERT INTO vo_actionscheduler_actions (hook
,status
,scheduled_date_gmt
,scheduled_date_local
,schedule
,group_id
,priority
,args
) SELECT 'wp_mail_smtp_queue_process', 'pending', '2024-04-29 04:40:57', '2024-04-29 05:40:57', 'O:32:\"ActionScheduler_IntervalSchedule\":5:{s:22:\"\0*\0scheduled_timestamp\";i:1714365657;s:18:\"\0*\0first_timestamp\";i:1714365657;s:13:\"\0*\0recurrence\";i:60;s:49:\"\0ActionScheduler_IntervalSchedule\0start_timestamp\";i:1714365657;s:53:\"\0ActionScheduler_IntervalSchedule\0interval_in_seconds\";i:60;}', 2, 10, '[null]' FROM DUAL WHERE ( SELECT action_id FROM vo_actionscheduler_actions WHERE status IN ( 'pending', 'in-progress' ) AND hook = 'wp_mail_smtp_queue_process' ANDgroup_id
= 2 LIMIT 1 ) IS NULL made by require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), WP_Hook->do_action, WP_Hook->apply_filters, WPMailSMTP\Core->get_tasks, WPMailSMTP\Tasks\Tasks->init, WPMailSMTP\Tasks\Queue\ProcessQueueTask->init, WPMailSMTP\Tasks\Task->register, WPMailSMTP\Tasks\Task->register_recurring, as_schedule_recurring_action, ActionScheduler_ActionFactory->create, ActionScheduler_ActionFactory->store_unique_action, ActionScheduler_DBStore->save_unique_action, ActionScheduler_DBStore->save_action_to_db [29-Apr-2024 04:47:26 UTC] WordPress database error Deadlock found when trying to get lock; try restarting transaction for query INSERT INTO vo_actionscheduler_actions (hook
,status
,scheduled_date_gmt
,scheduled_date_local
,schedule
,group_id
,priority
,args
) SELECT 'wp_mail_smtp_queue_process', 'pending', '2024-04-29 04:47:26', '2024-04-29 05:47:26', 'O:32:\"ActionScheduler_IntervalSchedule\":5:{s:22:\"\0*\0scheduled_timestamp\";i:1714366046;s:18:\"\0*\0first_timestamp\";i:1714366046;s:13:\"\0*\0recurrence\";i:60;s:49:\"\0ActionScheduler_IntervalSchedule\0start_timestamp\";i:1714366046;s:53:\"\0ActionScheduler_IntervalSchedule\0interval_in_seconds\";i:60;}', 2, 10, '[null]' FROM DUAL WHERE ( SELECT action_id FROM vo_actionscheduler_actions WHERE status IN ( 'pending', 'in-progress' ) AND hook = 'wp_mail_smtp_queue_process' ANDgroup_id
= 2 LIMIT 1 ) IS NULL made by require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), WP_Hook->do_action, WP_Hook->apply_filters, WPMailSMTP\Core->get_tasks, WPMailSMTP\Tasks\Tasks->init, WPMailSMTP\Tasks\Queue\ProcessQueueTask->init, WPMailSMTP\Tasks\Task->register, WPMailSMTP\Tasks\Task->register_recurring, as_schedule_recurring_action, ActionScheduler_ActionFactory->create, ActionScheduler_ActionFactory->store_unique_action, ActionScheduler_DBStore->save_unique_action, ActionScheduler_DBStore->save_action_to_db [29-Apr-2024 04:58:14 UTC] WordPress database error Deadlock found when trying to get lock; try restarting transaction for query INSERT INTO vo_actionscheduler_actions (hook
,status
,scheduled_date_gmt
,scheduled_date_local
,schedule
,group_id
,priority
,args
) SELECT 'wp_mail_smtp_queue_process', 'pending', '2024-04-29 04:58:14', '2024-04-29 05:58:14', 'O:32:\"ActionScheduler_IntervalSchedule\":5:{s:22:\"\0*\0scheduled_timestamp\";i:1714366694;s:18:\"\0*\0first_timestamp\";i:1714366694;s:13:\"\0*\0recurrence\";i:60;s:49:\"\0ActionScheduler_IntervalSchedule\0start_timestamp\";i:1714366694;s:53:\"\0ActionScheduler_IntervalSchedule\0interval_in_seconds\";i:60;}', 2, 10, '[null]' FROM DUAL WHERE ( SELECT action_id FROM vo_actionscheduler_actions WHERE status IN ( 'pending', 'in-progress' ) AND hook = 'wp_mail_smtp_queue_process' ANDgroup_id
= 2 LIMIT 1 ) IS NULL made by require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), WP_Hook->do_action, WP_Hook->apply_filters, WPMailSMTP\Core->get_tasks, WPMailSMTP\Tasks\Tasks->init, WPMailSMTP\Tasks\Queue\ProcessQueueTask->init, WPMailSMTP\Tasks\Task->register, WPMailSMTP\Tasks\Task->register_recurring, as_schedule_recurring_action, ActionScheduler_ActionFactory->create, ActionScheduler_ActionFactory->store_unique_action, ActionScheduler_DBStore->save_unique_action, ActionScheduler_DBStore->save_action_to_dbThanks @nasanansi – I’m happy with that, we’ve not seen the issue occur in the past 6 days, so it’s looking good.
Thanks @nasanansi – I saw this suggestion elsewhere yesterday so waiting a couple of days to see if we experience the deadlocks again.
Thanks for looking into this @dpinson. A real mind-boggler.
It’s only the one particular code instance (above) that outputs the ??symbol?incorrectly (only) when Optimize Email Sending is activated, so we’ve changed that section of code and will monitor any other instances, but currently everything else seems fine.Thanks @dpinson – we use Mailgun.
Interestingly, the ??symbol?shows as it should in our WordPress mail log, but only shows correctly in the final output of the received email when Optimize Email Sending?is set to off. It shows as a ? symbol in the Mailgun sent email log.Forum: Plugins
In reply to: [WP Job Manager] Resume Manager- not sending application mails to employeer@thisiswolf did you make any progress with this? We’ve issues with Job Alerts not sending.
Forum: Plugins
In reply to: [WP Job Manager] Job Alerts Auto DisabledThis issue has now been fixed in v3.1.0.
Forum: Plugins
In reply to: [WP Job Manager] Job Alerts Auto DisabledWe added this to the WP Job Manager GitHub and it turns out this is in fact a bug with the current release, a fix is due in the next release: https://github.com/Automattic/WP-Job-Manager/issues/2768#issuecomment-1953994944
Forum: Plugins
In reply to: [WP Job Manager] Job Alerts Auto DisabledThanks – ours is blank to disabled that feature, but thank you for your insight!