Server Actions Creating $_GET and $_POST Parameters That Already Exist

Wappler 2.7.1, Windows 10

What Happens

  1. Create a Server Action and define some $_GET or $_POST parameters manually in the Globals area.
  2. Add a Database Insert Action.
  3. Select those parameters you defined in step (1) in the [Insert Options].
  4. When you exit [Insert Options], the parameters in the Globals area have been duplicated.

Preferred Action

The parameters in the Globals area are not duplicated.

Please check if this happens in the latest Wappler version

Am now using 2.8.3 and this is still happening, but it appears now to be preventing a Server Connect from accessing the $_GET parameters of a highly complex Server Action that took 90 minutes to create… so I’m not keen just to start again!

I will paste the PHP code of the server action below… you can be assured I have not edited it, I purely opened it to be able to send you the code.

If there is an edit you can do to this code to fix the issue and send it back to me I’d be really happy!

(Would the fix be just to remove the duplicate parameters from the define section at the start?)

Best wishes,
Antony.

<?php
require('../../../dmxConnectLib/dmxConnect.php');


$app = new \lib\App();

$app->define(<<<'JSON'
{
  "settings": {
    "options": {}
  },
  "meta": {
    "options": {},
    "$_GET": [
      {
        "type": "text",
        "name": "booking_item"
      },
      {
        "type": "number",
        "name": "price"
      },
      {
        "type": "number",
        "name": "question"
      },
      {
        "type": "number",
        "name": "quantity"
      },
      {
        "type": "number",
        "name": "is_for"
      },
      {
        "type": "text",
        "name": "price_amount"
      },
      {
        "type": "number",
        "name": "contact"
      },
      {
        "type": "text",
        "name": "is_per"
      },
      {
        "type": "text",
        "name": "first_name"
      },
      {
        "type": "text",
        "name": "last_name"
      },
      {
        "type": "number",
        "name": "question"
      },
      {
        "type": "number",
        "name": "contact"
      },
      {
        "type": "number",
        "name": "is_for"
      },
      {
        "type": "text",
        "name": "is_per"
      },
      {
        "type": "number",
        "name": "price"
      },
      {
        "type": "number",
        "name": "quantity"
      },
      {
        "type": "text",
        "name": "first_name}} "
      }
    ],
    "$_POST": [
      {
        "type": "text",
        "name": "booking_item"
      },
      {
        "type": "text",
        "name": "price"
      },
      {
        "type": "text",
        "name": "question"
      },
      {
        "type": "number",
        "name": "quantity"
      },
      {
        "type": "text",
        "name": "is_for"
      },
      {
        "type": "number",
        "name": "price_amount"
      },
      {
        "type": "number",
        "name": "contact"
      },
      {
        "type": "text",
        "name": "is_per"
      },
      {
        "type": "number",
        "name": "quantity"
      },
      {
        "type": "text",
        "name": "first_name"
      },
      {
        "type": "text",
        "name": "last_name"
      }
    ],
    "$_SESSION": [
      {
        "type": "text",
        "name": "s_activity_event_id16"
      },
      {
        "type": "text",
        "name": "s_activity_event"
      },
      {
        "type": "text",
        "name": "s_booking"
      },
      {
        "type": "number",
        "name": "s_currency"
      },
      {
        "type": "text",
        "name": "s_subscriber_user"
      },
      {
        "type": "text",
        "name": "s_booking_id16"
      },
      {
        "type": "text",
        "name": "s_currency_code"
      },
      {
        "type": "text",
        "name": "booking_id16"
      },
      {
        "type": "number",
        "name": "activity_event"
      },
      {
        "type": "number",
        "name": "s_currency"
      },
      {
        "type": "text",
        "name": "s_currency_code"
      },
      {
        "type": "number",
        "name": "s_franchisor"
      },
      {
        "type": "number",
        "name": "s_collaborator"
      },
      {
        "type": "number",
        "name": "s_brand"
      },
      {
        "type": "text",
        "name": "is_per"
      },
      {
        "type": "number",
        "name": "s_activity"
      },
      {
        "type": "number",
        "name": "s_business"
      },
      {
        "type": "text",
        "name": "s_activity_type"
      },
      {
        "type": "number",
        "name": "s_is_a_test"
      }
    ]
  },
  "exec": {
    "steps": [
      "Connections/db_write",
      "SecurityProviders/form_subscriber_user",
      {
        "name": "",
        "module": "auth",
        "action": "restrict",
        "options": {
          "provider": "form_subscriber_user"
        }
      },
      {
        "name": "",
        "module": "core",
        "action": "condition",
        "options": {
          "if": "{{$_POST.booking_item == 0}}",
          "then": {
            "steps": [
              {
                "name": "insert_booking_item",
                "module": "dbupdater",
                "action": "insert",
                "options": {
                  "connection": "db_write",
                  "sql": {
                    "type": "insert",
                    "values": [
                      {
                        "table": "booking_items",
                        "column": "subscriber_user",
                        "type": "number",
                        "value": "{{$_SESSION.s_subscriber_user}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "franchisor",
                        "type": "number",
                        "value": "{{$_SESSION.s_franchisor}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "collaborator",
                        "type": "number",
                        "value": "{{$_SESSION.s_collaborator}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "business",
                        "type": "number",
                        "value": "{{$_SESSION.s_business}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "brand",
                        "type": "number",
                        "value": "{{$_SESSION.s_brand}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "booking",
                        "type": "number",
                        "value": "{{$_SESSION.s_booking}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "activity_event",
                        "type": "number",
                        "value": "{{$_SESSION.s_activity_event}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "question",
                        "type": "number",
                        "value": "{{$_GET.question}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "contact",
                        "type": "number",
                        "value": "{{$_GET.contact}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "activity_type",
                        "type": "text",
                        "value": "{{$_SESSION.s_activity_type}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "is_for",
                        "type": "number",
                        "value": "{{$_GET.is_for}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "is_per",
                        "type": "text",
                        "value": "{{$_GET.is_per}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "booking_status",
                        "type": "number",
                        "value": "199"
                      },
                      {
                        "table": "booking_items",
                        "column": "price",
                        "type": "number",
                        "value": "{{$_GET.price}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "currency",
                        "type": "number",
                        "value": "{{$_SESSION.s_currency}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "quantity",
                        "type": "number",
                        "value": "{{$_GET.quantity}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "amount_total",
                        "type": "number",
                        "value": "999"
                      },
                      {
                        "table": "booking_items",
                        "column": "amount_sales_tax",
                        "type": "number",
                        "value": "9.99"
                      },
                      {
                        "table": "booking_items",
                        "column": "description",
                        "type": "text",
                        "value": "{{$_GET.first_name}} . \" attending \" . {{$_SESSION.s_activity_title}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "date_booked",
                        "type": "datetime",
                        "value": "{{NOW_UTC}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "is_a_test",
                        "type": "number",
                        "value": "{{$_SESSION.s_is_a_test}}"
                      },
                      {
                        "table": "booking_items",
                        "column": "activity",
                        "type": "number",
                        "value": "{{$_SESSION.s_activity}}"
                      }
                    ],
                    "table": "booking_items",
                    "query": "INSERT INTO booking_items\n(subscriber_user, franchisor, collaborator, business, brand, booking, activity_event, question, contact, activity_type, is_for, is_per, booking_status, price, currency, quantity, amount_total, amount_sales_tax, description, date_booked, is_a_test, activity) VALUES (:P1 /* {{$_SESSION.s_subscriber_user}} */, :P2 /* {{$_SESSION.s_franchisor}} */, :P3 /* {{$_SESSION.s_collaborator}} */, :P4 /* {{$_SESSION.s_business}} */, :P5 /* {{$_SESSION.s_brand}} */, :P6 /* {{$_SESSION.s_booking}} */, :P7 /* {{$_SESSION.s_activity_event}} */, :P8 /* {{$_GET.question}} */, :P9 /* {{$_GET.contact}} */, :P10 /* {{$_SESSION.s_activity_type}} */, :P11 /* {{$_GET.is_for}} */, :P12 /* {{$_GET.is_per}} */, '199', :P13 /* {{$_GET.price}} */, :P14 /* {{$_SESSION.s_currency}} */, :P15 /* {{$_GET.quantity}} */, '999', '9.99', :P16 /* {{$_GET.first_name}} . \" attending \" . {{$_SESSION.s_activity_title}} */, :P17 /* {{NOW_UTC}} */, :P18 /* {{$_SESSION.s_is_a_test}} */, :P19 /* {{$_SESSION.s_activity}} */)",
                    "params": [
                      {
                        "name": ":P1",
                        "type": "expression",
                        "value": "{{$_SESSION.s_subscriber_user}}"
                      },
                      {
                        "name": ":P2",
                        "type": "expression",
                        "value": "{{$_SESSION.s_franchisor}}"
                      },
                      {
                        "name": ":P3",
                        "type": "expression",
                        "value": "{{$_SESSION.s_collaborator}}"
                      },
                      {
                        "name": ":P4",
                        "type": "expression",
                        "value": "{{$_SESSION.s_business}}"
                      },
                      {
                        "name": ":P5",
                        "type": "expression",
                        "value": "{{$_SESSION.s_brand}}"
                      },
                      {
                        "name": ":P6",
                        "type": "expression",
                        "value": "{{$_SESSION.s_booking}}"
                      },
                      {
                        "name": ":P7",
                        "type": "expression",
                        "value": "{{$_SESSION.s_activity_event}}"
                      },
                      {
                        "name": ":P8",
                        "type": "expression",
                        "value": "{{$_GET.question}}"
                      },
                      {
                        "name": ":P9",
                        "type": "expression",
                        "value": "{{$_GET.contact}}"
                      },
                      {
                        "name": ":P10",
                        "type": "expression",
                        "value": "{{$_SESSION.s_activity_type}}"
                      },
                      {
                        "name": ":P11",
                        "type": "expression",
                        "value": "{{$_GET.is_for}}"
                      },
                      {
                        "name": ":P12",
                        "type": "expression",
                        "value": "{{$_GET.is_per}}"
                      },
                      {
                        "name": ":P13",
                        "type": "expression",
                        "value": "{{$_GET.price}}"
                      },
                      {
                        "name": ":P14",
                        "type": "expression",
                        "value": "{{$_SESSION.s_currency}}"
                      },
                      {
                        "name": ":P15",
                        "type": "expression",
                        "value": "{{$_GET.quantity}}"
                      },
                      {
                        "name": ":P16",
                        "type": "expression",
                        "value": "{{$_GET.first_name}} . \" attending \" . {{$_SESSION.s_activity_title}}"
                      },
                      {
                        "name": ":P17",
                        "type": "expression",
                        "value": "{{NOW_UTC}}"
                      },
                      {
                        "name": ":P18",
                        "type": "expression",
                        "value": "{{$_SESSION.s_is_a_test}}"
                      },
                      {
                        "name": ":P19",
                        "type": "expression",
                        "value": "{{$_SESSION.s_activity}}"
                      }
                    ]
                  }
                },
                "meta": [
                  {
                    "name": "identity",
                    "type": "text"
                  },
                  {
                    "name": "affected",
                    "type": "number"
                  }
                ]
              },
              {
                "name": "booking_item",
                "module": "core",
                "action": "setvalue",
                "options": {
                  "key": "booking_item",
                  "value": "{{insert_booking_item.identity}}"
                },
                "output": true
              }
            ]
          },
          "else": {
            "steps": {
              "name": "booking_item",
              "module": "core",
              "action": "setvalue",
              "options": {
                "key": "booking_item",
                "value": "{{$_POST.booking_item}}"
              },
              "output": true
            }
          }
        },
        "outputType": "boolean"
      }
    ]
  }
}
JSON
);
?>

