Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion db.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@
/** @psalm-suppress UnresolvableInclude */
require_once ABSPATH . WPINC . '/wp-db.php';
}
// Check if we are in post-new.php page bypass hyperdb
$is_post_new = false;
if (defined('WP_ADMIN') && WP_ADMIN === true) {
// Get the current script name from PHP_SELF
$script_name = isset($_SERVER['PHP_SELF']) ? basename($_SERVER['PHP_SELF']) : '';
$is_post_new = ($script_name === 'post-new.php');
}

// If we're in post-new.php, bypass HyperDB and use standard database connection
if ($is_post_new) {
$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
return;
}



// phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
if ( defined( 'DB_CONFIG_FILE' ) && file_exists( DB_CONFIG_FILE ) ) {
Expand Down Expand Up @@ -1682,4 +1697,4 @@ public function ex_mysql_connect_timeout( $timeout = null ) {
$wpdb = new hyperdb();

/** @psalm-suppress UnresolvableInclude */
require DB_CONFIG_FILE;
require DB_CONFIG_FILE;