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

Investigate additional is_array checks in SV_WC_Helper::array_to_xml() #227

Open
bekarice opened this issue Jul 25, 2017 · 0 comments
Open
Assignees
Labels
Bug Raises or fixes a bug Question

Comments

@bekarice
Copy link
Contributor

With the latest XML Export version, when iterating over order xml, I'm getting warnings for an invalid foreach argument:

Stack trace
PHP Warning:  Invalid argument supplied for foreach() in /woocommerce-customer-order-xml-export-suite/lib/skyverge/woocommerce/class-sv-wc-helper.php on line 340
PHP Stack trace:
PHP   1. {main}() /wp-admin/admin-ajax.php:0
PHP   2. do_action() /wp-admin/admin-ajax.php:101
PHP   3. WP_Hook->do_action() /wp-includes/plugin.php:453
PHP   4. WP_Hook->apply_filters() /wp-includes/class-wp-hook.php:323
PHP   5. SV_WP_Background_Job_Handler->maybe_handle() /wp-includes/class-wp-hook.php:298
PHP   6. SV_WP_Background_Job_Handler->handle() /woocommerce-customer-order-xml-export-suite/lib/skyverge/woocommerce/utilities/class-sv-wp-background-job-handler.php:131
PHP   7. SV_WP_Background_Job_Handler->process_job() /woocommerce-customer-order-xml-export-suite/lib/skyverge/woocommerce/utilities/class-sv-wp-background-job-handler.php:542
PHP   8. WC_Customer_Order_XML_Export_Suite_Background_Export->process_item() /woocommerce-customer-order-xml-export-suite/lib/skyverge/woocommerce/utilities/class-sv-wp-background-job-handler.php:607
PHP   9. WC_Customer_Order_XML_Export_Suite_Handler->export_item() /woocommerce-customer-order-xml-export-suite/includes/class-wc-customer-order-xml-export-suite-background-export.php:77
PHP  10. WC_Customer_Order_XML_Export_Suite_Generator->get_output() /woocommerce-customer-order-xml-export-suite/includes/class-wc-customer-order-xml-export-suite-handler.php:721
PHP  11. WC_Customer_Order_XML_Export_Suite_Generator->get_orders_xml() /woocommerce-customer-order-xml-export-suite/includes/class-wc-customer-order-xml-export-suite-generator.php:1304
PHP  12. WC_Customer_Order_XML_Export_Suite_Generator->get_xml() /woocommerce-customer-order-xml-export-suite/includes/class-wc-customer-order-xml-export-suite-generator.php:191
PHP  13. SV_WC_Helper::array_to_xml() /woocommerce-customer-order-xml-export-suite/includes/class-wc-customer-order-xml-export-suite-generator.php:1221
PHP  14. SV_WC_Helper::array_to_xml() /woocommerce-customer-order-xml-export-suite/lib/skyverge/woocommerce/class-sv-wc-helper.php:354
PHP  15. SV_WC_Helper::array_to_xml() /woocommerce-customer-order-xml-export-suite/lib/skyverge/woocommerce/class-sv-wc-helper.php:341
PHP  16. SV_WC_Helper::array_to_xml() /woocommerce-customer-order-xml-export-suite/lib/skyverge/woocommerce/class-sv-wc-helper.php:354
PHP  17. SV_WC_Helper::array_to_xml() /woocommerce-customer-order-xml-export-suite/lib/skyverge/woocommerce/class-sv-wc-helper.php:341

It looks like we're walking to the end of the array and trying to then walk a string instead potentially, as the array before conversion looks fine:

Logged order export
Array
(
  [Order] => Array
    (
      [0] => Array
        (
          [OrderId] => 1159
          [OrderNumber] => 1159
          [OrderDate] => 2017-07-25 14:57:23
          [OrderStatus] => processing
          [BillingFirstName] => Walter
          [BillingLastName] => White
          [BillingFullName] => Walter White
          [BillingCompany] => 
          [BillingAddress1] => 308 Negra Arroyo Lane
          [BillingAddress2] => 
          [BillingCity] => Albuquerque
          [BillingState] => NM
          [BillingPostCode] => 87104
          [BillingCountry] => US
          [BillingEmail] => heisenberg@mailinator.com
          [BillingPhone] => 5558675309
          [ShippingFirstName] => Walter
          [ShippingLastName] => White
          [ShippingFullName] => Walter White
          [ShippingCompany] => 
          [ShippingAddress1] => 308 Negra Arroyo Lane
          [ShippingAddress2] => 
          [ShippingCity] => Albuquerque
          [ShippingState] => NM
          [ShippingPostCode] => 87104
          [ShippingCountry] => US
          [ShippingMethodId] => local_pickup_plus
          [ShippingMethod] => Store Pickup
          [PaymentMethodId] => bogus_gateway
          [PaymentMethod] => Bogus (Test)
          [DiscountTotal] => 0
          [ShippingTotal] => 10.8
          [ShippingTaxTotal] => 0.00
          [OrderTotal] => 226.80
          [FeeTotal] => 0
          [TaxTotal] => 0.00
          [CompletedDate] => 
          [CustomerNote] => 
          [CustomerId] => 2
          [OrderLineItems] => Array
            (
              [0] => Array
                (
                  [SKU] => 
                  [Quantity] => 1
                  [Price] => 216.00
                  [Meta] => Length (ft): 12, Width (ft): 3, Total Area (sq. ft.): 36
                  [ItemName] => Tarp
                  [LineTotal] => 216.00
                )
        )

      [OrderNotes] => Array
        (
          [OrderNote] => Array
            (
              [0] => Array
                (
                  [Date] => 2017-07-25 16:17:48
                  [Author] => WooCommerce
                  [Content] => Order exported to XML and successfully downloaded.
                )

              [1] => Array
                (
                  [Date] => 2017-07-25 14:57:25
                  [Author] => WooCommerce
                  [Content] => Order status changed from Pending payment to Processing.
                )

              [2] => Array
                (
                  [Date] => 2017-07-25 14:57:25
                  [Author] => WooCommerce
                  [Content] => Tarp (#478) stock reduced from 118.5 to 82.5.
                )

              [3] => Array
                (
                  [Date] => 2017-07-25 14:57:25
                  [Author] => WooCommerce
                  [Content] => Bogus is always approved 😎
                )

            )

        )

    )

)

)

Potentially a check in this bit to see if $child_element_value is an array before we loop it / recursively call the function?

@bekarice bekarice added Bug Raises or fixes a bug Question labels Jul 25, 2017
@ChaseWiseman ChaseWiseman modified the milestone: v4.7.2 Aug 29, 2017
@ChaseWiseman ChaseWiseman removed this from the v4.7.2 milestone Sep 12, 2017
@ChaseWiseman ChaseWiseman added this to the v5.0.1 & v4.8.3 milestone Dec 2, 2017
@ChaseWiseman ChaseWiseman self-assigned this Dec 5, 2017
@ChaseWiseman ChaseWiseman modified the milestones: v5.0.1 & v4.8.3, v5.2.0 Dec 11, 2017
@ChaseWiseman ChaseWiseman modified the milestones: v5.2.0, v5.2.1 Jul 13, 2018
@ChaseWiseman ChaseWiseman modified the milestones: v5.2.1, v5.3.0 Aug 29, 2018
@ChaseWiseman ChaseWiseman removed this from the v5.3.0 milestone Sep 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Raises or fixes a bug Question
Projects
None yet
Development

No branches or pull requests

2 participants