Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1b79a041ad2c
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ef24c0f36b8b
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jun 27, 2012

  1. Fix PostgreSQL error when adding project/subproject

    Release 1.2.11 (see commit b8d4b50 and
    issue #14288) introduced a regression preventing the user from creating
    a new project or adding a subproject.
    
    The error is caused by columns mantis_project_table.inherit_global and
    mantis_project_hierarchy_table.inherit_parent, which are defined as
    unsigned int in schema.php, but treated as boolean in the code. This is
    a problem with PostgreSQL due to strict type checking, but not on MySQL
    as type cast is done automatically.
    
    This commit is a workaround for the problem (sending an int to the DB
    instead of a bool if using PostgreSQL), as fixing the root cause would
    require a schema change which is not possible in 1.2.x.
    
    Fixes #14385
    dregad committed Jun 27, 2012
    Copy the full SHA
    ba71cf9 View commit details
  2. Fix PostgreSQL error when updating a project

    Release 1.2.11 (see commit b8d4b50 and
    issue #14288) introduced a regression preventing the user from updating
    an existing project.
    
    This commit is a workaround for the problem (sending an int to the DB
    instead of a bool if using PostgreSQL), as fixing the root cause would
    require a schema change which is not possible in 1.2.x.
    
    Fixes #14385
    dregad committed Jun 27, 2012
    Copy the full SHA
    ef24c0f View commit details
Showing with 21 additions and 4 deletions.
  1. +13 −2 core/project_api.php
  2. +8 −2 core/project_hierarchy_api.php
15 changes: 13 additions & 2 deletions core/project_api.php
Original file line number Diff line number Diff line change
@@ -287,7 +287,13 @@ function validate_project_file_path( $p_file_path ) {
function project_create( $p_name, $p_description, $p_status, $p_view_state = VS_PUBLIC, $p_file_path = '', $p_enabled = true, $p_inherit_global = true ) {

$c_enabled = db_prepare_bool( $p_enabled );
$c_inherit_global = db_prepare_bool( $p_inherit_global );

# Workaround for #14385 - inherit_global column is wrongly defined as int
if( db_is_pgsql() ) {
$c_inherit_global = db_prepare_int( $p_inherit_global );
} else {
$c_inherit_global = db_prepare_bool( $p_inherit_global );
}

if( is_blank( $p_name ) ) {
trigger_error( ERROR_PROJECT_NAME_INVALID, ERROR );
@@ -372,7 +378,12 @@ function project_update( $p_project_id, $p_name, $p_description, $p_status, $p_v

$p_project_id = (int) $p_project_id;
$c_enabled = db_prepare_bool( $p_enabled );
$c_inherit_global = db_prepare_bool( $p_inherit_global );
# Workaround for #14385 - inherit_global column is wrongly defined as int
if( db_is_pgsql() ) {
$c_inherit_global = db_prepare_int( $p_inherit_global );
} else {
$c_inherit_global = db_prepare_bool( $p_inherit_global );
}

if( is_blank( $p_name ) ) {
trigger_error( ERROR_PROJECT_NAME_INVALID, ERROR );
10 changes: 8 additions & 2 deletions core/project_hierarchy_api.php
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
$g_cache_project_hierarchy = null;
$g_cache_project_inheritance = null;
$g_cache_show_disabled = null;

/**
* Add project to project hierarchy
* @param int $p_child_id Child project ID
@@ -44,7 +44,13 @@ function project_hierarchy_add( $p_child_id, $p_parent_id, $p_inherit_parent = t

$c_child_id = db_prepare_int( $p_child_id );
$c_parent_id = db_prepare_int( $p_parent_id );
$c_inherit_parent = db_prepare_bool( $p_inherit_parent );

# Workaround for #14385 - inherit_parent column is wrongly defined as int
if( db_is_pgsql() ) {
$c_inherit_parent = db_prepare_int( $p_inherit_parent );
} else {
$c_inherit_parent = db_prepare_bool( $p_inherit_parent );
}

$query = "INSERT INTO $t_project_hierarchy_table
( child_id, parent_id, inherit_parent )