X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Third Party Add-Ons for X-Cart 4 (https://forum.x-cart.com/forumdisplay.php?f=45)
-   -   WordPress in X-Cart issue (https://forum.x-cart.com/showthread.php?t=70038)

vasilis 09-21-2014 01:47 PM

WordPress in X-Cart issue
 
I have installed and configured 'WordPress in X-Cart' for a 4.6.4 Gold site. When I enable the module, the x-cart front-end crashes, with an "Error establishing a database connection" message, in a blank page.
The X-Cart back-end works ok and when I disable the module, x-cart front-end works again.
Also, both WordPress front-end and admin work ok when I enter directly in the WordPress site. The WP site is located in the X-Cart root.
In the x-cart logs, the related log message is: "Cannot use object of type W3_Config as array in /home/sandblas/public_html/include/func/func.db.php on line 517"

Any ideas?

soldatov 09-22-2014 06:53 PM

Re: WordPress in X-Cart issue
 
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.

vasilis 09-23-2014 12:31 AM

Re: WordPress in X-Cart issue
 
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 ( === strcasecmp$current_site->domain$domain ) && === strcasecmp$current_site->path$path ) ) {
            
$current_blog get_site_by_path$domain$path );
        } elseif ( 
'/' !== $current_site->path && === strcasecmp$current_site->domain$domain ) && === 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$pathcountexplode'/'trim$current_site->path'/' ) ) ) );
        } else {
            
// Otherwise, use the first path segment (as usual).
            
$current_blog get_site_by_path$domain$path); // 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.

totaltec 09-23-2014 05:05 AM

Re: WordPress in X-Cart issue
 
Quote:

Originally Posted by vasilis
The WP site is located in the X-Cart root.

I don't recommend this configuration. Why not put WP in /blog? Having both applications share a directory... this can only lead to confusion and problems. Not just now, but later when someone else has to try and untangle this setup.

vasilis 09-23-2014 05:51 AM

Re: WordPress in X-Cart issue
 
Mike, you might be right, I will try this if I don't find any solution, but this is supposed to be the default setup, ie, the blog dir being inside the x-cart root directory. For example, the "Path to WordPress directory (relative to X-Cart directory, 'blog' is used by default)" setting in the "WordPress in X-Cart" configuration page refers to a subdirectory of the root. The same is supposed to be implied in the module installation instructions.

totaltec 09-23-2014 06:09 AM

Re: WordPress in X-Cart issue
 
I may have misunderstood, I thought you were saying that Wordpress and X-cart were installed in the same directory. If X-cart is located at /xcart, then WordPress should be located at /xcart/blog. Or X-cart at root / and WP at /blog

vasilis 09-23-2014 04:49 PM

Re: WordPress in X-Cart issue
 
Eventually, I solved the issue by doing two extra things:
- I removed any mod_rewrite rules in the .htaccess file of the WordPress root directory, because they broke the initial redirection
- I tried to remove my code tweak posted in this thread, but then the site displayed the database connection error, so I retrieved it back.
- I deactivated the W3 Total Cache plugin in WordPress, because it kept breaking the site (as skot suggested in this post).

The strange thing is that I needed to keep my code tweak as well.
Anyway, the integration worked fine.


All times are GMT -8. The time now is 06:19 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.