Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

ArgumentCountError and Undefined Index

$
0
0

Replies: 0

Hi,

this is just to make you aware of the following error I received when using your plugin together with Polylang and a custom product field like _my_custom_field. The export failed with this error message:


[02-Oct-2018 06:15:06 UTC] PHP ArgumentCountError:  Too few arguments to function PLLWC_Strings::attribute_label(), 2 passed in /var/www/mysite/www.mysite.org/htdocs/wp-includes/class-wp-hook.php on line 286 and exactly 3 expected in /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/polylang-wc/include/strings.php on line 406
[02-Oct-2018 06:15:06 UTC] PHP Stack trace:
[02-Oct-2018 06:15:06 UTC] PHP   1. {main}() /var/www/mysite/www.mysite.org/htdocs/wp-admin/admin-ajax.php:0
[02-Oct-2018 06:15:06 UTC] PHP   2. do_action() /var/www/mysite/www.mysite.org/htdocs/wp-admin/admin-ajax.php:100
[02-Oct-2018 06:15:06 UTC] PHP   3. WP_Hook->do_action() /var/www/mysite/www.mysite.org/htdocs/wp-includes/plugin.php:453
[02-Oct-2018 06:15:06 UTC] PHP   4. WP_Hook->apply_filters() /var/www/mysite/www.mysite.org/htdocs/wp-includes/class-wp-hook.php:310
[02-Oct-2018 06:15:06 UTC] PHP   5. WC_Order_Export_Admin->ajax_gate() /var/www/mysite/www.mysite.org/htdocs/wp-includes/class-wp-hook.php:286
[02-Oct-2018 06:15:06 UTC] PHP   6. WC_Order_Export_Ajax->export_part() /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/class-wc-order-export-admin.php:755
[02-Oct-2018 06:15:06 UTC] PHP   7. WC_Order_Export_Engine::build_file() /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/admin/class-wc-order-export-ajax.php:299
[02-Oct-2018 06:15:06 UTC] PHP   8. WC_Order_Export_Data_Extractor::fetch_order_data() /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/core/class-wc-order-export-engine.php:510
[02-Oct-2018 06:15:06 UTC] PHP   9. WC_Order_Export_Data_Extractor::fetch_order_products() /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/core/class-wc-order-export-data-extractor.php:1609
[02-Oct-2018 06:15:06 UTC] PHP  10. WC_Order_Export_Data_Extractor::get_product_variation() /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/core/class-wc-order-export-data-extractor.php:1341
[02-Oct-2018 06:15:06 UTC] PHP  11. apply_filters() /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/core/class-wc-order-export-data-extractor.php:2058
[02-Oct-2018 06:15:06 UTC] PHP  12. WP_Hook->apply_filters() /var/www/mysite/www.mysite.org/htdocs/wp-includes/plugin.php:203
[02-Oct-2018 06:15:06 UTC] PHP  13. PLLWC_Strings->attribute_label() /var/www/mysite/www.mysite.org/htdocs/wp-includes/class-wp-hook.php:286
[02-Oct-2018 06:15:06 UTC] PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function PLLWC_Strings::attribute_label(), 2 passed in /var/www/mysite/www.mysite.org/htdocs/wp-includes/class-wp-hook.php on line 286 and exactly 3 expected in /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/polylang-wc/include/strings.php:406
Stack trace:
#0 /var/www/mysite/www.mysite.org/htdocs/wp-includes/class-wp-hook.php(286): PLLWC_Strings->attribute_label('_my_custom_field', '_my_custom_field')
#1 /var/www/mysite/www.mysite.org/htdocs/wp-includes/plugin.php(203): WP_Hook->apply_filters('_my_custom_field', Array)
#2 /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/core/class-wc-order-export-data-extractor.php(2058): apply_filters('woocommerce_att...', '_my_custom_field', '_my_custom_field')
#3 /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order- in /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/polylang-wc/include/strings.php on line 406

