View Issue Details

IDProjectCategoryView StatusLast Update
0008246mantisbtupgradepublic2007-10-04 01:40
Reportergiallu Assigned Tothraxisp  
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status closedResolutionfixed 
Fixed in Version1.1.0rc1 
Summary0008246: Add support for running arbitrary functions
Description

The old system allowed running arbitrary functions during the upgrade; this looks like not being available now, but would be very useful

TagsNo tags attached.

Activities

thraxisp

thraxisp

2007-08-08 23:04

reporter   ~0015374

Initial code submitted to CVS. Two options were added: SQL only upgrade and a php function upgrade.

The former is done as follows:

$upgrade[] = Array('UpdateSQL', 'UPDATE '.config_get('mantis_user_table') SET duplicate_realname = 'Y' WHERE id<10' );

The latter references a function named in the upgrade.

$upgrade[] = Array('AddColumnSQL',Array(config_get('mantis_user_table'), "duplicate_realname I(1) NOTNULL DEFAULT \"0\""));
$upgrade[] = Array('UpdateFunction', 'user_duplicate' );

function install_user_duplicate() {
$t_user_table = config_get('mantis_user_table');

$query = "SELECT realname FROM $t_user_table
                        WHERE realname != ''
                        GROUP BY realname
                        HAVING count(realname) > 1";
                echo $query;
$result = db_query( $query );
$t_count = db_num_rows( $result );
echo " $t_count";
for ( $i = 0 ; $i < $t_count ; $i++ ) {
    $t_row = db_fetch_array( $result );
    $t_name = $t_row['realname'];
    $query = "UPDATE $t_user_table
        SET duplicate_realname = 'Y'
        WHERE realname='$t_name'";
    db_query( $query );
}

return 2; // success, any other value is a failure

}