Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined index: in plugins/wp-e-commerce/wpsc-includes/cart.class.php on line 432 #1683

Closed
JustinSainton opened this Issue Dec 3, 2014 · 10 comments

Comments

Projects
None yet
3 participants
@JustinSainton
Copy link
Member

commented Dec 3, 2014

Have had a couple reports of this, but not yet able to replicate. I'm sure it's from this commit, but I'm hesitant to revert without a clear path to reproduce.

@JustinSainton JustinSainton self-assigned this Dec 3, 2014

@JustinSainton JustinSainton added this to the 3.9.1 milestone Dec 3, 2014

@leewillis77

This comment has been minimized.

Copy link
Member

commented Dec 3, 2014

I can reproduce this if a shipping method is enabled, and then the plugin providing that rate is disabled without the method being de-selected first. xdebug trace below.

Notice: Undefined index: ses_wpsc_premium_shipping in /var/www/wpec38/wp-content/plugins/wp-e-commerce/wpsc-includes/cart.class.php on line 432
Call Stack

Time Memory Function Location

1 0.0004 132772 {main}( ) ../plugins.php:0
2 0.0007 133464 require_once( '/var/www/wpec38/wp-admin/admin.php' ) ../plugins.php:10
3 0.0010 133876 require_once( '/var/www/wpec38/wp-load.php' ) ../admin.php:31
4 0.0012 134388 require_once( '/var/www/wpec38/wp-config.php' ) ../wp-load.php:29
5 0.0013 135604 require_once( '/var/www/wpec38/wp-settings.php' ) ../wp-config.php:90
6 0.3282 2670916 do_action( $tag = 'init', $arg = ??? ) ../wp-settings.php:353
7 0.4804 2846916 call_user_func_array:{/var/www/wpec38/wp-includes/plugin.php:505} ( 'wpsc_allow_free_cart_checkout', array (0 => '') ) ../plugin.php:505
8 0.4804 2846960 wpsc_allow_free_cart_checkout( '' ) ../plugin.php:505
9 0.4804 2846984 wpsc_is_free_cart( ) ../cart-template-api.php:612
10 0.4805 2847120 wpsc_cart_total( $format_for_display = FALSE ) ../cart-template-api.php:597
11 0.4805 2847236 wpsc_cart->calculate_total_price( ) ../cart-template-api.php:159
12 0.4806 2847356 wpsc_cart->calculate_total_shipping( ) ../cart.class.php:807
13 0.4833 2847592 wpsc_cart->calculate_base_shipping( ) ../cart.class.php:998
14 0.4837 2847780 wpsc_cart->get_shipping_option( ) ../cart.class.php:1035

@leewillis77

This comment has been minimized.

Copy link
Member

commented Dec 3, 2014

Actually, scrap that, that doesn't seem to be the issue. I re-activated the plugin providing that method, and ensured it was de-selected in WP e-Commerce settings, then deactivated the plugin again and I still get this warning. Will try and debug further later on today.

@leewillis77

This comment has been minimized.

Copy link
Member

commented Dec 3, 2014

I agree that that commit is the cause, we're trying to access $wpsc_shipping_modules[$this->selected_shipping_method] when that's undefined (So I guess that the user's session has a selected option that is no longer avalable).

Looking at that function, I think there's a bunch of cleaning up we can do that's "better" than just reverting that commit though. Will raise a PR tonight

@misulicus

This comment has been minimized.

Copy link
Member

commented Dec 5, 2014

I just setup a brand new WordPress and WP eCommerce from wp.org repo (3.9).
Created 1 product, disabled shipping (it was on).
Added to cart and i got:
Undefined index: in plugins/wp-e-commerce/wpsc-includes/cart.class.php on line 432

Added the fix here:
https://github.com/wp-e-commerce/WP-e-Commerce/pull/1688/files

And now i`m getting this:

Undefined offset: 0 in <b>/home/devsourc/public_html/dev/wp-content/plugins/wp-e-commerce/wpsc-includes/cart.class.php</b> on line <b>1191</b>

@JustinSainton JustinSainton reopened this Dec 5, 2014

@JustinSainton

This comment has been minimized.

Copy link
Member Author

commented Dec 8, 2014

@misulicus Followed your instructions exactly, and was unable to replicate. Can you confirm that this still occurs in master, and which line the notice is referencing now?

@misulicus

This comment has been minimized.

Copy link
Member

commented Dec 9, 2014

setup a new store with 3.9 and master.no more error so far

@JustinSainton

This comment has been minimized.

Copy link
Member Author

commented Dec 9, 2014

Great, thanks for the confirmation.

@misulicus

This comment has been minimized.

Copy link
Member

commented Dec 11, 2014

Ok this is really weird.
On my dev site i just logged in, updated to 3.9.1
Went on frontend, and clicked add to cart.

the ajax request shows these issues with debug ON:

<br /> <b>Notice</b>: Undefined offset: 0 in <b>/home/devsourc/public_html/dev/wp-content/plugins/wp-e-commerce/wpsc-includes/cart.class.php</b> on line <b>1196</b><br /> <br /> <b>Notice</b>: Undefined offset: 0 in <b>/home/devsourc/public_html/dev/wp-content/plugins/wp-e-commerce/wpsc-includes/cart.class.php</b> on line <b>1196</b><br

@misulicus

This comment has been minimized.

Copy link
Member

commented Dec 11, 2014

right above that line i tried to debug:
var_dump($this->shipping_method_count); -> 1

$this->shipping_methods -> array(0) { }

@misulicus

This comment has been minimized.

Copy link
Member

commented Dec 11, 2014

i did a database search for 'shipping'
made this screenshot
https://dl.dropboxusercontent.com/u/16683640/Screenshots/2014-12-11_1104.png

Removed the _wpsc_cart.shipping_method_count field and no more error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.