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

[Bugfix] Multiple calls of editableFeatures method breaks php #5479

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

mind84
Copy link
Contributor

@mind84 mind84 commented Feb 26, 2025

When a popup is displayed the system checks first whether the user can edit the feature or not, so as to configure the lizmap-feature-toolbar HTML element correctly.

At time being, if the layer is filtered by user (Attribute filtering tab in Lizmap plugin), the system queries all the features of the layers and then filters the entire list by feature id to perform the check.

$editableFeatures = $qgisLayer->editableFeatures();

This operation is executed for every feature on popup, even if features belonging to same layer.

If the layer has a lot of feature then this operation easily leads to php exceptions (max_execution_time on master branch with jsonmachine, memory error for Lizmap <= 3.8 )

I didn't use the isFeatureEditable method (which seems suitable for this job) because it requires a feature object that you can't get from a WMS request (like the Popup request) so, as a first solution, I chose to parameterize the editableFeatures function.

Backport to 3.8 and 3.9, if possible

Funded by Faunalia

@github-actions github-actions bot added this to the 3.10.0 milestone Feb 26, 2025
@rldhont
Copy link
Collaborator

rldhont commented Feb 26, 2025

Hi @mind84,

Thanks for your contribution, if you want to update editableFeatures, I am much in favor of

    /**
     * Get the layer editable features.
     * Used client-side (JS) to fetch the features which are editable by the authenticated user
     * when there is a filter by login (or by polygon). This allows to deactivate the editing icon
     * for the non-editable features inside the popup and attribute table.
      * @param array<string, string> [$wfsParams] Extra WFS parameters to filter the layer : FEATUREID or EXP_FILTER could be use
     *
     * @return array Data containing the status (restricted|unrestricted) and the features if restricted
     */
    public function editableFeatures($wfsParams = array())

In this case editableFeatures can be use in isFeatureEditable

@rldhont rldhont added QGIS Server user interface sponsored development This development has been funded run end2end If the PR must run end2end tests or not php Pull requests that update Php code backport release_3_8 backport release_3_9 labels Feb 26, 2025
@mind84 mind84 force-pushed the editable_features_performance branch from 4d171f9 to 48c9b5d Compare February 26, 2025 14:23
@mind84
Copy link
Contributor Author

mind84 commented Feb 26, 2025

@rldhont,

I leave the isFeatureEditable method refactoring for another PR. There is some shared logic between the two functions but they do quite different jobs so I'll have to work on that

@rldhont
Copy link
Collaborator

rldhont commented Feb 26, 2025

Thanks @mind84

@mind84
Copy link
Contributor Author

mind84 commented Feb 27, 2025

@rldhont,

there a bunch of tests that fail, some might be related to these changes ( filter-layer-by-user.spec.js ), at least at first glance.

Looking closer, the errors seem more related to some interactions with the interface. Also, I can't reproduce these errors in my local development environment.

Should be worried about that?

Thanks!

@Gustry
Copy link
Member

Gustry commented Feb 27, 2025

Should be worried about that?

We are first looking at QGIS 3.34 stack, which is green in your PR.
For QGIS 3.40, we are aware about false positive. Be sure you have an up to date branch on master, some tests about 3.40 are fixed already.

filter-layer-by-user.spec.js is already fixed with #5470

@Gustry Gustry merged commit 9e329f2 into 3liz:master Feb 27, 2025
19 of 20 checks passed
@mind84 mind84 deleted the editable_features_performance branch February 27, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release_3_8 backport release_3_9 php Pull requests that update Php code QGIS Server run end2end If the PR must run end2end tests or not sponsored development This development has been funded user interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants