Skip to content

[Backport release_3_8] Fix the way to check if the lizmap_search is available #5877

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

Merged
merged 1 commit into from
Jul 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions lizmap/modules/lizmap/classes/lizmapFtsSearch.listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,35 @@ protected function checkLizmapFts()
return false;
}

// Use a transaction to avoid: "ERROR: current transaction is aborted"
// https://github.com/3liz/lizmap-web-client/issues/2008
$cnx->beginTransaction();
// Check if lizmap_search table / view / materialized view exists
// in the search_path
$sql = "
SELECT EXISTS (
SELECT FROM
pg_catalog.pg_class c
JOIN
pg_catalog.pg_namespace n ON
n.oid = c.relnamespace
WHERE
n.nspname = ANY(current_schemas(FALSE)) AND
-- current_schemas(FALSE) returns the list of schemas in the search_path
c.relname = 'lizmap_search' AND
c.relkind = ANY(ARRAY['r', 'v', 'm', 'f', 'p'])
-- r = ordinary table, v = view, m = materialized view, f = foreign table, p = partitioned
) AS lizmap_search_exists;
";

// Try to get data from lizmap_fts table / view / materialized view
try {
$cnx->query('SELECT * FROM lizmap_search LIMIT 0;');
$cnx->commit();
$ok = true;
$res = $cnx->query($sql);
foreach ($res as $r) {
return $r->lizmap_search_exists;
}
} catch (Exception $e) {
$cnx->rollback();
$ok = false;
jLog::logEx($e, 'error');

return false;
}

return $ok;
return false;
}
}
Loading