Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Error on WordPress Site Health Page with Custom Table Prefix #65

Open
noquierouser opened this issue Sep 11, 2024 · 0 comments
Open

Comments

@noquierouser
Copy link

When using a custom table prefix, a SQL error occurs while accessing the Site Health page in the WordPress admin area. The error appears to be related to querying table information.

Steps to Reproduce

  1. Set up WordPress with a custom table prefix
  2. Activate the WP SQLite DB plugin
  3. Navigate to Tools > Site Health in the WordPress admin
  4. Observe the SQL error

Error Message

WordPress database error:

Queries made or created this session were

- Raw query: SELECT TABLE_NAME AS 'table', TABLE_ROWS AS 'rows', SUM(data_length + index_length) as 'bytes' FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'null-db-name' AND TABLE_NAME IN ('custom_comments','custom_options','custom_posts','custom_terms','custom_users') GROUP BY TABLE_NAME;
- Rewritten: SELECT TABLE_NAME AS 'table', TABLE_ROWS AS 'rows', SUM(data_length + index_length) as 'bytes' FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'null-db-name' AND TABLE_NAME IN ('custom_comments','custom_options','custom_posts','custom_terms','custom_users') GROUP BY TABLE_NAME;
- With Placeholders: SELECT TABLE_NAME AS :param_0 , TABLE_ROWS AS :param_1 , SUM(data_length + index_length) as :param_2 FROM information_schema.TABLES WHERE TABLE_SCHEMA = :param_3 AND TABLE_NAME IN ( :param_4 , :param_5 , :param_6 , :param_7 , :param_8 ) GROUP BY TABLE_NAME;
- Prepare: SELECT TABLE_NAME AS :param_0 , TABLE_ROWS AS :param_1 , SUM(data_length + index_length) as :param_2 FROM information_schema.TABLES WHERE TABLE_SCHEMA = :param_3 AND TABLE_NAME IN ( :param_4 , :param_5 , :param_6 , :param_7 , :param_8 ) GROUP BY TABLE_NAME;

Error occurred at line 1644 in Function prepare_query.
Error message was: Problem preparing the PDO SQL Statement. Error was: SQLSTATE[HY000]: General error: 1 near ":param_0": syntax error 

#0 /home/username/public_html/wp-content/db.php(2746): WP_SQLite_DB\PDOEngine->get_error_message() 
#1 /home/username/public_html/wp-includes/class-wpdb.php(3141): WP_SQLite_DB\wpsqlitedb->query('SELECT TABLE_NA...') 
#2 /home/username/public_html/wp-admin/includes/class-wp-site-health.php(3568): wpdb->get_results('SELECT TABLE_NA...', 'OBJECT_K') 
#3 /home/username/public_html/wp-admin/includes/class-wp-site-health.php(2538): WP_Site_Health->should_suggest_persistent_object_cache() 
#4 /home/username/public_html/wp-admin/includes/class-wp-site-health.php(194): WP_Site_Health->get_test_persistent_object_cache() 
#5 /home/username/public_html/wp-admin/includes/class-wp-site-health.php(139): WP_Site_Health->perform_test(Array) 
#6 /home/username/public_html/wp-includes/class-wp-hook.php(324): WP_Site_Health->enqueue_scripts('site-health.php') 
#7 /home/username/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) 
#8 /home/username/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) 
#9 /home/username/public_html/wp-admin/admin-header.php(118): do_action('admin_enqueue_s...', 'site-health.php') 
#10 /home/username/public_html/wp-admin/site-health.php(96): require_once('/home/username/p...') 

SELECT TABLE_NAME AS 'table', TABLE_ROWS AS 'rows', SUM(data_length + index_length) as 'bytes' FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'null-db-name' AND TABLE_NAME IN ('custom_comments','custom_options','custom_posts','custom_terms','custom_users') GROUP BY TABLE_NAME;

Additional Information

  • WordPress Version: 6.6.2
  • Plugin Version: 1.3.2
  • PHP Version: 8.3.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant