Skip to content

Conversation

florisvdh
Copy link
Member

@florisvdh florisvdh commented Dec 28, 2023

Attempt to fix #195.

Changes should not affect typical use of the package, but only make the experience more intuitive when one wants to fiddle with JSON input/output.

- Always update the cache value if option or env var is set for json_output; this brings effect of the user
setting more on par with effect of json_input setting. This also includes an immediate effect of the option
setting on the return value of qgis_using_json_output(), just like it already was the case in
qgis_using_json_input().

- If json_output is set by the user, don't follow it if it's set as FALSE AND the user has explicitly set
json_input as TRUE. The latter always triggers json_output as TRUE in backend qgis_process.
During package configuration, reconfigure the use_json_output cache value if the corresponding option/envvar
is set by the user and resolves to the opposite of the cache value. The 'resolving' part of the user setting
includes the check for a conflicting explicit setting for json_input vs json_output, just as resolving is done in
qgis_using_json_output().
Never allow a pre-existing cache value 'FALSE' to survive if JSON INput
is EXPLICITLY and ACCEPTABLY set as TRUE
…t setting *

If the json_output user setting (ie option or env var) is empty, but the json_input user setting is not empty
AND set as TRUE in an acceptable way (i.e. minimum QGIS version requirement satified), then the
use_json_output cache value must be TRUE. If not, the cache must be reconfigured and the cache file rewritten.
qgis_query_plugins() calls qgis_using_json_output(). If json_input user setting is present, this now makes
that qgis_version() is called. But the latter needs qgisprocess_cache$version, so we need to temporarily set
this cache element too to prepare for qgis_query_plugins().
…e of user settings *

This was already the case on Windows and macOS, and this commit extends this approach to all systems. AFAIK it
was never clear in the first place why at some point it didn't work on GHA Ubuntu runner (the reason for
testing '--json' in case of non-win & non-mac), and I've never witnessed such behaviour in Linux or GHA. This
commit causes a speed gain up to several seconds for the query=TRUE case.

Note that the test mimicking a situation where --json would not work, was only relevant in the previous state
and only on Linux, so dropping these expectations.
@florisvdh florisvdh merged commit 9404a5e into main Dec 29, 2023
@florisvdh florisvdh deleted the json branch December 29, 2023 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve the handling and validation of JSON input/output user settings
1 participant