diff --git a/CHANGELOG b/CHANGELOG index f03847bc1..e3ac7dcf2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,7 @@ CHANGELOG Roundcube Webmail - Fix so displayed maximum attachment size depends also on 'max_message_size' (#7105) - Fix bug where 'skins_allowed' option didn't enforce user skin preference (#7080) - Fix so contact's organization field accepts up to 128 characters (it was 50) +- Fix bug where listing tables in PostgreSQL database with db_prefix didn't work (#7093) RELEASE 1.4.1 ------------- diff --git a/program/lib/Roundcube/db/pgsql.php b/program/lib/Roundcube/db/pgsql.php index 957d3f4e5..da26f12f6 100644 --- a/program/lib/Roundcube/db/pgsql.php +++ b/program/lib/Roundcube/db/pgsql.php @@ -191,9 +191,8 @@ class rcube_db_pgsql extends rcube_db { // get tables if not cached if ($this->tables === null) { - if ($schema = $this->options['table_prefix']) { - $schema = str_replace('.', '', $schema); - $add = " AND TABLE_SCHEMA = " . $this->quote($schema); + if (($schema = $this->options['table_prefix']) && $schema[strlen($schema)-1] === '.') { + $add = " AND TABLE_SCHEMA = " . $this->quote(substr($schema, 0, -1)); } else { $add = " AND TABLE_SCHEMA NOT IN ('pg_catalog', 'information_schema')"; @@ -220,9 +219,9 @@ class rcube_db_pgsql extends rcube_db { $args = array($table); - if ($schema = $this->options['table_prefix']) { + if (($schema = $this->options['table_prefix']) && $schema[strlen($schema)-1] === '.') { $add = " AND TABLE_SCHEMA = ?"; - $args[] = str_replace('.', '', $schema); + $args[] = substr($schema, 0, -1); } else { $add = " AND TABLE_SCHEMA NOT IN ('pg_catalog', 'information_schema')";