Quote:
I think there is a conflict between your X-Cart and one of the plugins installed in your WordPress.
Try to deactivate all the WordPress plugins, then activate the "Integration with X-Cart" plugin and then activate the other plugins one-by-one to see which plugin is causing the problem.
|
I had already done this, but no result.
I tried to trace the code with a debugger in my local dev. server and I found out that in
/wp-includes/ms-settings.php WP script file, close to line 57, the code searches for the current blog, by querying the WP database, via the input path in the browser. This is stored in the
$current_blog variable, via the snippet:
PHP Code:
if ( 0 === strcasecmp( $current_site->domain, $domain ) && 0 === strcasecmp( $current_site->path, $path ) ) {
$current_blog = get_site_by_path( $domain, $path );
} elseif ( '/' !== $current_site->path && 0 === strcasecmp( $current_site->domain, $domain ) && 0 === stripos( $path, $current_site->path ) ) {
// If the current network has a path and also matches the domain and path of the request,
// we need to look for a site using the first path segment following the network's path.
$current_blog = get_site_by_path( $domain, $path, 1 + count( explode( '/', trim( $current_site->path, '/' ) ) ) );
} else {
// Otherwise, use the first path segment (as usual).
$current_blog = get_site_by_path( $domain, $path, 1 ); // REPLACED LINE
}
The
$current_blog variable was set to false, thus, leading to further empty object regarding the found current WP site and exiting the procedure, displaying the "Error establishing a database connection" message.
From what I noticed, the
$path variable was set to the x-cart root dir relative path (eg, if xcart is installed in /xcart root dir and the WP blog in /xcart/blog/ dir, then the $path variable was set to '/xcart/', leaving out the blog path part, thus not finding the blog.
On the other hand, the
$current_site->path value contains the path to the blog (/xcart/blog/), so I replaced the above line (comment: 'REPLACED LINE') with the one below:
PHP Code:
$current_blog = get_site_by_path($domain, $current_site->path);
After this, when I enable the 'WordPress in XCart' module,
I don't get this database error, and the xcart site displays as normally expected, but when I go to the blog url,
the blog doesn't display integrated inside the xcart site template, as expected, but it displays separately, on it's own. (Obviously, I have enabled the 'integration with xcart' module and also I have input the right path in the 'Path to WordPress directory (relative to X-Cart directory, 'blog' is used by default)' setting, in the 'WordPress in XCart' configuration page. Also, the xcart store is a clean 4.6.4 installation, out of the box, so no modified code exists).
I understand that the code tweak I have done above is not a clean solution, it just 'patches' the situation, but at least, I don't get any php fatal errors in the logs. Also, there is no way that the WP developers have left such a bug here, so I probably tweaked the code in an atypical way.
So, I was wondering if something else is wrong in the wp configuration paths, for example, or in the .htaccess files.