Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

WordPress in X-Cart issue

 
Reply
   X-Cart forums > X-Cart 4 > Third Party Add-Ons for X-Cart 4
 
Thread Tools
  #1  
Old 09-21-2014, 01:47 PM
  vasilis's Avatar 
vasilis vasilis is offline
 

X-Adept
  
Join Date: Feb 2009
Posts: 758
 

Default 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?
__________________
Vasilis Vrontisis
X-Cart Development, Maintenance & Customization
https://[URL="http://www.craftforweb.com"]craftforweb.com[/url]
vasilis@craftforweb.com
Reply With Quote
  #2  
Old 09-22-2014, 06:53 PM
  soldatov's Avatar 
soldatov soldatov is offline
Moderator
 

X-Cart team
  
Join Date: Apr 2011
Posts: 163
 

Default 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.
Reply With Quote

The following user thanks soldatov for this useful post:
vasilis (09-23-2014)
  #3  
Old 09-23-2014, 12:31 AM
  vasilis's Avatar 
vasilis vasilis is offline
 

X-Adept
  
Join Date: Feb 2009
Posts: 758
 

Default 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.
__________________
Vasilis Vrontisis
X-Cart Development, Maintenance & Customization
https://[URL="http://www.craftforweb.com"]craftforweb.com[/url]
vasilis@craftforweb.com
Reply With Quote
  #4  
Old 09-23-2014, 05:05 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default 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.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #5  
Old 09-23-2014, 05:51 AM
  vasilis's Avatar 
vasilis vasilis is offline
 

X-Adept
  
Join Date: Feb 2009
Posts: 758
 

Default 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.
__________________
Vasilis Vrontisis
X-Cart Development, Maintenance & Customization
https://[URL="http://www.craftforweb.com"]craftforweb.com[/url]
vasilis@craftforweb.com
Reply With Quote

The following user thanks vasilis for this useful post:
totaltec (09-23-2014)
  #6  
Old 09-23-2014, 06:09 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default 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
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #7  
Old 09-23-2014, 04:49 PM
  vasilis's Avatar 
vasilis vasilis is offline
 

X-Adept
  
Join Date: Feb 2009
Posts: 758
 

Default 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.
__________________
Vasilis Vrontisis
X-Cart Development, Maintenance & Customization
https://[URL="http://www.craftforweb.com"]craftforweb.com[/url]
vasilis@craftforweb.com
Reply With Quote

The following user thanks vasilis for this useful post:
totaltec (09-23-2014)
Reply
   X-Cart forums > X-Cart 4 > Third Party Add-Ons for X-Cart 4



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:59 PM.

   

 
X-Cart forums © 2001-2020