From b7ebffd620a57c150577af24bf6d46e9c6d091a4 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Wed, 30 Apr 2014 18:28:54 +0200 Subject: [PATCH 1/6] Update ADOdb to 5.19 --- core/constant_inc.php | 2 +- library/README.libs | 2 +- library/adodb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/constant_inc.php b/core/constant_inc.php index 28232f1cb2..345104f93a 100644 --- a/core/constant_inc.php +++ b/core/constant_inc.php @@ -39,7 +39,7 @@ # installation define( 'CONFIGURED_PASSWORD', "______" ); -define( 'DB_MIN_VERSION_ADODB', '5.19dev' ); # For mssql, oracle and pgsql +define( 'DB_MIN_VERSION_ADODB', '5.19' ); # For mssql, oracle and pgsql define( 'DB_MIN_VERSION_MSSQL', '9.0.0' ); define( 'DB_MIN_VERSION_MYSQL', '5.0.8' ); # See #16584 define( 'DB_MIN_VERSION_PGSQL', '8.4' ); # Earliest supported version as of Jan 2014 diff --git a/library/README.libs b/library/README.libs index 73ed1adce3..c53c70c4f7 100644 --- a/library/README.libs +++ b/library/README.libs @@ -5,7 +5,7 @@ The version and status of each is summarized below: ------------------------------------------------------------------- directory | project | version | status ------------------------------------------------------------------- -adodb | adodb | v5.18a-49 | unpatched [1] +adodb | adodb | v5.19 | unpatched [1] disposable | disposable | 1.1.0 | unpatched ezc | ez Components | 2009.2.1 | unpatched phpmailer | PHPMailer | 5.2.6 | unpatched [1] diff --git a/library/adodb b/library/adodb index c1abd33cf8..9346d288a1 160000 --- a/library/adodb +++ b/library/adodb @@ -1 +1 @@ -Subproject commit c1abd33cf8f4c67a98f559a0028f39d8194b21f0 +Subproject commit 9346d288a1b7f7a50cc35b6a0e56d29e9d000ecf From 84d21a61f61335d9d66a8ecdac88bcf5e6b16590 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Tue, 13 May 2014 09:23:20 +0200 Subject: [PATCH 2/6] oci8 no longer needs special fetch mode with ADOdb 5.19 Fixes #15426 --- core/database_api.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/core/database_api.php b/core/database_api.php index 94455565dd..819635ee6e 100644 --- a/core/database_api.php +++ b/core/database_api.php @@ -53,18 +53,9 @@ # @global bool $g_db_log_queries $g_db_log_queries = ( 0 != ( config_get_global( 'log_level' ) & LOG_DATABASE ) ); - # set adodb fetch mode # @global bool $ADODB_FETCH_MODE -if( db_is_oracle() ) { - # Due to oci8 returning column names in uppercase, the MantisBT - # default fetch mode (ADODB_FETCH_ASSOC) does not work properly - # in the current version of ADOdb (5.18) so we override it. - # See #15426 - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; -} else { - $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; -} +$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; /** * Mantis Database Parameters Count class From f9c2aec0718f0cac2e6b9f626e2a3661b2303c2b Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Mon, 7 Jul 2014 23:31:15 +0200 Subject: [PATCH 3/6] Use ADODB-specific constant instead of 'false' --- core/database_api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/database_api.php b/core/database_api.php index 819635ee6e..43b4dcbf6e 100644 --- a/core/database_api.php +++ b/core/database_api.php @@ -472,7 +472,7 @@ function db_fetch_array( IteratorAggregate &$p_result ) { $p_result->MoveNext(); return $t_array; } else { - $t_row = $p_result->GetRowAssoc( false ); + $t_row = $p_result->GetRowAssoc( ADODB_ASSOC_CASE_LOWER ); static $s_array_result; static $s_array_fields; From 83e1cfde28459f74fd34aa8a2e233ccd7c6385dd Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Tue, 8 Jul 2014 00:49:47 +0200 Subject: [PATCH 4/6] Coding guidelines --- core/database_api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/database_api.php b/core/database_api.php index 43b4dcbf6e..3fb371a227 100644 --- a/core/database_api.php +++ b/core/database_api.php @@ -328,7 +328,7 @@ function db_query_bound( $p_query, array $p_arr_parms = null, $p_limit = -1, $p_ static $s_check_params; if( $s_check_params === null ) { - $s_check_params = ( db_is_pgsql() || $t_db_type == 'odbc_mssql' || $t_db_type == 'mssqlnative'); + $s_check_params = ( db_is_pgsql() || $t_db_type == 'odbc_mssql' || $t_db_type == 'mssqlnative' ); } $t_start = microtime( true ); From fbf016c3b497a7b223751fd4cc537904c4810b58 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Tue, 8 Jul 2014 00:50:52 +0200 Subject: [PATCH 5/6] Fix db_query_bound() to work with ADOdb::Execute() In ADOdb v5.19 the Execute() method was modified to perform a strict type check on the $inputarr parameter. Since that param defaults to 'false', database errors are triggered when the method receives 'null' and there are no parameters to the query being executed. Since db_query_bound() $p_arr_parms defaults to null, the problem occurs almost everywhere. To fix this, we can either: 1. set $p_arr_parms to array() when it is null 2. defaut $p_arr_parms to array() The 2nd option would cause errors with db_query_bound($sql, null) calls, so we implement the first one as it offers better backwards compatibility. Function can be called like this (the first 3 methods being equivalent): - db_query_bound($sql) - db_query_bound($sql, null) - db_query_bound($sql, array()) - db_query_bound($sql, array(1,2)) --- core/database_api.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/database_api.php b/core/database_api.php index 3fb371a227..d9660a5386 100644 --- a/core/database_api.php +++ b/core/database_api.php @@ -333,7 +333,14 @@ function db_query_bound( $p_query, array $p_arr_parms = null, $p_limit = -1, $p_ $t_start = microtime( true ); - if( $p_arr_parms != null && $s_check_params ) { + # This ensures that we don't get an error from ADOdb if $p_arr_parms == null, + # as Execute() expects either an array or false if there are no parameters - + # null actually gets treated as array( 0 => null ) + if( is_null( $p_arr_parms ) ) { + $p_arr_parms = array(); + } + + if( !empty( $p_arr_parms ) && $s_check_params ) { $t_params = count( $p_arr_parms ); for( $i = 0;$i < $t_params;$i++ ) { if( $p_arr_parms[$i] === false ) { @@ -360,7 +367,7 @@ function db_query_bound( $p_query, array $p_arr_parms = null, $p_limit = -1, $p_ if( ON == $g_db_log_queries ) { $t_lastoffset = 0; $i = 0; - if( !( is_null( $p_arr_parms ) || empty( $p_arr_parms ) ) ) { + if( !empty( $p_arr_parms ) ) { while( preg_match( '/\?/', $p_query, $t_matches, PREG_OFFSET_CAPTURE, $t_lastoffset ) ) { $t_matches = $t_matches[0]; # Realign the offset returned by preg_match as it is byte-based, From c726ff7b8449d76763919e65c1d3dbbcd63e7ded Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Tue, 8 Jul 2014 01:03:15 +0200 Subject: [PATCH 6/6] Call db_query_bound() with array() instead of null This is not strictly necessary right now, but replacing known occurences avoids future refactoring should we decide to change the default value for $p_arr_parms to array() later on. --- core/project_hierarchy_api.php | 2 +- core/summary_api.php | 2 +- core/user_api.php | 2 +- manage_user_page.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/project_hierarchy_api.php b/core/project_hierarchy_api.php index 96b2c1962f..79dfd89e19 100644 --- a/core/project_hierarchy_api.php +++ b/core/project_hierarchy_api.php @@ -172,7 +172,7 @@ function project_hierarchy_cache( $p_show_disabled = false ) { WHERE $t_enabled_clause ORDER BY p.name"; - $t_result = db_query_bound( $t_query, ( $p_show_disabled ? null : array( true ) ) ); + $t_result = db_query_bound( $t_query, ( $p_show_disabled ? array() : array( true ) ) ); $g_cache_project_hierarchy = array(); $g_cache_project_inheritance = array(); diff --git a/core/summary_api.php b/core/summary_api.php index fc1aa132fc..26d21af898 100644 --- a/core/summary_api.php +++ b/core/summary_api.php @@ -569,7 +569,7 @@ function summary_print_by_reporter() { WHERE $t_specific_where GROUP BY reporter_id ORDER BY num DESC"; - $t_result = db_query_bound( $t_query, null, $t_reporter_summary_limit ); + $t_result = db_query_bound( $t_query, array(), $t_reporter_summary_limit ); $t_reporters = array(); while( $t_row = db_fetch_array( $t_result ) ) { diff --git a/core/user_api.php b/core/user_api.php index ea90d10382..34fcf416c9 100644 --- a/core/user_api.php +++ b/core/user_api.php @@ -1074,7 +1074,7 @@ function user_get_accessible_subprojects( $p_user_id, $p_project_id, $p_show_dis WHERE $t_enabled_clause ph.parent_id IS NOT NULL ORDER BY p.name"; - $t_result = db_query_bound( $t_query, ( $p_show_disabled ? null : array( true ) ) ); + $t_result = db_query_bound( $t_query, ( $p_show_disabled ? array() : array( true ) ) ); } else { $t_query = "SELECT DISTINCT p.id, p.name, ph.parent_id FROM $t_project_table p diff --git a/manage_user_page.php b/manage_user_page.php index 3ac101e9a2..33b729b443 100644 --- a/manage_user_page.php +++ b/manage_user_page.php @@ -179,7 +179,7 @@ echo ''; echo ''; -$t_where_params = null; +$t_where_params = array(); if( $f_filter === 'ALL' ) { $t_where = '(1 = 1)'; } else if( $f_filter === 'UNUSED' ) {