Skip to content

Commit e5a3719

Browse files
Merge pull request #8206 from Oldiesmann/fix_postgres_search
2 parents 99e8d1f + 56338ed commit e5a3719

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Sources/Search/APIs/Custom.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,10 @@ public function getSize(): int
213213
if ($request !== false && Db::$db->num_rows($request) == 1) {
214214
$row = Db::$db->fetch_assoc($request);
215215
$this->size = (int) $row['Data_length'] + (int) $row['Index_length'];
216+
Db::$db->free_result($request);
216217
}
217218
}
218219

219-
Db::$db->free_result($request);
220-
221220
return $this->size;
222221
}
223222

Sources/Search/APIs/Parsed.php

+10
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ public function getSize(): int
188188
$this->size = 0;
189189

190190
if (Db::$db->title === POSTGRE_TITLE) {
191+
192+
// Postgres will throw an error if the tables don't exist, so check first
193+
$search_tables = Db::$db->list_tables(Db::$db->name, Db::$db->prefix . 'log_search%');
194+
195+
if (array_intersect([Db::$db->prefix . 'log_search_dictionary', Db::$db->prefix . 'log_search_parsed'], $search_tables) == []) {
196+
return $this->size;
197+
}
198+
191199
$request = Db::$db->query(
192200
'',
193201
'SELECT (
@@ -203,6 +211,8 @@ public function getSize(): int
203211
while ($row = Db::$db->fetch_assoc($request)) {
204212
$this->size = (int) $row['total_size'];
205213
}
214+
215+
Db::$db->free_result($request);
206216
} else {
207217
$request = Db::$db->query(
208218
'',

0 commit comments

Comments
 (0)