Help Needed. Service Unavailable - Uncaught Exception

We are randomly and intermittently getting the following error on our home page using cs-cart 4.5.2SP2.

Any suggestions? I have no idea what Pimple is or what it is used for. Refreshing the page [F5] always gets rid of the error.

I have no idea what Pimple is or what it is used for. Refreshing the page [F5] always gets rid of the error.

https://pimple.symfony.com/

Hello,

This would require server-side investigation. Contact either the CS-Cart helpdesk or feel free to contact us at info@poppedweb.com

Best wishes,

Yes, I see what pimple is, but what does the error mean and how to correct?

Yes, I see what pimple is, but what does the error mean and how to correct?

Like I said, we can't see from here. We need to know which add-ons you have, what core modifications you have done, PHP version, etc.

From the stack trace provided, it is trying to retrieve the current template "view" from the registry but for some reason it is undefined.

As @popedweb states, it must be investigated on your server since 1) it is intermittent (which means sometimes it works and sometimes doesn't) and 2) That is is probably NOT related to the registry at all, but rather to the template engine itself. There is probably a different error ahead of this one in your error_log that will probably point more directly to the actual problem rather than the symptom.

http://forum.cs-cart.com/topic/50936-how-to-moving-cscart-from-server-to-localhost/?view=findpost&p=292592&hl=pimple&fromsearch=1

I saw that the other day and tried it. Still a NOGO.

OK, I think I found the cause. Now how to fix.

I have some modified code in fn.cart.php that says

if (strlen($arrive['3'])>1) {Registry::get('view')->assign('arrive3', $arrive['3']);}

It appears for some reason, sometimes 'view' is not defined and Registry::get('view') is throwing an error.

Why?

and I have

use Tygh\Registry;

Generally a Registry::get('something") will return false if "something" is not set. You can use an ifGet(value, default) but then what would you do if it's not set?

So the reason it's not set is most likely that you are trying to reference the 'view' before the templater is initialized (which is where the 'view' is set). Are you doing this in an addon? Addons init.,php files are usually run AFTER all the standard init() routines are performed. If you're modifying distributed code then you are probably trying to reference it before the templater is initialized.

Suggest you verify at what point in the page loading process you are getting the 'view'.

To help any further, would need more detail on what/how you're doing what you are doing.

Yes, I believe you are correct about the templater getting initialized, but weird how the error is very intermittent.

Its for an addon, but I modified the app/functions/fn.cart.php directly in order to pass some variables. It all works fine (has been for years), but very intermittently we get this view error.

In fn.cart.php (around line 3325), I added:

foreach ($group['shippings'] as $shipping_id => $shipping) {
		//	if ($shipping_id == 40) {continue 1;}
		// DAVID MOD FOR ARRIVE DATE
                //echo $shipping_id.'
'; $arrive = arriveDate($shipping_id); //call function and pass in $shipping_id // Assign smarty variables to PHP array indexes if (strlen($arrive['3'])>1) {Registry::get('view')->assign('arrive3', $arrive['3']);} if (strlen($arrive['11'])>1) {Registry::get('view')->assign('arrive11', $arrive['11']);} if (strlen($arrive['12'])>1) {Registry::get('view')->assign('arrive12', $arrive['12']);} if (strlen($arrive['13'])>1) {Registry::get('view')->assign('arrive13', $arrive['13']);} //GROUND BY ZONES if (strlen($arrive['111'])>1) {Registry::get('view')->assign('zone1', $arrive['111']);} if (strlen($arrive['112'])>1) {Registry::get('view')->assign('zone2', $arrive['112']);} if (strlen($arrive['113'])>1) {Registry::get('view')->assign('zone3', $arrive['113']);} if (strlen($arrive['114'])>1) {Registry::get('view')->assign('zone4', $arrive['114']);} if (strlen($arrive['115'])>1) {Registry::get('view')->assign('zone5', $arrive['115']);} // END DAVID MOD FOR ARRIVE DATE
Do you see any harm (or will it help) if I add
fn_init_stack(array('fn_init_templater'));
before the foreach line of code?
I tried it and so far no error, but the problem is intermittent.

Unfortunately we have seen the error once today. So my fix didn't help.

It does appear to be the Admin who sees it the most when switching to Frontend. Can it be related to the Admin logging in with multiple accounts or acting on behalf of? We are not sure if customers are seeing the intermittent error.

David

Hello,

The only thing I could think of is that you have created / edited an order and then decide to view the admin panel (without a user session --> sid_customer_*) thus causing this bug (because it will try and calculate the cart of the admin perhaps?).

Kind regards,

I can guess till the cows come home.

Best practice would be never modify core files. Always use addons. If you need to modify a core file, do it as a hook and then make a hook request in the developer area (sticky post). Never do anything in an addon's config.php file that expects other areas of the system to be initialized (I.e. init follows config).

I can guess till the cows come home.

Best practice would be never modify core files. Always use addons. If you need to modify a core file, do it as a hook and then make a hook request in the developer area (sticky post). Never do anything in an addon's config.php file that expects other areas of the system to be initialized (I.e. init follows config).

I have also started to see this error, very intermitant only since updating to the latest version of CS-cart

Alan

I'm getting this also using a 3rd party addon we need working, very frustrating as they are saying it's CS Carts fault...

Any more ideas or how anyone above resolved this?

#0 /home/cctvkits/public_html/app/Tygh/Registry.php(105): Pimple\Container->offsetGet('view')
#1 /home/cctvkits/public_html/app/addons/product_package_builder/func.php(366): Tygh\Registry::get('view')
#2 /home/cctvkits/public_html/app/functions/fn.control.php(120): fn_product_package_builder_get_product_data(63, '?:products.*, ?...', ' LEFT JOIN ?:pr...', Array, 'en', ' AND (companies...')
#3 /home/cctvkits/public_html/app/functions/fn.catalog.php(181): fn_set_hook('get_product_dat...', 63, '?:products.*, ?...', ' LEFT JOIN ?:pr...', Array, 'en', ' AND (companies...')
#4 /home/cctvkits/public_html/app/addons/product_package_builder/func.php(686): fn_get_product_data(63, Array, 'en', '?:products.*, ?...', true, true, true, true)
#5 /home/cctvkits/public_html/app/functions/fn.control.php(120): fn_product_package_builder_get_o

Hello

This addon has no producer support? Does this addon have open code or is it encoded?

Best regards

Robert

I'm getting this also using a 3rd party addon we need working, very frustrating as they are saying it's CS Carts fault...

Any more ideas or how anyone above resolved this?

It is hard to say anything without detailed code examination

Hi and thanks - they are looking at it now but it is hard to recreate the issue reliably. It's not encoded. They have setup logging on the dev store apparently. Thought logs were under var/log but don't seem to have such a directory?