Skip to content

API output changed with 1.6.0 (PHP8), which breaks automation tools like Terraform #4043

@steffencircle

Description

@steffencircle

Describe the bug
After upgrading to version 1.6.0 with PHP 8 , we noticed that the API output changed, which breaks automation Tools like Terraform and the phpipam Terraform provider.

The issue was first addressed with the provider itself here lord-kyron/terraform-provider-phpipam#84 but i have the feeling it makes sense to also raise it here, as i am still unsure if the change in behaviour is intended.

In its core, the issue seems to be that phpipam now with PHP8 seems to return integers and floats using native PHP types instead of strings.

See here https://www.php.net/manual/en/migration81.incompatible.php#migration81.incompatible.pdo.mysql

The issue for now appears with the sections API but might be seen elsewhere.

Below is a section output of the error, on what the returned response for Section now with 1.6.0 looks like:

v1.6.0

curl -X GET https://my-phpipam.net/api/apiclient/sections/ --header "token: MY_TOKEN" -i

  {
    "id": 1,
    "name": "Customers",
    "description": "Section for customers",
    "masterSection": 0,
    "permissions": "{\"3\":\"1\",\"2\":\"2\"}",
    "strictMode": "1",
    "subnetOrdering": null,
    "order": 3,
    "editDate": "2022-12-22 10:48:16",
    "showSubnet": 1,
    "showVLAN": 0,
    "showVRF": 0,
    "showSupernetOnly": 0,
    "DNS": null
  },

Running the following API call against the 1.5.2 instance reveals that the response looks different there:

v1.5.2

curl -X GET https://my-phpipam.net/api/apiclient/sections/ --header "token: MY_TOKEN" -i

...
    {
      "id": "1",
      "name": "Customers",
      "description": "Section for customers",
      "masterSection": "0",
      "permissions": "{\"3\":\"1\",\"2\":\"2\"}",
      "strictMode": "1",
      "subnetOrdering": null,
      "order": "3",
      "editDate": "2022-12-22 10:48:16",
      "showSubnet": "1",
      "showVLAN": "0",
      "showVRF": "0",
      "showSupernetOnly": "0",
      "DNS": null
    },

Other users have experimeted with using PDO::ATTR_STRINGIFY_FETCHES to restore the old behaviour which seems to work, however its unclear if that breaks something else.

phpIPAM version
1.6.0

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions