Skip to content

Commit

Permalink
DB ADOdb MetaIndex fails when no constraints exist
Browse files Browse the repository at this point in the history
Working with Oracle database (oci8), when MetaIndex() method is called
to retrieve the list of indexes for a table that has no constraints
set, an error is triggered:
Fatal error: Call to a member function FetchRow() on a non-object

This commit adds a check to cleanly exit the function, returning false.

Similar error handling has also been added to the calling database_api
function db_index_exists()

This allows the DB installation (schema.php) to proceed without errors.

Fixes #13438

Porting to 1.3 - Conflicts:
	library/adodb/drivers/adodb-oci8.inc.php

Note: the fix to ADOdb driver does not need to be ported as it was
included in a later release of the library.
  • Loading branch information
dregad committed Oct 16, 2013
1 parent 674fbf7 commit 8792ee5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/database_api.php
Expand Up @@ -626,11 +626,13 @@ function db_index_exists( $p_table_name, $p_index_name ) {

if( is_blank( $p_index_name ) || is_blank( $p_table_name ) ) {
return false;

// no index found
}

$t_indexes = $g_db->MetaIndexes( $p_table_name );
if( $t_indexes === false ) {
// no index found
return false;
}

if( !empty( $t_indexes ) ) {
# Can't use in_array() since it is case sensitive
Expand Down

0 comments on commit 8792ee5

Please sign in to comment.