3liz / lizmap-web-client

Transfer a QGIS project on a server, Lizmap is providing the web interface to browse it
https://www.lizmap.com
Mozilla Public License 2.0
249 stars 141 forks source link

[Bug]: Editing data of Array type with PHP 8.1 doesn't (always) work #3154

Closed geographit closed 1 year ago

geographit commented 1 year ago

What is the bug?

When a project has an editable layer with

  1. An array field in Postgis
  2. A "customised" Attribute forms (E.g aliases...)

Trying to edit the layer in Lizmap throws an error in the logs array_key_exists(): Argument #2 ($array) must be of type array

It is not possible to edit the layer and Lizmap becomes unstable (I noticed some crashes).

Steps to reproduce the issue

  1. Create a postgis table with an array

    CREATE TABLE test_array (
    id SERIAL NOT NULL PRIMARY KEY,
    my_array real [5] DEFAULT NULL,
    geom geometry(MULTIPOLYGON, 4326)
    );
  2. Create a lizmap project with the layer set as editable

  3. Style the layer attribute form (add an alias). This will cause the .qgs file to specify the field type in xml <editWidget type="List">

  4. In lizmap edit the layer. It should hang and display an error in Lizmap logs.

Temporary fix

Installing php 7.8 instead of php 8.1 solves the issue. Also if the layer's attribute form is not modified, the project file (*.qgs) it seems php won't know the data type and there will be no error.

Versions

QGIS desktop 3.26 Lizmap 3.55 QGIS Server 3.26

Check Lizmap plugin

QGIS server version, only if the section above doesn't mention the QGIS Server version

No response

Operating system

Ubuntu 22 lts

Browsers

Firefox, Chrome, Safari, Microsoft Edge

Browsers version

Firefox 89

Relevant log output

No response

nworr commented 1 year ago

thanks for the detailled steps, it's related to a change in array_key_exists since php 8.0. quick fix can be made