Skip to content

Commit

Permalink
QA: Change the Default for last_updated
Browse files Browse the repository at this point in the history
* The default for last_updated in the plugin_config table was wrong
* Re-arrange some columns for archived and available plugin versions
* Add the Archive/Available size to the respective table views.
  • Loading branch information
TheWitness committed Nov 24, 2024
1 parent 3a9243c commit e9f057b
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 33 deletions.
2 changes: 1 addition & 1 deletion cacti.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ CREATE TABLE `plugin_config` (
`author` varchar(64) NOT NULL default '',
`webpage` varchar(255) NOT NULL default '',
`version` varchar(10) NOT NULL default '',
`last_updated` timestamp default NULL,
`last_updated` timestamp NOT NULL default CURRENT_TIMESTAMP(),
PRIMARY KEY (`id`),
KEY `status` (`status`),
KEY `directory` (`directory`)
Expand Down
28 changes: 14 additions & 14 deletions docs/audit_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ INSERT INTO `table_columns` VALUES ('aggregate_graph_templates',7,'total','int(1
INSERT INTO `table_columns` VALUES ('aggregate_graph_templates',8,'total_type','int(10) unsigned','NO','',NULL,'');
INSERT INTO `table_columns` VALUES ('aggregate_graph_templates',9,'total_prefix','varchar(64)','NO','',NULL,'');
INSERT INTO `table_columns` VALUES ('aggregate_graph_templates',10,'order_type','int(10) unsigned','NO','',NULL,'');
INSERT INTO `table_columns` VALUES ('aggregate_graph_templates',11,'created','timestamp','NO','','current_timestamp()','');
INSERT INTO `table_columns` VALUES ('aggregate_graph_templates',11,'created','timestamp','NO','','CURRENT_TIMESTAMP','');
INSERT INTO `table_columns` VALUES ('aggregate_graph_templates',12,'user_id','int(10) unsigned','NO','MUL',NULL,'');
INSERT INTO `table_columns` VALUES ('aggregate_graph_templates',12,'graphs','int(10) unsigned','NO','','0','');
INSERT INTO `table_columns` VALUES ('aggregate_graph_templates_graph',1,'aggregate_template_id','int(10) unsigned','NO','PRI',NULL,'');
Expand Down Expand Up @@ -165,7 +165,7 @@ INSERT INTO `table_columns` VALUES ('aggregate_graphs',10,'total','int(10) unsig
INSERT INTO `table_columns` VALUES ('aggregate_graphs',11,'total_type','int(10) unsigned','NO','',NULL,'');
INSERT INTO `table_columns` VALUES ('aggregate_graphs',12,'total_prefix','varchar(64)','NO','',NULL,'');
INSERT INTO `table_columns` VALUES ('aggregate_graphs',13,'order_type','int(10) unsigned','NO','',NULL,'');
INSERT INTO `table_columns` VALUES ('aggregate_graphs',14,'created','timestamp','NO','','current_timestamp()','on update current_timestamp()');
INSERT INTO `table_columns` VALUES ('aggregate_graphs',14,'created','timestamp','NO','','CURRENT_TIMESTAMP','ON UPDATE CURRENT_TIMESTAMP');
INSERT INTO `table_columns` VALUES ('aggregate_graphs',15,'user_id','int(10) unsigned','NO','MUL',NULL,'');
INSERT INTO `table_columns` VALUES ('aggregate_graphs_graph_item',1,'aggregate_graph_id','int(10) unsigned','NO','PRI',NULL,'');
INSERT INTO `table_columns` VALUES ('aggregate_graphs_graph_item',2,'graph_templates_item_id','int(10) unsigned','NO','PRI',NULL,'');
Expand Down Expand Up @@ -729,8 +729,8 @@ INSERT INTO `table_columns` VALUES ('host',48,'polling_time','double','YES','','
INSERT INTO `table_columns` VALUES ('host',49,'total_polls','int(10) unsigned','YES','','0','');
INSERT INTO `table_columns` VALUES ('host',50,'failed_polls','int(10) unsigned','YES','','0','');
INSERT INTO `table_columns` VALUES ('host',51,'availability','decimal(8,5)','NO','','100.00000','');
INSERT INTO `table_columns` VALUES ('host',52,'last_updated','timestamp','NO','','current_timestamp()','on update current_timestamp()');
INSERT INTO `table_columns` VALUES ('host',53,'created','timestamp','YES','','current_timestamp()','');
INSERT INTO `table_columns` VALUES ('host',52,'last_updated','timestamp','NO','','CURRENT_TIMESTAMP','ON UPDATE CURRENT_TIMESTAMP');
INSERT INTO `table_columns` VALUES ('host',53,'created','timestamp','YES','','CURRENT_TIMESTAMP','');
INSERT INTO `table_columns` VALUES ('host_graph',1,'host_id','mediumint(8) unsigned','NO','PRI','0','');
INSERT INTO `table_columns` VALUES ('host_graph',2,'graph_template_id','mediumint(8) unsigned','NO','PRI','0','');
INSERT INTO `table_columns` VALUES ('host_snmp_cache',1,'host_id','mediumint(8) unsigned','NO','PRI','0','');
Expand All @@ -740,7 +740,7 @@ INSERT INTO `table_columns` VALUES ('host_snmp_cache',4,'field_value','varchar(5
INSERT INTO `table_columns` VALUES ('host_snmp_cache',5,'snmp_index','varchar(255)','NO','PRI','','');
INSERT INTO `table_columns` VALUES ('host_snmp_cache',6,'oid','text','NO','',NULL,'');
INSERT INTO `table_columns` VALUES ('host_snmp_cache',7,'present','tinyint(3) unsigned','NO','MUL','1','');
INSERT INTO `table_columns` VALUES ('host_snmp_cache',8,'last_updated','timestamp','NO','MUL','current_timestamp()','on update current_timestamp()');
INSERT INTO `table_columns` VALUES ('host_snmp_cache',8,'last_updated','timestamp','NO','MUL','CURRENT_TIMESTAMP','ON UPDATE CURRENT_TIMESTAMP');
INSERT INTO `table_columns` VALUES ('host_snmp_query',1,'host_id','mediumint(8) unsigned','NO','PRI','0','');
INSERT INTO `table_columns` VALUES ('host_snmp_query',2,'snmp_query_id','mediumint(8) unsigned','NO','PRI','0','');
INSERT INTO `table_columns` VALUES ('host_snmp_query',3,'sort_field','varchar(50)','NO','','','');
Expand All @@ -762,7 +762,7 @@ INSERT INTO `table_columns` VALUES ('plugin_config',4,'status','tinyint(3) unsig
INSERT INTO `table_columns` VALUES ('plugin_config',5,'author','varchar(64)','NO','','','');
INSERT INTO `table_columns` VALUES ('plugin_config',6,'webpage','varchar(255)','NO','','','');
INSERT INTO `table_columns` VALUES ('plugin_config',7,'version','varchar(10)','NO','','','');
INSERT INTO `table_columns` VALUES ('plugin_config',8,'last_updated','timestamp','YES','','','');
INSERT INTO `table_columns` VALUES ('plugin_config',8,'last_updated','timestamp','NO','','CURRENT_TIMESTAMP','');
INSERT INTO `table_columns` VALUES ('plugin_db_changes',1,'id','mediumint(8) unsigned','NO','PRI',NULL,'auto_increment');
INSERT INTO `table_columns` VALUES ('plugin_db_changes',2,'plugin','varchar(16)','NO','MUL','','');
INSERT INTO `table_columns` VALUES ('plugin_db_changes',3,'table','varchar(64)','NO','','','');
Expand Down Expand Up @@ -818,17 +818,17 @@ INSERT INTO `table_columns` VALUES ('poller_command',1,'poller_id','smallint(5)
INSERT INTO `table_columns` VALUES ('poller_command',2,'time','timestamp','NO','','0000-00-00 00:00:00','');
INSERT INTO `table_columns` VALUES ('poller_command',3,'action','tinyint(3) unsigned','NO','PRI','0','');
INSERT INTO `table_columns` VALUES ('poller_command',4,'command','varchar(191)','NO','PRI','','');
INSERT INTO `table_columns` VALUES ('poller_command',5,'last_updated','timestamp','NO','','current_timestamp()','on update current_timestamp()');
INSERT INTO `table_columns` VALUES ('poller_command',5,'last_updated','timestamp','NO','','CURRENT_TIMESTAMP','ON UPDATE CURRENT_TIMESTAMP');
INSERT INTO `table_columns` VALUES ('poller_data_template_field_mappings',1,'data_template_id','int(10) unsigned','NO','PRI','0','');
INSERT INTO `table_columns` VALUES ('poller_data_template_field_mappings',2,'data_name','varchar(40)','NO','PRI','','');
INSERT INTO `table_columns` VALUES ('poller_data_template_field_mappings',3,'data_source_names','varchar(125)','NO','PRI','','');
INSERT INTO `table_columns` VALUES ('poller_data_template_field_mappings',4,'last_updated','timestamp','NO','','current_timestamp()','on update current_timestamp()');
INSERT INTO `table_columns` VALUES ('poller_data_template_field_mappings',4,'last_updated','timestamp','NO','','CURRENT_TIMESTAMP','ON UPDATE CURRENT_TIMESTAMP');
INSERT INTO `table_columns` VALUES ('poller_item',1,'local_data_id','int(10) unsigned','NO','PRI','0','');
INSERT INTO `table_columns` VALUES ('poller_item',2,'poller_id','int(10) unsigned','NO','MUL','1','');
INSERT INTO `table_columns` VALUES ('poller_item',3,'host_id','mediumint(8) unsigned','NO','MUL','0','');
INSERT INTO `table_columns` VALUES ('poller_item',4,'action','tinyint(3) unsigned','NO','MUL','1','');
INSERT INTO `table_columns` VALUES ('poller_item',5,'present','tinyint(3) unsigned','NO','MUL','1','');
INSERT INTO `table_columns` VALUES ('poller_item',6,'last_updated','timestamp','NO','','current_timestamp()','on update current_timestamp()');
INSERT INTO `table_columns` VALUES ('poller_item',6,'last_updated','timestamp','NO','','CURRENT_TIMESTAMP','ON UPDATE CURRENT_TIMESTAMP');
INSERT INTO `table_columns` VALUES ('poller_item',7,'hostname','varchar(100)','NO','','','');
INSERT INTO `table_columns` VALUES ('poller_item',8,'snmp_community','varchar(100)','NO','','','');
INSERT INTO `table_columns` VALUES ('poller_item',9,'snmp_version','tinyint(3) unsigned','NO','','0','');
Expand Down Expand Up @@ -857,7 +857,7 @@ INSERT INTO `table_columns` VALUES ('poller_output_boost',1,'local_data_id','int
INSERT INTO `table_columns` VALUES ('poller_output_boost',2,'rrd_name','varchar(19)','NO','PRI','','');
INSERT INTO `table_columns` VALUES ('poller_output_boost',3,'time','timestamp','NO','PRI','0000-00-00 00:00:00','');
INSERT INTO `table_columns` VALUES ('poller_output_boost',4,'output','varchar(512)','NO','',NULL,'');
INSERT INTO `table_columns` VALUES ('poller_output_boost',5,'last_updated','timestamp','NO','','current_timestamp()','');
INSERT INTO `table_columns` VALUES ('poller_output_boost',5,'last_updated','timestamp','NO','','CURRENT_TIMESTAMP','');
INSERT INTO `table_columns` VALUES ('poller_output_boost_local_data_ids',1,'local_data_id','int(10) unsigned','NO','PRI','0','');
INSERT INTO `table_columns` VALUES ('poller_output_boost_local_data_ids',2,'process_handler','int(10) unsigned','YES','MUL','0','');
INSERT INTO `table_columns` VALUES ('poller_output_boost_processes',1,'sock_int_value','bigint(20) unsigned','NO','PRI',NULL,'auto_increment');
Expand Down Expand Up @@ -892,7 +892,7 @@ INSERT INTO `table_columns` VALUES ('processes',3,'tasktype','varchar(20)','NO',
INSERT INTO `table_columns` VALUES ('processes',4,'taskname','varchar(40)','NO','PRI','','');
INSERT INTO `table_columns` VALUES ('processes',5,'taskid','int(10) unsigned','NO','PRI','0','');
INSERT INTO `table_columns` VALUES ('processes',6,'timeout','int(10) unsigned','YES','','300','');
INSERT INTO `table_columns` VALUES ('processes',7,'started','timestamp','NO','','current_timestamp()','');
INSERT INTO `table_columns` VALUES ('processes',7,'started','timestamp','NO','','CURRENT_TIMESTAMP','');
INSERT INTO `table_columns` VALUES ('processes',8,'last_update','timestamp','NO','','0000-00-00 00:00:00','');
INSERT INTO `table_columns` VALUES ('reports',1,'id','mediumint(8) unsigned','NO','PRI',NULL,'auto_increment');
INSERT INTO `table_columns` VALUES ('reports',2,'user_id','mediumint(8) unsigned','NO','','0','');
Expand Down Expand Up @@ -941,7 +941,7 @@ INSERT INTO `table_columns` VALUES ('sessions',3,'access','int(10) unsigned','YE
INSERT INTO `table_columns` VALUES ('sessions',4,'data','mediumblob','YES','',NULL,'');
INSERT INTO `table_columns` VALUES ('sessions',5,'user_id','int(10) unsigned','NO','','0','');
INSERT INTO `table_columns` VALUES ('sessions',6,'user_agent','varchar(128)','NO','','','');
INSERT INTO `table_columns` VALUES ('sessions',7,'start_time','timestamp','NO','','current_timestamp()','');
INSERT INTO `table_columns` VALUES ('sessions',7,'start_time','timestamp','NO','','CURRENT_TIMESTAMP','');
INSERT INTO `table_columns` VALUES ('sessions',8,'transactions','int(10) unsigned','NO','','1','');
INSERT INTO `table_columns` VALUES ('settings',1,'name','varchar(75)','NO','PRI','','');
INSERT INTO `table_columns` VALUES ('settings',2,'value','varchar(4096)','NO','','','');
Expand Down Expand Up @@ -1097,7 +1097,7 @@ INSERT INTO `table_columns` VALUES ('user_auth',27,'tfa_secret','char(50)','YES'
INSERT INTO `table_columns` VALUES ('user_auth_cache',1,'id','int(10) unsigned','NO','PRI',NULL,'auto_increment');
INSERT INTO `table_columns` VALUES ('user_auth_cache',2,'user_id','int(10) unsigned','NO','MUL','0','');
INSERT INTO `table_columns` VALUES ('user_auth_cache',3,'hostname','varchar(100)','NO','MUL','','');
INSERT INTO `table_columns` VALUES ('user_auth_cache',4,'last_update','timestamp','NO','MUL','current_timestamp()','');
INSERT INTO `table_columns` VALUES ('user_auth_cache',4,'last_update','timestamp','NO','MUL','CURRENT_TIMESTAMP','');
INSERT INTO `table_columns` VALUES ('user_auth_cache',5,'token','varchar(191)','NO','UNI','','');
INSERT INTO `table_columns` VALUES ('user_auth_group',1,'id','int(10) unsigned','NO','PRI',NULL,'auto_increment');
INSERT INTO `table_columns` VALUES ('user_auth_group',2,'name','varchar(20)','NO','',NULL,'');
Expand Down Expand Up @@ -1128,7 +1128,7 @@ INSERT INTO `table_columns` VALUES ('user_auth_row_cache',1,'user_id','mediumint
INSERT INTO `table_columns` VALUES ('user_auth_row_cache',2,'class','varchar(20)','NO','PRI','','');
INSERT INTO `table_columns` VALUES ('user_auth_row_cache',3,'hash','varchar(32)','NO','PRI','','');
INSERT INTO `table_columns` VALUES ('user_auth_row_cache',4,'total_rows','int(10)','NO','','0','');
INSERT INTO `table_columns` VALUES ('user_auth_row_cache',5,'time','timestamp','NO','','current_timestamp()','');
INSERT INTO `table_columns` VALUES ('user_auth_row_cache',5,'time','timestamp','NO','','CURRENT_TIMESTAMP','');
INSERT INTO `table_columns` VALUES ('user_domains',1,'domain_id','int(10) unsigned','NO','PRI',NULL,'auto_increment');
INSERT INTO `table_columns` VALUES ('user_domains',2,'domain_name','varchar(20)','NO','',NULL,'');
INSERT INTO `table_columns` VALUES ('user_domains',3,'type','int(10) unsigned','NO','','0','');
Expand Down
6 changes: 3 additions & 3 deletions install/upgrades/1_3_0.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function upgrade_to_1_3_0() {
db_install_add_column('aggregate_graph_templates_graph', array('name' => 't_left_axis_format', 'type' => 'char(2)', 'default' => '0', 'after' => 'right_axis_formatter'));
db_install_add_column('aggregate_graph_templates_graph', array('name' => 'left_axis_format', 'type' => 'mediumint(8)', 'NULL' => true, 'after' => 't_left_axis_format'));

db_install_add_column('plugin_config', array('name' => 'last_updated', 'type' => 'timestamp', 'NULL' => true, 'after' => 'version'));
db_install_add_column('plugin_config', array('name' => 'last_updated', 'type' => 'timestamp', 'NULL' => false, 'default' => 'CURRENT_TIMESTAMP', 'after' => 'version'));

db_install_execute('UPDATE plugin_config SET last_updated = NOW() WHERE status IN (1,2,3,4) AND last_updated = NULL');

Expand All @@ -65,7 +65,7 @@ function upgrade_to_1_3_0() {
`readme` blob DEFAULT NULL,
`changelog` blob DEFAULT NULL,
`archive` longblob DEFAULT NULL,
`last_updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`last_updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`plugin`,`tag_name`))
ENGINE=InnoDB
ROW_FORMAT=DYNAMIC");
Expand Down Expand Up @@ -206,7 +206,7 @@ function upgrade_to_1_3_0() {

if (!db_column_exists('poller_output_boost', 'last_updated')) {
db_install_execute('ALTER TABLE poller_output_boost
ADD COLUMN last_updated timestamp NOT NULL default current_timestamp,
ADD COLUMN last_updated timestamp NOT NULL default CURRENT_TIMESTAMP,
ADD INDEX last_updated(last_updated)');
}

Expand Down
82 changes: 67 additions & 15 deletions plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -1091,30 +1091,36 @@ function displayFileDialog(url, dialogTitle, height, width) {
'sort' => 'ASC',
'tip' => __('The version of this Plugin.')
),
'pa.version' => array(
'display' => __('Archived Version'),
'align' => 'right',
'sort' => 'ASC',
'tip' => __('The version of this Plugin.')
),
'pa.archive_length' => array(
'display' => __('Archive Size'),
'align' => 'right',
'sort' => 'ASC',
'tip' => __('The compressed size of this Plugin in bytes.')
),
'requires' => array(
'display' => __('Archived Requires'),
'align' => 'right',
'sort' => 'ASC',
'tip' => __('This Plugin requires the following Plugins be installed first.')
),
'pa.version' => array(
'display' => __('Archived Version'),
'pa.last_updated' => array(
'display' => __('Archived Date'),
'align' => 'right',
'sort' => 'ASC',
'tip' => __('The version of this Plugin.')
'tip' => __('The date that this Plugin was Archived.')
),
'pi.last_updated' => array(
'display' => __('Last Installed/Upgraded'),
'align' => 'right',
'sort' => 'ASC',
'tip' => __('The date that this Plugin was last Installed or Upgraded.')
),
'pa.last_updated' => array(
'display' => __('Date Archived'),
'align' => 'right',
'sort' => 'ASC',
'tip' => __('The date that this Plugin was Archived.')
)
);

break;
Expand Down Expand Up @@ -1175,6 +1181,12 @@ function displayFileDialog(url, dialogTitle, height, width) {
'sort' => 'ASC',
'tip' => __('The Available version for install for this Plugin.')
),
'pa.archive_length' => array(
'display' => __('Available Size'),
'align' => 'right',
'sort' => 'ASC',
'tip' => __('The compressed size of this Plugin in bytes.')
),
'nosort3' => array(
'display' => __('Available Requires'),
'align' => 'right',
Expand Down Expand Up @@ -1385,7 +1397,7 @@ function format_plugin_row($plugin, $last_plugin, $include_ordering, $table) {
$requires = $plugin['requires'];
}

if ($plugin['last_updated'] == '') {
if ($plugin['last_updated'] == '0000-00-00 00:00:00') {
$last_updated = __('N/A');
} else {
$last_updated = substr($plugin['last_updated'], 0, 16);
Expand Down Expand Up @@ -1522,9 +1534,32 @@ function format_available_plugin_row($plugin, $table) {
$last_updated = substr($plugin['last_updated'], 0, 16);
}

$row .= "<td class='right'>" . $last_updated . '</td>';
$row .= "<td class='right'>" . html_escape($plugin['avail_tag_name']) . '</td>';
if ($plugin['avail_tag_name'] !== 'develop') {
$tag_version = str_replace('v', '', $plugin['avail_tag_name']);
} else {
$tag_version = $plugin['avail_tag_name'];
}

$row .= "<td class='right'>" . $last_updated . '</td>';
$row .= "<td class='right'>" . html_escape($tag_version) . '</td>';

$size = $plugin['archive_length'];
$suffix = '';

if ($size > 1024) {
$suffix = ' KB';
$size /= 1024;
}

if ($size > 1024) {
$suffix = ' MB';
$size /= 1024;
}

$row .= "<td class='right'>" . number_format_i18n($size, 1) . $suffix . '</td>';

$row .= "<td class='right'>" . html_escape($requires) . '</td>';

$row .= "<td class='right'>" . substr($plugin['avail_published'], 0, 16) . '</td>';

return $row;
Expand Down Expand Up @@ -1590,17 +1625,33 @@ function format_archive_plugin_row($plugin, $table) {
}

$row .= "<td class='nowrap'>" . filter_value($plugin['author'], get_request_var('filter')) . '</td>';
$row .= "<td class='right'>" . html_escape($plugin['archive_compat']) . '</td>';
$row .= "<td class='right'>" . html_escape($plugin['archive_compat']) . '</td>';

if ($plugin['version'] == '') {
$row .= "<td class='right'>" . __esc('Not Installed') . '</td>';
} else {
$row .= "<td class='right'>" . html_escape($plugin['version']) . '</td>';
}

$row .= "<td class='right'>" . html_escape($plugin['archive_requires']) . '</td>';
$row .= "<td class='right'>" . html_escape($plugin['archive_version']) . '</td>';

$size = $plugin['archive_length'];
$suffix = '';

if ($size > 1024) {
$suffix = ' KB';
$size /= 1024;
}

if ($size > 1024) {
$suffix = ' MB';
$size /= 1024;
}

$row .= "<td class='right'>" . number_format_i18n($size, 1) . $suffix . '</td>';

$row .= "<td class='right'>" . html_escape($plugin['archive_requires']) . '</td>';

if ($plugin['last_updated'] == '') {
$last_updated = __('N/A');
} else {
Expand All @@ -1609,9 +1660,10 @@ function format_archive_plugin_row($plugin, $table) {

$archive_date = substr($plugin['archive_date'], 0, 16);

$row .= "<td class='right'>" . $last_updated . '</td>';
$row .= "<td class='right'>" . $archive_date . '</td>';

$row .= "<td class='right'>" . $last_updated . '</td>';

return $row;
}

Expand Down

0 comments on commit e9f057b

Please sign in to comment.