dgrundel / woo-product-importer

A simple, free CSV importer for WooCommerce
200 stars 99 forks source link

Notice: Undefined offset: 1 On fresh install #46

Open MichaelKubovic opened 11 years ago

MichaelKubovic commented 11 years ago

I've installed your plugin with latest Woocommerce.

On the first screen I get 'Notice: Undefined offset: 1 in /Users/michael/Sites/madweb/madad.sk/wp/wp-content/plugins/woo-product-importer-master/woo-product-importer-upload.php on line 448' at least hundred times in a loop.

Last five notices differ

Undefined offset: 1 in /Users/michael/Sites/madweb/madad.sk/wp/wp-content/plugins/woo-product-importer-master/woo-product-importer-upload.php on line 438 Notice: Undefined index: c in /Users/michael/Sites/madweb/madad.sk/wp/wp-content/plugins/woo-product-importer-master/woo-product-importer-upload.php on line 442 Notice: Undefined index: in /Users/michael/Sites/madweb/madad.sk/wp/wp-content/plugins/woo-product-importer-master/woo-product-importer-upload.php on line 443 Notice: Undefined offset: 1 in /Users/michael/Sites/madweb/madad.sk/wp/wp-content/plugins/woo-product-importer-master/woo-product-importer-upload.php on line 438 Notice: Undefined index: posix in /Users/michael/Sites/madweb/madad.sk/wp/wp-content/plugins/woo-product-importer-master/woo-product-importer-upload.php on line 442 Notice: Undefined index: in /Users/michael/Sites/madweb/madad.sk/wp/wp-content/plugins/woo-product-importer-master/woo-product-importer-upload.php on line 443

MichaelKubovic commented 11 years ago

I have just found out that my locales when parsed by \n are in following format:

array(204) { [0]=> string(5) "af_ZA" [1]=> string(15) "af_ZA.ISO8859-1" [2]=> string(16) "af_ZA.ISO8859-15" [3]=> string(11) "af_ZA.UTF-8" [4]=> string(5) "am_ET" [5]=> string(11) "am_ET.UTF-8" [6]...

Your code expects every item of array to contain a dot.

Simple fix would be to add following code at line 436 in woo-product-importer-upload.php: if(count($parts) <> 2) continue; or better replace condition at line 434 width if(strstr($loc, '.')) {