sqlite-object-cache icon indicating copy to clipboard operation
sqlite-object-cache copied to clipboard

Initalization issues triggered by config changes cause Fatal Error

Open stewarty opened this issue 6 months ago • 1 comments

Hi there, great plugin!

Complete edge case and likely fixable by anyone using the plugin but worth reporting should anything related pop-up.

When I added the const WP_SQLITE_OBJECT_CACHE_DB_FILE to an already installed and active instance of the plugin I get a Fatal Error.

Fatal error: Uncaught Error: Call to undefined function __() in /var/www/html/public/wordpress/wp-admin/includes/file.php:16 

Stack trace: 
#0 /var/www/html/public/content/object-cache.php(2594): require_once() 
#1 /var/www/html/public/content/object-cache.php(685): WP_Object_Cache->delete_offending_files() 
#2 /var/www/html/public/content/object-cache.php(538): WP_Object_Cache->open_connection() 
#3 /var/www/html/public/content/object-cache.php(2685): WP_Object_Cache->__construct() 
#4 /var/www/html/public/wordpress/wp-includes/load.php(893): wp_cache_init() 
#5 /var/www/html/public/wordpress/wp-settings.php(147): wp_start_object_cache() 
#6 /var/www/html/public/wp-config.php(48): require_once('...') 
#7 /var/www/html/public/wordpress/wp-load.php(55): require_once('...') 
#8 /var/www/html/public/wordpress/wp-admin/admin.php(35): require_once('...') 
#9 /var/www/html/public/wordpress/wp-admin/index.php(10): require_once('...') 
#10 {main} thrown in /var/www/html/public/wordpress/wp-admin/includes/file.php on line 16

It looks like the plugin is trying to remove the old sqlite file and replace it with a new one using wp-admin/includes/file.php. The loaded file.php opens with a series of translateable file definitions using the __ function, but __ isn't yet available as l10n.php isn't loaded till after wp_start_object_cache() in wp-settings.php.

$wp_file_descriptions = array(
	'functions.php'         => __( 'Theme Functions' ),
	'header.php'            => __( 'Theme Header' ),
	'footer.php'            => __( 'Theme Footer' ),
	'sidebar.php'           => __( 'Sidebar' ),
	'comments.php'          => __( 'Comments' ),
... ...

Not a big deal in the end, I can manually remove the old file but it might be worth changing the File System manipulation needed incase it catches someone else.

stewarty avatar Jul 10 '25 11:07 stewarty

I'll try to fix this l11n bug. The documentation (https://wordpress.org/plugins/sqlite-object-cache/#installation) does state that the wp-config.php parameters should only be changed when the plugin is deactivated.

OllieJones avatar Jul 14 '25 20:07 OllieJones