Hello Antony,
I was not able to recreate this…
Can you just explain in a few short steps explain how to reproduce it?

I wish I could, Teodor!

This is what I do:

  1. Start creating a complex server action that I am not totally clear how will work.
  2. Add various parameters, sometimes to the parameters area, sometimes typing them manually into a database insert for example. (not recommended I know, but sometimes just most easily gets the job done).
  3. Suddenly realise the problem is back.

That is the best I can tell you for now!

Best wishes,
Antony.

Are you only doing this with POST variables? So do they exist already, under GLOBALS > POST ?

Well editing the JSON at the start of the PHP file seems to fix things for now anyway! :slight_smile:

I have this issue in 2.8.4 too. It has been around for a while but editing the JSON has worked to now (although it is somewhat annoying).

It seems to happen most if you create POST variables first, then go through the process of establishing a DB connection, adding a DB Insert or Update step. When linking the db fields to the variables it will add the variables again, even if they already exist.

  1. Create action and POST vars
  2. Create DB action
  3. It will duplicate some vars (see fname in the screenshot below)

    Interestingly, when creating these screenshots, the email field was typed manually in the value column of the DB action grid whereas the fname one (which ended up being duplicated) was picked with the data picker lightning bolt.
1 Like

I confirm that this behavior is still happening. Opening in code view and manually removing extra parameters is a workaround.

This topic is 2 years old. If you still have any issue please create a new topic and explain the issue in details.