I migrated to another server. I actually have two almost identical copies of my site on the new server one under a test domain. One works fine the other is throwing:
Warning: file_put_contents(/var/www/vhosts/domain.com/httpdocs/var/cache/top_menu.GET_0.0_1_35_ ALL PRODUCTS STOCK CAR QUARTER MIDGET SPRINT CAR</ in /var/www/vhosts/domain.com/httpdocs/core/fn.fs.php on line 813
Notice no indication in the error WHY the warning.
I verfied cache dir has 777 permission. Same as the site that is working! There are other cache files being written there though!
Please try clearing the template cache. To do it, open in your web browser http://www.your_domain.com/admin.php?cc, where www.your_domain.com is the address of your store, and admin.php is a script file for the administration panel of your store which was renamed for security reasons.
Also please check the “top_menu.tpl” file located in the “skins/[CUSTOMER_ACTIVE_SKIN]/customer” directory of your CS-Cart and make sure that there is no any problem with a third-party code in it (if any exists).
Wish it were that simple. I already delete all the files in the cache. The top_menu.tpl file only has HTML in it. It is the exact same top_menu.tpl file on the server where we don’t get the error.
Too bad the error message doesn’t say what the specific problem is.
The problem requires the investigation on your server. Please contact our support team via Customer Help Desk.
file_put_contents errors are nearly always related to permission problems but in this case it is indicating possible file corruption or a bad modification somewhere.
The error posted above is showing that cs-cart is attempting to create a file name that includes coding in the name itself instead of processing that code and including it within the cached file that should be created.
[quote]/var/www/vhosts/domain.com/httpdocs/var/cache/[COLOR=DarkRed]top_menu.GET_0.0_1_35_
Figured out the problem. The old server had display_errors turned off on PHP and the new server had it on by default so we just didn’t know the error was happening and since it was with caching we never noticed any problem.
The source of the problem is that we have customized our site to actually hide categories that don’t have any products visible to the usergroup of the currently logged in user. We store the visible category list in a session variable:
$_SESSION[‘auth’][‘usergroup_ids’][‘category_list’]=$categories_links;
Apparently the caching system thinks this session variable contains parameters associated with that page, so all the category list is being appended to the $filename variable in the file_put_contents function.
We’re doing some really complex stuff with user groups, using them essentially as a 3rd dimension for browsing products and this is the only way we could implement it to work the way we wanted.
We determined on our new faster server, turning caching off is actually faster than leaving the file caching on so the problem becomes a moot point.
The question becomes, is there any other side effects except the caching system of passing lots of data in the auth Session variable?
$_SESSION[‘auth’][‘usergroup_ids’] array is used by the system and should NOT be used by you to capture your categories list. Why are you storing this in the ‘auth’ element? Also, using SESSION means that if things change on your server and the user comes back in 10 days that they could get an old list instead of the current list.
Why not utilize the hook for fn_my_changes_get_categories() that will filter out categories with product_count == 0 and be done with it? Then you don’t need to store any state, all you have to do is add a condition to the category listing.