The error triggers in Polylang for WooCommerce but I think it rather originates in the woo-order-export-lite plugin. The culpit are these lines 2048ff in class-wc-order-export-data-extractor.php:


			//known attribute?
			if ( taxonomy_exists( wc_sanitize_taxonomy_name( $meta['meta_key'] ) ) ) {
				$term               = get_term_by( 'slug', $meta['meta_value'],
					wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
				$meta['meta_key']   = wc_attribute_label( wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
				$meta['meta_value'] = isset( $term->name ) ? $term->name : $meta['meta_value'];
			} else {
				$meta['meta_key'] = apply_filters( 'woocommerce_attribute_label',
					wc_attribute_label( $meta['meta_key'], $product ), $meta['meta_key'] );
			}

I I uncomment everything in the else clause, then it works:


			//known attribute?
			if ( taxonomy_exists( wc_sanitize_taxonomy_name( $meta['meta_key'] ) ) ) {
				$term               = get_term_by( 'slug', $meta['meta_value'],
					wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
				$meta['meta_key']   = wc_attribute_label( wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
				$meta['meta_value'] = isset( $term->name ) ? $term->name : $meta['meta_value'];
//			} else {
//				$meta['meta_key'] = apply_filters( 'woocommerce_attribute_label',
//					wc_attribute_label( $meta['meta_key'], $product ), $meta['meta_key'] );
			}

As said this is more of a kind of bug report, hope the feedback maybe helps.

PS On a side note, I also saw this Warning in my error.log:


03-Oct-2018 15:06:01 UTC] PHP Notice:  Undefined index: mode in /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/admin/class-wc-order-export-manage.php on line 110
[03-Oct-2018 15:06:01 UTC] PHP Stack trace:
[03-Oct-2018 15:06:01 UTC] PHP   1. {main}() /var/www/mysite/www.mysite.org/htdocs/wp-admin/admin-ajax.php:0
[03-Oct-2018 15:06:01 UTC] PHP   2. do_action() /var/www/mysite/www.mysite.org/htdocs/wp-admin/admin-ajax.php:100
[03-Oct-2018 15:06:01 UTC] PHP   3. WP_Hook->do_action() /var/www/mysite/www.mysite.org/htdocs/wp-includes/plugin.php:453
[03-Oct-2018 15:06:01 UTC] PHP   4. WP_Hook->apply_filters() /var/www/mysite/www.mysite.org/htdocs/wp-includes/class-wp-hook.php:310
[03-Oct-2018 15:06:01 UTC] PHP   5. WC_Order_Export_Admin->ajax_gate() /var/www/mysite/www.mysite.org/htdocs/wp-includes/class-wp-hook.php:286
[03-Oct-2018 15:06:01 UTC] PHP   6. WC_Order_Export_Ajax->get_used_custom_order_meta() /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/class-wc-order-export-admin.php:755
[03-Oct-2018 15:06:01 UTC] PHP   7. WC_Order_Export_Manage::make_new_settings() /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/admin/class-wc-order-export-ajax.php:74
[03-Oct-2018 15:06:01 UTC] PHP Notice:  Undefined index: id in /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/admin/class-wc-order-export-manage.php on line 110
[03-Oct-2018 15:06:01 UTC] PHP Stack trace:
[03-Oct-2018 15:06:01 UTC] PHP   1. {main}() /var/www/mysite/www.mysite.org/htdocs/wp-admin/admin-ajax.php:0
[03-Oct-2018 15:06:01 UTC] PHP   2. do_action() /var/www/mysite/www.mysite.org/htdocs/wp-admin/admin-ajax.php:100
[03-Oct-2018 15:06:01 UTC] PHP   3. WP_Hook->do_action() /var/www/mysite/www.mysite.org/htdocs/wp-includes/plugin.php:453
[03-Oct-2018 15:06:01 UTC] PHP   4. WP_Hook->apply_filters() /var/www/mysite/www.mysite.org/htdocs/wp-includes/class-wp-hook.php:310
[03-Oct-2018 15:06:01 UTC] PHP   5. WC_Order_Export_Admin->ajax_gate() /var/www/mysite/www.mysite.org/htdocs/wp-includes/class-wp-hook.php:286
[03-Oct-2018 15:06:01 UTC] PHP   6. WC_Order_Export_Ajax->get_used_custom_order_meta() /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/class-wc-order-export-admin.php:755
[03-Oct-2018 15:06:01 UTC] PHP   7. WC_Order_Export_Manage::make_new_settings() /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/admin/class-wc-order-export-ajax.php:74
[03-Oct-2018 15:06:01 UTC] PHP Notice:  Undefined index: id in /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/admin/class-wc-order-export-manage.php on line 111
[03-Oct-2018 15:06:01 UTC] PHP Stack trace:
[03-Oct-2018 15:06:01 UTC] PHP   1. {main}() /var/www/mysite/www.mysite.org/htdocs/wp-admin/admin-ajax.php:0
[03-Oct-2018 15:06:01 UTC] PHP   2. do_action() /var/www/mysite/www.mysite.org/htdocs/wp-admin/admin-ajax.php:100
[03-Oct-2018 15:06:01 UTC] PHP   3. WP_Hook->do_action() /var/www/mysite/www.mysite.org/htdocs/wp-includes/plugin.php:453
[03-Oct-2018 15:06:01 UTC] PHP   4. WP_Hook->apply_filters() /var/www/mysite/www.mysite.org/htdocs/wp-includes/class-wp-hook.php:310
[03-Oct-2018 15:06:01 UTC] PHP   5. WC_Order_Export_Admin->ajax_gate() /var/www/mysite/www.mysite.org/htdocs/wp-includes/class-wp-hook.php:286
[03-Oct-2018 15:06:01 UTC] PHP   6. WC_Order_Export_Ajax->get_used_custom_order_meta() /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/class-wc-order-export-admin.php:755
[03-Oct-2018 15:06:01 UTC] PHP   7. WC_Order_Export_Manage::make_new_settings() /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/admin/class-wc-order-export-ajax.php:74
[03-Oct-2018 15:06:01 UTC] PHP Notice:  Undefined index: mode in /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/admin/class-wc-order-export-manage.php on line 155
[03-Oct-2018 15:06:01 UTC] PHP Stack trace:
[03-Oct-2018 15:06:01 UTC] PHP   1. {main}() /var/www/mysite/www.mysite.org/htdocs/wp-admin/admin-ajax.php:0
[03-Oct-2018 15:06:01 UTC] PHP   2. do_action() /var/www/mysite/www.mysite.org/htdocs/wp-admin/admin-ajax.php:100
[03-Oct-2018 15:06:01 UTC] PHP   3. WP_Hook->do_action() /var/www/mysite/www.mysite.org/htdocs/wp-includes/plugin.php:453
[03-Oct-2018 15:06:01 UTC] PHP   4. WP_Hook->apply_filters() /var/www/mysite/www.mysite.org/htdocs/wp-includes/class-wp-hook.php:310
[03-Oct-2018 15:06:01 UTC] PHP   5. WC_Order_Export_Admin->ajax_gate() /var/www/mysite/www.mysite.org/htdocs/wp-includes/class-wp-hook.php:286
[03-Oct-2018 15:06:01 UTC] PHP   6. WC_Order_Export_Ajax->get_used_custom_order_meta() /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/class-wc-order-export-admin.php:755
[03-Oct-2018 15:06:01 UTC] PHP   7. WC_Order_Export_Manage::make_new_settings() /var/www/mysite/www.mysite.org/htdocs/wp-content/plugins/woo-order-export-lite/classes/admin/class-wc-order-export-ajax.php:74

Viewing all articles
Browse latest Browse all 59525

Trending Articles