Skip to content

Commit

Permalink
Fix #10818: MetaColumnNames ADOdb function may return bool value
Browse files Browse the repository at this point in the history
The MetaColumnNames ADOdb function doesn't always return an array - it
could return a boolean value of false as well. Therefore before using
the result of a call to MetaColumnNames, we must first check that we've
got a valid array. ADOdb documentation of course doesn't mention this.
  • Loading branch information
davidhicks committed Jan 17, 2010
1 parent e1d134e commit 90d3d4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions core/database_api.php
Expand Up @@ -602,8 +602,8 @@ function db_index_exists( $p_table_name, $p_index_name ) {
*/
function db_field_exists( $p_field_name, $p_table_name ) {
global $g_db;
$columns = $g_db->MetaColumnNames( $p_table_name );
return is_array( $columns ) ? in_array( $p_field_name, $columns ) : false;
$columns = db_field_names( $p_table_name );
return in_array( $p_field_name, $columns );
}

/**
Expand All @@ -613,7 +613,8 @@ function db_field_exists( $p_field_name, $p_table_name ) {
*/
function db_field_names( $p_table_name ) {
global $g_db;
return $g_db->MetaColumnNames( $p_table_name );
$columns = $g_db->MetaColumnNames( $p_table_name );
return is_array( $columns ) ? $columns : array();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion manage_user_page.php
Expand Up @@ -68,7 +68,7 @@
$c_filter = '';

# Clean up the form variables
if ( !in_array( $f_sort, db_field_names( $t_user_table ) ) ) {
if ( !db_field_exists( $f_sort, $t_user_table ) ) {
$c_sort = 'username';
} else {
$c_sort = addslashes($f_sort);
Expand Down

0 comments on commit 90d3d4d

Please sign in to comment.