• Resolved enomoto celtislab

    (@enomoto-celtislab)


    When variation groups are not used.

    $variations_groups = filter_input( INPUT_POST, ‘asp-variations-group-names’, FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY );

    The value obtained in $variations_groups is an empty array as shown below.

    array(1) (
    [0] = (string)
    )

    This has been determined to have a variation group.

    Then I get a PHP error.

    Fatal error: Uncaught Error: array_values(): Argument #1 ($array) must be of type array, null given
    in C:\xampp82\htdocs\wordpress\wp-content\plugins\stripe-payments\admin\includes\class-asp-admin-product-meta-boxes.php on line 1057

    Call stack:

    1. array_values()
      wp-content/plugins/stripe-payments/admin/includes/class-asp-admin-product-meta-boxes.php:1057
    2. ASP_Admin_Product_Meta_Boxes::save_product_handler()
      wp-includes/class-wp-hook.php:324
    3. WP_Hook::apply_filters()
      wp-includes/class-wp-hook.php:348
    4. WP_Hook::do_action()
      wp-includes/plugin.php:517
    5. do_action()
      wp-includes/post.php:4749
    6. wp_insert_post()
      wp-includes/post.php:4862
    7. wp_update_post()
      wp-admin/includes/post.php:453
    8. edit_post()
      wp-admin/post.php:227

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support mbrsolution

    (@mbrsolution)

    Thank you for reaching out to us. Let me see if I understand your issue. You are saying that when you create a new product and you don’t enable?Use variations only to construct final product price you see the error you mention above. Is this correct?

    Kind regards.

    Thread Starter enomoto celtislab

    (@enomoto-celtislab)

    yes
    I don’t use variations when saving products. However, PHP program processing determines that it is being used.
    This will do the wrong thing and cause a PHP error

    Plugin Support mbrsolution

    (@mbrsolution)

    Thank you for sharing more information. I have submitted a message to the developers to investigate further your findings.

    Kind regards.

    Plugin Author mra13

    (@mra13)

    Thank you. I will check this out.

    Plugin Author mra13

    (@mra13)

    We have released an update that should solve this.

    Thread Starter enomoto celtislab

    (@enomoto-celtislab)

    Not resolved.

    Normally, there seems to be no problem, but the problem may occur after some processing (I don’t know what I did)

    stripe-payments\admin\includes\class-asp-admin-product-meta-boxes.php?on line?1058-

    $variations_groups = filter_input( INPUT_POST, 'asp-variations-group-names', FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY );
    // if ( ! empty( $variations_groups ) && is_array( $variations_groups ) ) {
    if ( ! empty( $variations_groups ) && is_array( $variations_groups ) && ! empty( $variations_groups[0] ) ) {

    I think you normally expect $variations_groups to be null when you’re not using variations, but sometimes with array types the first array element is an empty string.

    If you add one judgment condition: ! empty( $variations_groups[0] ), no errors will occur even in irregular cases like this

    Plugin Author mra13

    (@mra13)

    Thank you. We will try to add something for this condition in the next release again.

    Plugin Support mbrsolution

    (@mbrsolution)

    We have released a new version with a patch for your issue. Can you check to see if this version fixes your issue.

    Thank you.

    Thread Starter enomoto celtislab

    (@enomoto-celtislab)

    The error can no longer be reproduce.

    My guess is that when the error occurred, asp_variations_names was undefined, so filter_input () became null.
    After that, when I corrected the code and executed it to check the operation, update_post_meta( $post_id, ‘asp_variations_names’, false ); was executed, the undefined was resolved, and the error no longer occurred.

    However, if you click the Create Group button in variations and update the Edit Product without creating a variation, an empty variation will be created.

    When you Pay Now for this item, an empty dropdown select for variation selection will appear at the top of the purchase dialog.

    Is this the expected behavior?

    After all, wouldn’t it be better to add one more judgment condition ? empty( $variations_groups[0] ),

    For now, I think the error no longer occurs during normal use, so I’ll mark it as resolved.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘PHP error – handle variations’ is closed to new replies.