Change egw_addressbook.contact_pubkey to 16k as an ascii-armored 4096 bit PGP key is ~12k

This commit is contained in:
Ralf Becker 2015-09-01 13:44:21 +00:00
parent 15a8df624c
commit a26e86ee1e
3 changed files with 36 additions and 7 deletions

View File

@ -12,7 +12,7 @@
/* Basic information about this app */ /* Basic information about this app */
$setup_info['phpgwapi']['name'] = 'phpgwapi'; $setup_info['phpgwapi']['name'] = 'phpgwapi';
$setup_info['phpgwapi']['title'] = 'EGroupware API'; $setup_info['phpgwapi']['title'] = 'EGroupware API';
$setup_info['phpgwapi']['version'] = '14.3.902'; $setup_info['phpgwapi']['version'] = '14.3.903';
$setup_info['phpgwapi']['versions']['current_header'] = '1.29'; $setup_info['phpgwapi']['versions']['current_header'] = '1.29';
$setup_info['phpgwapi']['enable'] = 3; $setup_info['phpgwapi']['enable'] = 3;
$setup_info['phpgwapi']['app_order'] = 1; $setup_info['phpgwapi']['app_order'] = 1;
@ -73,3 +73,4 @@ $setup_info['groupdav']['license'] = 'GPL';
$setup_info['groupdav']['hooks']['preferences'] = 'groupdav_hooks::menus'; $setup_info['groupdav']['hooks']['preferences'] = 'groupdav_hooks::menus';
$setup_info['groupdav']['hooks']['settings'] = 'groupdav_hooks::settings'; $setup_info['groupdav']['hooks']['settings'] = 'groupdav_hooks::settings';

View File

@ -270,7 +270,7 @@ $phpgw_baseline = array(
'contact_note' => array('type' => 'varchar','precision' => '8192','comment' => 'notes field'), 'contact_note' => array('type' => 'varchar','precision' => '8192','comment' => 'notes field'),
'contact_tz' => array('type' => 'varchar','precision' => '8','comment' => 'timezone difference'), 'contact_tz' => array('type' => 'varchar','precision' => '8','comment' => 'timezone difference'),
'contact_geo' => array('type' => 'ascii','precision' => '32','comment' => 'currently not used'), 'contact_geo' => array('type' => 'ascii','precision' => '32','comment' => 'currently not used'),
'contact_pubkey' => array('type' => 'ascii','precision' => '8192','comment' => 'public key'), 'contact_pubkey' => array('type' => 'ascii','precision' => '16384','comment' => 'public key'),
'contact_created' => array('type' => 'int','meta' => 'timestamp','precision' => '8','comment' => 'timestamp of the creation'), 'contact_created' => array('type' => 'int','meta' => 'timestamp','precision' => '8','comment' => 'timestamp of the creation'),
'contact_creator' => array('type' => 'int','meta' => 'user','precision' => '4','nullable' => False,'comment' => 'account id of the creator'), 'contact_creator' => array('type' => 'int','meta' => 'user','precision' => '4','nullable' => False,'comment' => 'account id of the creator'),
'contact_modified' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'comment' => 'timestamp of the last modified'), 'contact_modified' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'comment' => 'timestamp of the last modified'),

View File

@ -525,11 +525,17 @@ function phpgwapi_upgrade14_2_017()
'precision' => '32', 'precision' => '32',
'comment' => 'currently not used' 'comment' => 'currently not used'
)); ));
$GLOBALS['egw_setup']->oProc->AlterColumn('egw_addressbook','contact_pubkey',array( // only shorten pubkey to varchar(16384), if it does NOT contain longer input and it can be stored as varchar
'type' => 'ascii', $max_pubkey_length = $GLOBALS['egw']->db->query('SELECT MAX(LENGTH(contact_pubkey)) FROM egw_addressbook')->fetchColumn();
'precision' => '8192', // returns NULL, if there are no rows!
'comment' => 'public key' if ((int)$max_pubkey_length <= 16384 && $GLOBALS['egw_setup']->oProc->max_varchar_length >= 16384)
)); {
$GLOBALS['egw_setup']->oProc->AlterColumn('egw_addressbook','contact_pubkey',array(
'type' => 'ascii',
'precision' => '16384',
'comment' => 'public key'
));
}
$GLOBALS['egw_setup']->oProc->AlterColumn('egw_addressbook','contact_uid',array( $GLOBALS['egw_setup']->oProc->AlterColumn('egw_addressbook','contact_uid',array(
'type' => 'ascii', 'type' => 'ascii',
'precision' => '128', 'precision' => '128',
@ -895,3 +901,25 @@ function phpgwapi_upgrade14_3_901()
} }
return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '14.3.902'; return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '14.3.902';
} }
/**
* Change egw_addressbook.contact_pubkey to 16k as an ascii-armored 4096 bit PGP key is ~12k
*
* @return type
*/
function phpgwapi_upgrade14_3_902()
{
// only shorten pubkey to varchar(16384), if it does NOT contain longer input and it can be stored as varchar
$max_pubkey_length = $GLOBALS['egw']->db->query('SELECT MAX(LENGTH(contact_pubkey)) FROM egw_addressbook')->fetchColumn();
// returns NULL, if there are no rows!
if ((int)$max_pubkey_length <= 16384 && $GLOBALS['egw_setup']->oProc->max_varchar_length >= 16384)
{
$GLOBALS['egw_setup']->oProc->AlterColumn('egw_addressbook','contact_pubkey',array(
'type' => 'ascii',
'precision' => '16384',
'comment' => 'public key'
));
}
return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '14.3.903';
}