Closed BWBama85 closed 3 years ago
The database is updated automatically. I only know of one way to replicate this issue, which is done when manually making changes to Cache Enabler's database option while the version number matches the current version so it's not updated automatically.
I'm unsure what steps were taken to produce this issue for you, but to fix this you can either reinstall Cache Enabler, visit any page in your website, or make a change in the Cache Enabler settings and then save the settings.
This is the code that triggers it.
<?php
define("WP_USE_THEMES", false);
require_once('/home/nginx/domains/bamapolitics.com/public/wp-blog-header.php');
$tsf = function_exists( 'the_seo_framework' ) ? the_seo_framework() : null;
$args = array(
'posts_per_page' => -1,
'post_type' => 'page',
'meta_query' => array(
array(
'key' => 'election_date',
'value' => '',
'compare' => '!='
)
),
);
$election_query = new WP_Query( $args );
if( $election_query->have_posts() ) {
// echo '<table>';
while( $election_query->have_posts() ) {
$election_query->the_post();
$meta_desc = $post->post_title . ' results and candidate information for Alabama voters.';
if ( $post->_genesis_description != $meta_desc OR empty($post->_genesis_description) ) {
$post_data = array(
'ID' => $post->ID,
'meta_input' => array(
'_genesis_description' => $meta_desc
)
);
wp_update_post($post_data);
}
if ( $post->election_date == '2022' OR $post->election_date == '2021' ) {
$title_meta = $post->post_title;
if ( $post->_genesis_title != $title_meta OR empty($post->_genesis_title) ) {
$post_data = array(
'ID' => $post->ID,
'meta_input' => array(
'_genesis_title' => $title_meta
)
);
wp_update_post($post_data);
}
} else {
$title_meta = $post->post_title . ' Results';
if ( $post->_genesis_title != $title_meta OR empty($post->_genesis_title) ) {
$post_data = array(
'ID' => $post->ID,
'meta_input' => array(
'_genesis_title' => $title_meta
)
);
wp_update_post($post_data);
}
}
}
}
and is run through a cronjob and also appears when ran manually via the command line.
To confirm, this occurs after reinstalling Cache Enabler? By reinstall I mean deactivating, deleting, and then installing Cache Enabler again. (Please note that this will remove any settings you have configured, so if you have any regular expressions you will want to save these somewhere else temporarily.)
Hi, that appears to have solved the issue.
This is happening again anytime I use wp_update_post. Has this been tested with PHP 8?
This fixes the issue for me:
if ( isset( Cache_Enabler_Engine::$settings['clear_site_cache_on_saved_post'] ) ) {
I haven't encountered any issues while using PHP 8 but haven't done any extensive testing yet.
Hmm, it's possible the engine isn't being started. Before troubleshooting if that is the case, would it be possible for you to provide the option_value
for the cache_enabler
option? This can be obtained in your database. This would be located in your {prefix}_options
table (e.g. wp_options
).
PHP Warning: Trying to access array offset on value of type null in /home/nginx/domains/bamapolitics.com/public/wp-content/plugins/cache-enabler/inc/cache_enabler.class.php on line 1431