Project

General

Profile

Actions

Bug #16694

closed

Extension manager fails in a postgres environment with multiple schema's and tables.

Added by Michiel Roos over 17 years ago. Updated about 11 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2006-11-07
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.1
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Attempting to install any extension that works with tables errors out with:

Fatal error: Call to a member function MetaType() on a non-object in /var/www/typo3/typo3_src-4.0.2/typo3/sysext/dbal/class.ux_t3lib_db.php on line 1096

This is caused in the end by:
typo3/sysext/dbal/class.ux_t3lib_db.php line 1088, function MetaType
which is called by:
typo3/sysext/dbal/class.ux_t3lib_db.php line 1734, function admin_get_fields
which is called by:
t3lib/class.t3lib_install.php line 411, function getFieldDefinitions_database
which is called by:
typo3/mod/tools/em/class.em_index.php line 4371, function checkDBupdates

The function checkDBupdates:
Validates the database according to extension requirements. Prints form for changes if any. If none, returns blank. If an update is ordered, empty is returned as well. DBAL compliant (based on Install Tool code).

The function getFieldDefinitions_database calls admin_get_tables which gets all the tables and iterates over them. This function should iterate over the list of tables WITH the schema prefix added.

function admin_get_tables (typo3/sysext/dbal/class.ux_t3lib_db.php, 1649), calls (in case of adodb):
$sqlTables = $this->handlerInstance['_DEFAULT']->MetaTables('TABLES');

So . . . . . in case of postgres . . . . the MetaTables function:
typo3/sysext/adodb/adodb/drivers/adodb-postgres64.inc.php, line 209:

Executes:
select tablename,'T' from pg_tables where tablename not like 'pg\_%'
and schemaname not in ( 'pg_catalog','information_schema')
union
select viewname,'V' from pg_views where viewname not like 'pg\_%' and schemaname not in ( 'pg_catalog','information_schema')

This returns a list of all tables that the current connection user may view.

The problem here is that TYPO3 was installed by default in the 'public' schema. Tables herein may be queried without using the schema prefix 'public'.

The function MetaType does a SELECT from a table (without prefix). But a table has been added to a different schema (for example contacts.organisations) within the same database as TYPO3 was installed into.

In our case this results in three tables also viewable: origanisations, persons and organisations_persosn. These three tables reside in the 'contacts' schema however.

Because of all this the SQL SELECT query in MetaType() will fail.

Solution: allways take the schema into account when getting table listings and doing table operations.

(issue imported from #M4472)


Files

4472_class.ux_t3lib_sqlparser.patch (1.14 KB) 4472_class.ux_t3lib_sqlparser.patch Administrator Admin, 2007-10-10 10:50
Actions

Also available in: Atom PDF