Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Convert DateTimes in database to integer types.

  • Loading branch information...
commit 51051c75143a3cadd312ea68e3a6edc849b21b1e 1 parent 820c573
@grangeway grangeway authored
Showing with 289 additions and 221 deletions.
  1. +9 −2 admin/install.php
  2. +31 −0 admin/install_functions.php
  3. +30 −0 admin/install_helper_functions.php
  4. +123 −0 admin/schema.php
  5. +1 −1  api/soap/mc_issue_api.php
  6. +2 −2 api/soap/mc_project_api.php
  7. +3 −3 bug_graph_bycategory.php
  8. +3 −3 bug_graph_bystatus.php
  9. +1 −1  bug_report.php
  10. +1 −1  bug_revision_view_page.php
  11. +2 −2 bug_update.php
  12. +15 −22 core/bug_api.php
  13. +1 −1  core/bug_revision_api.php
  14. +17 −11 core/bugnote_api.php
  15. +2 −112 core/database_api.php
  16. +1 −1  core/date_api.php
  17. +1 −1  core/email_api.php
  18. +0 −1  core/email_queue_api.php
  19. +1 −1  core/file_api.php
  20. +3 −3 core/graph_api.php
  21. +1 −1  core/history_api.php
  22. +1 −4 core/news_api.php
  23. +0 −2  core/sponsorship_api.php
  24. +1 −1  core/string_api.php
  25. +4 −4 core/summary_api.php
  26. +3 −3 core/tokens_api.php
  27. +2 −6 core/version_api.php
  28. +1 −1  file_download.php
  29. +2 −2 graphs/graph_by_cumulative.php
  30. +2 −2 graphs/graph_by_daily_delta.php
  31. +1 −1  main_page.php
  32. +1 −1  manage_proj_ver_copy.php
  33. +2 −4 manage_tags_page.php
  34. +7 −7 manage_user_page.php
  35. +1 −1  manage_user_prune.php
  36. +2 −2 print_bug_page.php
  37. +3 −3 print_bugnote_inc.php
  38. +1 −1  proj_doc_page.php
  39. +3 −3 summary_page.php
  40. +2 −2 tag_update_page.php
  41. +2 −2 tag_view_page.php
View
11 admin/install.php
@@ -723,8 +723,11 @@ function InsertData( $p_table, $p_data ) {
$t_target = $upgrade[$i][1];
} else if( $upgrade[$i][0] == 'UpdateFunction' ) {
$sqlarray = array(
- $upgrade[$i][1],
+ $upgrade[$i][1],
);
+ if( isset( $upgrade[$i][2] ) ) {
+ $sqlarray[] = $upgrade[$i][2];
+ }
$t_sql = false;
$t_target = $upgrade[$i][1];
} else {
@@ -748,7 +751,11 @@ function InsertData( $p_table, $p_data ) {
if( $t_sql ) {
$ret = $dict->ExecuteSQLArray( $sqlarray );
} else {
- $ret = call_user_func( 'install_' . $sqlarray[0] );
+ if( isset( $sqlarray[1] ) ) {
+ $ret = call_user_func( 'install_' . $sqlarray[0], $sqlarray[1] );
+ } else {
+ $ret = call_user_func( 'install_' . $sqlarray[0] );
+ }
}
if( $ret == 2 ) {
print_test_result( GOOD );
View
31 admin/install_functions.php
@@ -77,3 +77,34 @@ function install_category_migrate() {
# return 2 because that's what ADOdb/DataDict does when things happen properly
return 2;
}
+
+function install_date_migrate( $p_data) {
+ // $p_data[0] = tablename, [1] id column, [2] = old column, [3] = new column
+
+ $t_table = db_get_table( $p_data[0] );
+ $t_id_column = $p_data[1];
+ $t_old_column = $p_data[2];
+ $t_new_column = $p_data[3];
+
+ $query = "SELECT $t_id_column, $t_old_column FROM $t_table";
+ $t_result = db_query_bound( $query );
+
+ while( $row = db_fetch_array( $t_result ) ) {
+ $t_id = $row[$t_id_column];
+ $t_old_value = $row[$t_old_column];
+
+ $t_new_value = db_unixtimestamp($t_old_value);
+ if ($t_new_value < 100000 ) {
+ $t_new_value = 1;
+ }
+
+ $query = "UPDATE $t_table SET $t_new_column=" . db_param() . "
+ WHERE $t_id_column =" . db_param();
+
+ db_query_bound( $query, array( $t_new_value, $t_id ) );
+ }
+
+ # return 2 because that's what ADOdb/DataDict does when things happen properly
+ return 2;
+
+}
View
30 admin/install_helper_functions.php
@@ -36,3 +36,33 @@ function check_php_version( $p_version ) {
}
}
}
+
+/**
+ * legacy pre-1.2 date function used by schema.php
+ * return a DB compatible date, representing a unixtime(0) + 1 second. Internally considered a NULL date
+ * @return string Formatted Date for DB insertion e.g. 1970-01-01 00:00:00 ready for database insertion
+ */
+function db_null_date() {
+ global $g_db;
+
+ return $g_db->BindTimestamp( $g_db->UserTimeStamp( 1, 'Y-m-d H:i:s', true ) );
+}
+
+/**
+ * legacy pre-1.2 date function used by install_functions.php
+ * generate a integer unixtimestamp of a date
+ * @param $p_date Date
+ * @param bool $p_gmt whether to use GMT or current timezone (default false)
+ * @return int unix timestamp of a date
+ * @todo review date handling
+ */
+function db_unixtimestamp( $p_date = null, $p_gmt = false ) {
+ global $g_db;
+
+ if( null !== $p_date ) {
+ $p_timestamp = $g_db->UnixTimeStamp( $p_date, $p_gmt );
+ } else {
+ $p_timestamp = time();
+ }
+ return $p_timestamp;
+}
View
123 admin/schema.php
@@ -25,6 +25,12 @@
# An update identifier is inferred from the ordering of this table. ONLY ADD NEW CHANGES TO THE
# END OF THE TABLE!!!
+if ( !function_exists( 'db_null_date' ) ) {
+ function db_null_date() {
+ return 0;
+ }
+}
+
$upgrade[] = Array('CreateTableSQL',Array(db_get_table( 'mantis_config_table' ),"
config_id C(64) NOTNULL PRIMARY,
project_id I DEFAULT '0' PRIMARY,
@@ -422,3 +428,120 @@
$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_bug_rev_id_time', db_get_table( 'mantis_bug_revision_table' ), 'bug_id, timestamp' ) );
$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_bug_rev_type', db_get_table( 'mantis_bug_revision_table' ), 'type' ) );
+#date conversion
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "
+ date_submitted_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_table', 'id', 'date_submitted', 'date_submitted_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "date_submitted" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "date_submitted_int", "date_submitted", "date_submitted_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "
+ due_date_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_table', 'id', 'due_date', 'due_date_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "due_date" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "due_date_int", "due_date", "due_date_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array('CreateIndexSQL',Array('idx_last_mod',db_get_table( 'mantis_bugnote_table' ),'last_modified', array('DROP')), Array( 'db_index_exists', Array( db_get_table('mantis_bugnote_table'), 'idx_last_mod')));
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "
+ last_modified_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bugnote_table', 'id', 'last_modified', 'last_modified_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "last_modified" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "last_modified_int", "last_modified", "last_modified_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array('CreateIndexSQL',Array('idx_last_mod',db_get_table('mantis_bugnote_table'),'last_modified'));
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "
+ last_updated_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_table', 'id', 'last_updated', 'last_updated_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "last_updated" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "last_updated_int", "last_updated", "last_updated_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_file_table' ), "
+ date_added_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_file_table', 'id', 'date_added', 'date_added_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_file_table' ), "date_added" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_file_table' ), "date_added_int", "date_added", "date_added_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "
+ date_submitted_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bugnote_table', 'id', 'date_submitted', 'date_submitted_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "date_submitted" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "date_submitted_int", "date_submitted", "date_submitted_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_file_table' ), "
+ date_added_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_project_file_table', 'id', 'date_added', 'date_added_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_project_file_table' ), "date_added" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_project_file_table' ), "date_added_int", "date_added", "date_added_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "
+ date_modified_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_history_table', 'id', 'date_modified', 'date_modified_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "date_modified" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "date_modified_int", "date_modified", "date_modified_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_user_table' ), "
+ last_visit_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_user_table', 'id', 'last_visit', 'last_visit_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_user_table' ), "last_visit" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_user_table' ), "last_visit_int", "last_visit", "last_visit_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_email_table' ), "
+ submitted_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_email_table', 'email_id', 'submitted', 'submitted_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_email_table' ), "submitted" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_email_table' ), "submitted_int", "submitted", "submitted_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "
+ date_created_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_tag_table', 'id', 'date_created', 'date_created_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "date_created" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "date_created_int", "date_created", "date_created_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "
+ date_updated_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_tag_table', 'id', 'date_updated', 'date_updated_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "date_updated" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "date_updated_int", "date_updated", "date_updated_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_tag_table' ), "
+ date_attached_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_tag_table', 'bug_id', 'date_attached', 'date_attached_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_tag_table' ), "date_attached" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_tag_table' ), "date_attached_int", "date_attached", "date_attached_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "
+ timestamp_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_tokens_table', 'id', 'timestamp', 'timestamp_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "timestamp" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "timestamp_int", "timestamp", "timestamp_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "
+ expiry_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_tokens_table', 'id', 'expiry', 'expiry_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "expiry" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "expiry_int", "expiry", "expiry_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_user_table' ), "
+ date_created_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_user_table', 'id', 'date_created', 'date_created_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_user_table' ), "date_created" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_user_table' ), "date_created_int", "date_created", "date_created_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_news_table' ), "
+ last_modified_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_news_table', 'id', 'last_modified', 'last_modified_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_news_table' ), "last_modified" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_news_table' ), "last_modified_int", "last_modified", "last_modified_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_news_table' ), "
+ date_posted_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_news_table', 'id', 'date_posted', 'date_posted_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_news_table' ), "date_posted" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_news_table' ), "date_posted_int", "date_posted", "date_posted_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_revision_table' ), "
+ timestamp_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_revision_table', 'id', 'timestamp', 'timestamp_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_revision_table' ), "timestamp" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_revision_table' ), "timestamp_int", "timestamp", "timestamp_int I UNSIGNED NOTNULL DEFAULT '1' " ) );
View
2  api/soap/mc_issue_api.php
@@ -201,7 +201,7 @@ function mci_issue_get_attachments( $p_issue_id ) {
$t_attachment['filename'] = $t_attachment_row['filename'];
$t_attachment['size'] = $t_attachment_row['filesize'];
$t_attachment['content_type'] = $t_attachment_row['file_type'];
- $t_attachment['date_submitted'] = timestamp_to_iso8601( db_unixtimestamp( $t_attachment_row['date_added'] ) );
+ $t_attachment['date_submitted'] = timestamp_to_iso8601( $t_attachment_row['date_added'] );
$t_attachment['download_url'] = mci_get_mantis_path() . 'file_download.php?file_id=' . $t_attachment_row['id'] . '&amp;type=bug';
$t_result[] = $t_attachment;
}
View
4 api/soap/mc_project_api.php
@@ -212,7 +212,7 @@ function mc_project_get_released_versions( $p_username, $p_password, $p_project_
'id' => $t_version['id'],
'name' => $t_version['version'],
'project_id' => $p_project_id,
- 'date_order' => timestamp_to_iso8601( db_unixtimestamp( $t_version['date_order'] ) ),
+ 'date_order' => timestamp_to_iso8601( $t_version['date_order'] ),
'description' => mci_null_if_empty( $t_version['description'] ),
'released' => $t_version['released'],
);
@@ -577,7 +577,7 @@ function mc_project_get_attachments( $p_username, $p_password, $p_project_id ) {
$t_attachment['description'] = $row['description'];
$t_attachment['size'] = $row['filesize'];
$t_attachment['content_type'] = $row['file_type'];
- $t_attachment['date_submitted'] = timestamp_to_iso8601( db_unixtimestamp( $row['date_added'] ) );
+ $t_attachment['date_submitted'] = timestamp_to_iso8601( $row['date_added'] );
$t_attachment['download_url'] = mci_get_mantis_path() . 'file_download.php?file_id=' . $row['id'] . '&amp;type=doc';
$t_result[] = $t_attachment;
}
View
6 bug_graph_bycategory.php
@@ -107,14 +107,14 @@
' WHERE bug_id in ('.implode(',', $t_bug).') and '.
'( (type='.NORMAL_TYPE.' and field_name=\'category\') or '.
'(type='.NORMAL_TYPE.' and field_name=\'status\') or type='.NEW_BUG.' ) and '.
- 'date_modified >= \''.db_date( $t_start ).'\''.
+ 'date_modified >= \''. $t_start .'\''.
' order by date_modified DESC';
$t_result = db_query( $t_select );
$row = db_fetch_array( $t_result );
for ($t_now = time() - $t_incr; $t_now >= $t_start; $t_now -= $t_incr) {
// walk through the data points and use the data retrieved to update counts
- while( ( $row !== false ) && ( db_unixtimestamp($row['date_modified']) >= $t_now ) ) {
+ while( ( $row !== false ) && ( $row['date_modified'] >= $t_now ) ) {
switch ($row['type']) {
case 0: // updated bug
if ($row['field_name'] == 'category') {
@@ -211,7 +211,7 @@
}
echo '</tr>';
for ($t_ptr=0; $t_ptr<$t_bin_count; $t_ptr++) {
- echo '<tr class="row-'.($t_ptr%2+1).'"><td>'.$t_ptr.' ('.db_date( $t_marker[$t_ptr] ).')'.'</td>';
+ echo '<tr class="row-'.($t_ptr%2+1).'"><td>'.$t_ptr.' ('. $t_marker[$t_ptr] .')'.'</td>';
foreach ( $t_category as $t_cat ) {
echo '<td>'.(isset($t_data[$t_ptr][$t_cat]) ? $t_data[$t_ptr][$t_cat] : 0).'</td>';
}
View
6 bug_graph_bystatus.php
@@ -99,14 +99,14 @@
$t_select = 'SELECT bug_id, type, old_value, new_value, date_modified FROM '.$t_bug_hist_table.
' WHERE bug_id in ('.implode(',', $t_bug).
') and ( (type='.NORMAL_TYPE.' and field_name=\'status\')
- or type='.NEW_BUG.' ) and date_modified >= \''.db_date( $t_start ).'\''.
+ or type='.NEW_BUG.' ) and date_modified >= \''. $t_start .'\''.
' order by date_modified DESC';
$t_result = db_query( $t_select );
$t_row = db_fetch_array( $t_result );
for ($t_now = time() - $t_incr; $t_now >= $t_start; $t_now -= $t_incr) {
// walk through the data points and use the data retrieved to update counts
- while( ( $t_row !== false ) && ( db_unixtimestamp($t_row['date_modified']) >= $t_now ) ) {
+ while( ( $t_row !== false ) && ( $t_row['date_modified'] >= $t_now ) ) {
switch ($t_row['type']) {
case 0: // updated bug
if ( isset( $t_data[$t_ptr][$t_row['new_value']] ) ) {
@@ -222,7 +222,7 @@
}
}
if ( $f_show_as_table ) {
- echo '<tr class="row-'.($t_ptr%2+1).'"><td>'.$t_ptr.' ('.db_date( $t_metrics[0][$t_ptr] ).')'.'</td>';
+ echo '<tr class="row-'.($t_ptr%2+1).'"><td>'.$t_ptr.' ('. $t_metrics[0][$t_ptr] .')'.'</td>';
for ( $i=1; $i<=$t_label_count; $i++ ) {
echo '<td>'.$t_metrics[$i][$t_ptr].'</td>';
}
View
2  bug_report.php
@@ -64,7 +64,7 @@
if ( is_blank ( $t_bug_data->due_date ) ) {
$t_bug_data->due_date = date_get_null();
} else {
- $t_bug_data->due_date = db_unixtimestamp ( $t_bug_data->due_date, true ) + 1;
+ $t_bug_data->due_date = $t_bug_data->due_date;
}
$f_file = gpc_get_file( 'file', null ); /** @todo (thraxisp) Note that this always returns a structure */
View
2  bug_revision_view_page.php
@@ -98,7 +98,7 @@ function show_revision( $t_revision ) {
$t_label = '';
}
-$t_by_string = sprintf( lang_get( 'revision_by' ), string_display_line( $t_revision['timestamp'] ), user_get_name( $t_revision['user_id'] ) );
+$t_by_string = sprintf( lang_get( 'revision_by' ), string_display_line( date( config_get( 'normal_date_format' ), $t_revision['timestamp'] ) ), user_get_name( $t_revision['user_id'] ) );
?>
<tr class="spacer"><td><a name="r<?php echo $t_revision['id'] ?>"></a></td></tr>
View
4 bug_update.php
@@ -82,9 +82,9 @@
$t_bug_data->due_date = gpc_get_string( 'due_date', $t_bug_data->due_date);
if ( is_blank ( $t_bug_data->due_date ) ) {
- $t_bug_data->due_date = date_get_null();
+ $t_bug_data->due_date = 1;
} else {
- $t_bug_data->due_date = db_unixtimestamp ( $t_bug_data->due_date, true ) + 1;
+ $t_bug_data->due_date = $t_bug_data->due_date;
}
$t_bug_data->description = gpc_get_string( 'description', $t_bug_data->description );
View
37 core/bug_api.php
@@ -221,15 +221,6 @@ function bug_cache_array_rows( $p_bug_id_array ) {
function bug_add_to_cache( $p_bug_row, $p_stats = null ) {
global $g_cache_bug;
- if( !is_int( $p_bug_row['date_submitted'] ) ) {
- $p_bug_row['date_submitted'] = db_unixtimestamp( $p_bug_row['date_submitted'] );
- }
- if( !is_int( $p_bug_row['last_updated'] ) ) {
- $p_bug_row['last_updated'] = db_unixtimestamp( $p_bug_row['last_updated'] );
- }
- if( !is_int( $p_bug_row['due_date'] ) ) {
- $p_bug_row['due_date'] = db_unixtimestamp( $p_bug_row['due_date'] );
- }
$g_cache_bug[(int) $p_bug_row['id']] = $p_bug_row;
if( !is_null( $p_stats ) ) {
@@ -423,7 +414,7 @@ function bug_is_resolved( $p_bug_id ) {
function bug_is_overdue( $p_bug_id ) {
$t_due_date = bug_get_field( $p_bug_id, 'due_date' );
if( !date_is_null( $t_due_date ) ) {
- $t_now = db_unixtimestamp();
+ $t_now = db_now();
if( $t_now > $t_due_date ) {
if( !bug_is_resolved( $p_bug_id ) ) {
return true;
@@ -534,7 +525,7 @@ function bug_create( $p_bug_data ) {
# check due_date format
if( !is_blank( $p_bug_data->due_date ) ) {
- $c_due_date = db_bind_timestamp( $p_bug_data->due_date, true );
+ $c_due_date = $p_bug_data->due_date;
} else {
$c_due_date = date_get_null();
}
@@ -684,8 +675,8 @@ function bug_copy( $p_bug_id, $p_target_project_id = null, $p_copy_custom_fields
bug_set_field( $t_new_bug_id, 'status', $t_bug_data->status );
bug_set_field( $t_new_bug_id, 'resolution', $t_bug_data->resolution );
bug_set_field( $t_new_bug_id, 'projection', $t_bug_data->projection );
- bug_set_field( $t_new_bug_id, 'date_submitted', $t_mantis_db->DBTimeStamp( $t_bug_data->date_submitted ), false );
- bug_set_field( $t_new_bug_id, 'last_updated', $t_mantis_db->DBTimeStamp( $t_bug_data->last_updated ), false );
+ bug_set_field( $t_new_bug_id, 'date_submitted', $t_bug_data->date_submitted );
+ bug_set_field( $t_new_bug_id, 'last_updated', $t_bug_data->last_updated );
bug_set_field( $t_new_bug_id, 'eta', $t_bug_data->eta );
bug_set_field( $t_new_bug_id, 'fixed_in_version', $t_bug_data->fixed_in_version );
bug_set_field( $t_new_bug_id, 'target_version', $t_bug_data->target_version );
@@ -989,9 +980,9 @@ function bug_update( $p_bug_id, $p_bug_data, $p_update_extended = false, $p_bypa
}
if( !is_blank( $p_bug_data->due_date ) ) {
- $c_due_date = db_bind_timestamp( $p_bug_data->due_date, true );
+ $c_due_date = $p_bug_data->due_date;
} else {
- $c_due_date = db_null_date();
+ $c_due_date = date_get_null();
}
$t_old_data = bug_get( $p_bug_id, true );
@@ -1096,7 +1087,7 @@ function bug_update( $p_bug_id, $p_bug_data, $p_update_extended = false, $p_bypa
history_log_event_direct( $p_bug_id, 'sponsorship_total', $t_old_data->sponsorship_total, $p_bug_data->sponsorship_total );
history_log_event_direct( $p_bug_id, 'sticky', $t_old_data->sticky, $p_bug_data->sticky );
- history_log_event_direct( $p_bug_id, 'due_date', ( $t_old_data->due_date != db_unixtimestamp( db_null_date() ) ) ? $t_old_data->due_date : null, ( $p_bug_data->due_date != db_unixtimestamp( db_null_date() ) ) ? $p_bug_data->due_date : null );
+ history_log_event_direct( $p_bug_id, 'due_date', ( $t_old_data->due_date != date_get_null() ) ? $t_old_data->due_date : null, ( $p_bug_data->due_date != date_get_null() ) ? $p_bug_data->due_date : null );
# Update extended info if requested
if( $p_update_extended ) {
@@ -1338,7 +1329,7 @@ function bug_get_newest_bugnote_timestamp( $p_bug_id ) {
if( false === $row ) {
return false;
} else {
- return db_unixtimestamp( $row );
+ return $row;
}
}
@@ -1359,8 +1350,7 @@ function bug_get_bugnote_stats( $p_bug_id ) {
if( $g_cache_bug[$c_bug_id]['_stats'] === false ) {
return false;
} else {
- $t_stats['last_modified'] = db_unixtimestamp( $g_cache_bug[$c_bug_id]['_stats']['last_modified'] );
- $t_stats['count'] = $g_cache_bug[$c_bug_id]['_stats']['count'];
+ $t_stats = $g_cache_bug[$c_bug_id]['_stats'];
}
return $t_stats;
}
@@ -1378,7 +1368,7 @@ function bug_get_bugnote_stats( $p_bug_id ) {
return false;
}
- $t_stats['last_modified'] = db_unixtimestamp( $row['last_modified'] );
+ $t_stats['last_modified'] = $row['last_modified'];
$t_stats['count'] = db_num_rows( $result );
return $t_stats;
@@ -1477,8 +1467,11 @@ function bug_set_field( $p_bug_id, $p_field_name, $p_value ) {
# dates
case 'last_updated':
case 'date_submitted':
- case 'due_date':
- $c_value = db_bind_timestamp( $p_value );
+ case 'due_date':
+ if ( !is_numeric( $p_value ) ) {
+ trigger_error( ERROR_GENERIC, ERROR );
+ }
+ $c_value = $p_value;
break;
default:
View
2  core/bug_revision_api.php
@@ -52,7 +52,7 @@ function bug_revision_add( $p_bug_id, $p_user_id, $p_type, $p_value, $p_bugnote_
if ( $p_timestamp === null ) {
$t_timestamp = db_now();
} else {
- $t_timestamp = db_bind_timestamp($p_timestamp);
+ $t_timestamp = $p_timestamp;
}
$t_query = "INSERT INTO $t_bug_rev_table (
View
28 core/bugnote_api.php
@@ -430,8 +430,8 @@ function bugnote_get_all_bugnotes( $p_bug_id, $p_user_bugnote_order, $p_user_bug
$t_bugnote->note = $row['note'];
$t_bugnote->view_state = $row['view_state'];
$t_bugnote->reporter_id = $row['reporter_id'];
- $t_bugnote->date_submitted = db_unixtimestamp( $row['date_submitted'] );
- $t_bugnote->last_modified = db_unixtimestamp( $row['last_modified'] );
+ $t_bugnote->date_submitted = $row['date_submitted'];
+ $t_bugnote->last_modified = $row['last_modified'];
$t_bugnote->note_type = $row['note_type'];
$t_bugnote->note_attr = $row['note_attr'];
$t_bugnote->time_tracking = $row['time_tracking'];
@@ -577,20 +577,20 @@ function bugnote_format_id( $p_bugnote_id ) {
*/
function bugnote_stats_get_events_array( $p_bug_id, $p_from, $p_to ) {
$c_bug_id = db_prepare_int( $p_bug_id );
- $c_from = db_bind_timestamp( $p_from . ' 00:00:00' );
- $c_to = db_bind_timestamp( $p_to . ' 23:59:59' );
+ $c_to = strtotime( $p_to, 86399); // @23:59:59
+ $c_from = strtotime( $p_from );
$t_user_table = db_get_table( 'mantis_user_table' );
$t_bugnote_table = db_get_table( 'mantis_bugnote_table' );
if( !is_blank( $c_from ) ) {
- $t_from_where = " AND bn.date_submitted >= '$c_from '";
+ $t_from_where = " AND bn.date_submitted >= $c_from ";
} else {
$t_from_where = '';
}
if( !is_blank( $c_to ) ) {
- $t_to_where = " AND bn.date_submitted <= '$c_to '";
+ $t_to_where = " AND bn.date_submitted <= $c_to ";
} else {
$t_to_where = '';
}
@@ -624,23 +624,29 @@ function bugnote_stats_get_events_array( $p_bug_id, $p_from, $p_to ) {
*/
function bugnote_stats_get_project_array( $p_project_id, $p_from, $p_to, $p_cost ) {
$c_project_id = db_prepare_int( $p_project_id );
- $c_to = db_bind_timestamp( $p_to . ' 23:59:59' );
- $c_from = db_bind_timestamp( $p_from . ' 00:00:00' );
+
+ $c_to = strtotime( $p_to, 86399); // @23:59:59
+ $c_from = strtotime( $p_from );
+
+ if ( $c_to === false || $c_form === false ) {
+ error_parameters( array( $p_form, $p_to ) );
+ trigger_error( ERROR_GENERIC, ERROR );
+ }
+
$c_cost = db_prepare_double( $p_cost );
- // MySQL
$t_bug_table = db_get_table( 'mantis_bug_table' );
$t_user_table = db_get_table( 'mantis_user_table' );
$t_bugnote_table = db_get_table( 'mantis_bugnote_table' );
if( !is_blank( $c_from ) ) {
- $t_from_where = " AND bn.date_submitted >= '$c_from'";
+ $t_from_where = " AND bn.date_submitted >= $c_from";
} else {
$t_from_where = '';
}
if( !is_blank( $c_to ) ) {
- $t_to_where = " AND bn.date_submitted <= '$c_to'";
+ $t_to_where = " AND bn.date_submitted <= $c_to";
} else {
$t_to_where = '';
}
View
114 core/database_api.php
@@ -738,31 +738,6 @@ function db_prepare_binary_string( $p_string ) {
}
/**
- * prepare a date for binding in the format database accepts.
- * @param string|int $p_date can be a Unix integer timestamp or an ISO format Y-m-d. If null or false or '' is passed in, it will be converted to an SQL null.
- * @return string Formatted Date for DB insertion e.g. 1970-01-01 ready for database insertion
- */
-function db_bind_date( $p_date ) {
- global $g_db;
- return $g_db->BindDate( $p_date );
-}
-
-/**
- * prepare a date/time for binding in the format database accepts.
- * @param string|int $p_date can be a Unix integer timestamp or an ISO format Y-m-d h:m:s. If null or false or '' is passed in, it will be converted to an SQL null.
- * @param bool $p_gmt whether to use GMT or current timezone (default false)
- * @return string Formatted Date for DB insertion e.g. 1970-01-01 00:00:00 ready for database insertion
- */
-function db_bind_timestamp( $p_date, $p_gmt = false ) {
- global $g_db;
- if( $p_gmt ) {
- return $g_db->BindTimestamp( $g_db->UserTimeStamp( $p_date, 'Y-m-d H:i:s', true ) );
- } else {
- return $g_db->BindTimeStamp( $p_date );
- }
-}
-
-/**
* prepare a int for database insertion.
* @param int $p_int integer
* @return int integer
@@ -803,71 +778,7 @@ function db_prepare_bool( $p_bool ) {
function db_now() {
global $g_db;
- return $g_db->BindTimeStamp( time() );
-}
-
-/**
- * generate a date/time in database format of a date
- * @param $p_date Date
- * @param bool $p_gmt whether to use GMT or current timezone (default false)
- * @return string Formatted Date for DB insertion e.g. 1970-01-01 00:00:00 ready for database insertion
- * @todo review date handling
- */
-function db_timestamp( $p_date = null, $p_gmt = false ) {
- global $g_db;
-
- if( null !== $p_date ) {
- $p_timestamp = $g_db->UnixTimeStamp( $p_date, $p_gmt );
- } else {
- $p_timestamp = time();
- }
- return $g_db->BindTimeStamp( $p_timestamp );
-}
-
-/**
- * generate a integer unixtimestamp of a date
- * @param $p_date Date
- * @param bool $p_gmt whether to use GMT or current timezone (default false)
- * @return int unix timestamp of a date
- * @todo review date handling
- */
-function db_unixtimestamp( $p_date = null, $p_gmt = false ) {
- global $g_db;
-
- if( null !== $p_date ) {
- $p_timestamp = $g_db->UnixTimeStamp( $p_date, $p_gmt );
- } else {
- $p_timestamp = time();
- }
- return $p_timestamp;
-}
-
-/**
- * convert unix timestamp to db compatible date
- * @param $p_timestamp Date
- * @param bool $p_gmt whether to use GMT or current timezone (default false)
- * @return string Formatted Date
- * @todo review date handling
- */
-function db_date( $p_timestamp = null, $p_gmt = false ) {
- global $g_db;
-
- if( null !== $p_timestamp ) {
- $p_date = $g_db->UserTimeStamp( $p_timestamp, 'Y-m-d H:i:s', $p_gmt );
- } else {
- $p_date = $g_db->UserTimeStamp( time(), 'Y-m-d H:i:s', $p_gmt );
- }
- return $p_date;
-}
-
-/**
- * return a DB compatible date, representing a unixtime(0) + 1 second. Internally considered a NULL date
- * @return string Formatted Date for DB insertion e.g. 1970-01-01 00:00:00 ready for database insertion
- */
-function db_null_date() {
- global $g_db;
-
- return $g_db->BindTimestamp( $g_db->UserTimeStamp( 1, 'Y-m-d H:i:s', true ) );
+ return time();
}
/**
@@ -918,29 +829,8 @@ function db_helper_compare_days( $p_date1_id_or_column, $p_date2_id_or_column, $
if( is_int( $p_date2_id_or_column ) ) {
$p_date2 = db_param();
}
- switch( $t_db_type ) {
- case 'mssql':
- case 'odbc_mssql':
- case 'ado_mssql':
- return "(DATEDIFF(day, $p_date2, $p_date1) " . $p_limitstring . ")";
- case 'mysql':
- case 'mysqli':
- return "(TO_DAYS($p_date1) - TO_DAYS($p_date2) " . $p_limitstring . ")";
- case 'postgres':
- case 'postgres64':
- case 'postgres7':
- case 'pgsql':
- return "(date_mi($p_date1::date, $p_date2::date) " . $p_limitstring . ")";
- case 'oci8':
- return "(($p_date1 - $p_date2)" . $p_limitstring . ")";
- case 'db2':
- // all DB2 UDB use days function
- return "(days($p_date1) - days($p_date2) " . $p_limitstring . ")";
- default:
- error_parameters( 'db_type', $t_db_type );
- trigger_error( ERROR_CONFIG_OPT_INVALID, ERROR );
- }
+ return "(($p_date1 - $p_date2)" . $p_limitstring . ")";
}
/**
View
2  core/date_api.php
@@ -38,7 +38,7 @@ function date_is_null( $p_date ) {
* @access public
*/
function date_get_null() {
- return db_unixtimestamp( db_null_date() );
+ return 1;
}
/**
View
2  core/email_api.php
@@ -289,7 +289,7 @@ function email_collect_recipients( $p_bug_id, $p_notify_type, $p_extra_user_ids_
# add users who contributed bugnotes
$t_bugnote_id = bugnote_get_latest_id( $p_bug_id );
$t_bugnote_view = bugnote_get_field( $t_bugnote_id, 'view_state' );
- $t_bugnote_date = db_unixtimestamp( bugnote_get_field( $t_bugnote_id, 'last_modified' ) );
+ $t_bugnote_date = bugnote_get_field( $t_bugnote_id, 'last_modified' );
$t_bug_date = bug_get_field( $p_bug_id, 'last_updated' );
$t_bugnote_table = db_get_table( 'mantis_bugnote_table' );
View
1  core/email_queue_api.php
@@ -97,7 +97,6 @@ function email_queue_row_to_object( $p_row ) {
}
$t_row = $p_row;
- $t_row['submitted'] = db_unixtimestamp( $t_row['submitted'] );
$t_row['metadata'] = unserialize( $t_row['metadata'] );
$t_email_data = new EmailData;
View
2  core/file_api.php
@@ -284,7 +284,7 @@ function file_get_visible_attachments( $p_bug_id ) {
$t_attachment['id'] = $t_id;
$t_attachment['display_name'] = file_get_display_name( $t_filename );
$t_attachment['size'] = $t_filesize;
- $t_attachment['date_added'] = db_unixtimestamp( $t_date_added );
+ $t_attachment['date_added'] = $t_date_added;
$t_attachment['can_download'] = $t_can_download;
$t_attachment['diskfile'] = $t_diskfile;
View
6 core/graph_api.php
@@ -615,7 +615,7 @@ function create_cumulative_bydate() {
$row = db_fetch_array( $result );
# rationalise the timestamp to a day to reduce the amount of data
- $t_date = db_unixtimestamp( $row['date_submitted'] );
+ $t_date = $row['date_submitted'];
$t_date = (int)( $t_date / 86400 );
if( isset( $metrics[$t_date] ) ) {
@@ -649,10 +649,10 @@ function create_cumulative_bydate() {
# if h_last_updated is NULL, there were no appropriate history records
# (i.e. pre 0.18 data), use last_updated from bug table instead
if( NULL == $row['date_modified'] ) {
- $t_date = db_unixtimestamp( $row['last_updated'] );
+ $t_date = $row['last_updated'];
} else {
if( $t_res_val > $row['old_value'] ) {
- $t_date = db_unixtimestamp( $row['date_modified'] );
+ $t_date = $row['date_modified'];
}
}
if( $t_id <> $t_last_id ) {
View
2  core/history_api.php
@@ -185,7 +185,7 @@ function history_get_raw_events_array( $p_bug_id, $p_user_id = null ) {
}
}
- $raw_history[$j]['date'] = db_unixtimestamp( $v_date_modified );
+ $raw_history[$j]['date'] = $v_date_modified;
$raw_history[$j]['userid'] = $v_user_id;
# user_get_name handles deleted users, and username vs realname
View
5 core/news_api.php
@@ -164,7 +164,6 @@ function news_get_row( $p_news_id ) {
trigger_error( ERROR_NEWS_NOT_FOUND, ERROR );
} else {
$row = db_fetch_array( $result );
- $row['date_posted'] = db_unixtimestamp( $row['date_posted'] );
return $row;
}
}
@@ -221,7 +220,6 @@ function news_get_rows( $p_project_id, $p_sitewide = true ) {
for( $i = 0;$i < $t_row_count;$i++ ) {
$row = db_fetch_array( $result );
- $row['date_posted'] = db_unixtimestamp( $row['date_posted'] );
array_push( $t_rows, $row );
}
@@ -259,7 +257,7 @@ function news_get_limited_rows( $p_offset, $p_project_id = null ) {
$t_news_table = db_get_table( 'mantis_news_table' );
$t_news_view_limit = config_get( 'news_view_limit' );
- $t_news_view_limit_days = config_get( 'news_view_limit_days' );
+ $t_news_view_limit_days = config_get( 'news_view_limit_days' ) * 86400;
switch( config_get( 'news_limit_method' ) ) {
case 0:
@@ -308,7 +306,6 @@ function news_get_limited_rows( $p_offset, $p_project_id = null ) {
$t_rows = array();
for( $i = 0;$i < $t_row_count;$i++ ) {
$row = db_fetch_array( $result );
- $row['date_posted'] = db_unixtimestamp( $row['date_posted'] );
array_push( $t_rows, $row );
}
View
2  core/sponsorship_api.php
@@ -91,8 +91,6 @@ function sponsorship_cache_row( $p_sponsorship_id, $p_trigger_errors = true ) {
}
$row = db_fetch_array( $result );
- $row['date_submitted'] = db_unixtimestamp( $row['date_submitted'] );
- $row['last_updated'] = db_unixtimestamp( $row['last_updated'] );
$g_cache_sponsorships[$c_sponsorship_id] = $row;
return $row;
View
2  core/string_api.php
@@ -572,7 +572,7 @@ function string_get_bugnote_view_link( $p_bug_id, $p_bugnote_id, $p_user_id = nu
$t_link .= string_get_bugnote_view_url( $p_bug_id, $p_bugnote_id, $p_user_id ) . '"';
if( $p_detail_info ) {
$t_reporter = string_attribute( user_get_name( bugnote_get_field( $p_bugnote_id, 'reporter_id' ) ) );
- $t_update_date = string_attribute( date( config_get( 'normal_date_format' ), ( db_unixtimestamp( bugnote_get_field( $p_bugnote_id, 'last_modified' ) ) ) ) );
+ $t_update_date = string_attribute( date( config_get( 'normal_date_format' ), ( bugnote_get_field( $p_bugnote_id, 'last_modified' ) ) ) );
$t_link .= ' title="' . bug_format_id( $t_bug_id ) . ': [' . $t_update_date . '] ' . $t_reporter . '"';
}
View
8 core/summary_api.php
@@ -191,7 +191,7 @@ function summary_print_by_enum( $p_enum_string, $p_enum ) {
function summary_new_bug_count_by_date( $p_time_length = 1 ) {
$t_mantis_bug_table = db_get_table( 'mantis_bug_table' );
- $c_time_length = (int) $p_time_length;
+ $c_time_length = (int) $p_time_length * 86400;
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
@@ -203,7 +203,7 @@ function summary_new_bug_count_by_date( $p_time_length = 1 ) {
$query = "SELECT COUNT(*)
FROM $t_mantis_bug_table
- WHERE " . db_helper_compare_days( "'" . db_now() . "'", "date_submitted", "<= '$c_time_length'" ) . " AND $specific_where";
+ WHERE " . db_helper_compare_days( "" . db_now() . "", "date_submitted", "<= $c_time_length" ) . " AND $specific_where";
$result = db_query_bound( $query );
return db_result( $result, 0 );
}
@@ -215,7 +215,7 @@ function summary_resolved_bug_count_by_date( $p_time_length = 1 ) {
$t_bug_history_table = db_get_table( 'mantis_bug_history_table' );
$t_resolved = config_get( 'bug_resolved_status_threshold' );
- $c_time_length = (int) $p_time_length;
+ $c_time_length = (int) $p_time_length * 864000;
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
@@ -234,7 +234,7 @@ function summary_resolved_bug_count_by_date( $p_time_length = 1 ) {
WHERE b.status >= " . db_param() . "
AND h.old_value < " . db_param() . "
AND h.new_value >= " . db_param() . "
- AND " . db_helper_compare_days( "'" . db_now() . "'", "date_modified", "<= '$c_time_length'" ) . "
+ AND " . db_helper_compare_days( "" . db_now() . "", "date_modified", "<= $c_time_length" ) . "
AND $specific_where";
$result = db_query_bound( $query, Array( $t_resolved, $t_resolved, $t_resolved ) );
return db_result( $result, 0 );
View
6 core/tokens_api.php
@@ -128,7 +128,7 @@ function token_touch( $p_token_id, $p_expiry = TOKEN_EXPIRY ) {
token_ensure_exists( $p_token_id );
$c_token_id = db_prepare_int( $p_token_id );
- $c_token_expiry = db_timestamp( db_date( time() + $p_expiry ) );
+ $c_token_expiry = time() + $p_expiry;
$t_tokens_table = db_get_table( 'mantis_tokens_table' );
$t_query = "UPDATE $t_tokens_table
@@ -192,7 +192,7 @@ function token_delete_by_owner( $p_user_id = null ) {
function token_create( $p_type, $p_value, $p_expiry = TOKEN_EXPIRY, $p_user_id = null ) {
$c_type = db_prepare_int( $p_type );
$c_timestamp = db_now();
- $c_expiry = db_timestamp( db_date( time() + $p_expiry ) );
+ $c_expiry = time() + $p_expiry;
$c_user_id = db_prepare_int( $p_user_id == null ? auth_get_current_user_id() : $p_user_id );
$t_tokens_table = db_get_table( 'mantis_tokens_table' );
@@ -214,7 +214,7 @@ function token_create( $p_type, $p_value, $p_expiry = TOKEN_EXPIRY, $p_user_id =
function token_update( $p_token_id, $p_value, $p_expiry = TOKEN_EXPIRY ) {
token_ensure_exists( $p_token_id );
$c_token_id = db_prepare_int( $p_token_id );
- $c_expiry = db_timestamp( db_date( time() + $p_expiry ) );
+ $c_expiry = time() + $p_expiry;
$t_tokens_table = db_get_table( 'mantis_tokens_table' );
View
8 core/version_api.php
@@ -71,7 +71,6 @@ function version_cache_row( $p_version_id, $p_trigger_errors = true ) {
}
$row = db_fetch_array( $result );
- $row['date_order'] = db_unixtimestamp( $row['date_order'] );
$g_cache_versions[$c_version_id] = $row;
return $row;
@@ -124,7 +123,7 @@ function version_add( $p_project_id, $p_version, $p_released = VERSION_FUTURE, $
if( null === $p_date_order ) {
$c_date_order = db_now();
} else {
- $c_date_order = db_timestamp( $p_date_order );
+ $c_date_order = $p_date_order;
}
version_ensure_unique( $p_version, $p_project_id );
@@ -159,7 +158,7 @@ function version_update( $p_version_info ) {
$c_description = $p_version_info->description;
$c_released = db_prepare_int( $p_version_info->released );
$c_obsolete = db_prepare_bool( $p_version_info->obsolete );
- $c_date_order = db_timestamp( $p_version_info->date_order );
+ $c_date_order = $p_version_info->date_order;
$c_project_id = db_prepare_int( $p_version_info->project_id );
$t_project_version_table = db_get_table( 'mantis_project_version_table' );
@@ -294,7 +293,6 @@ function version_cache_array_rows( $p_project_id_array ) {
$rows = array();
while( $row = db_fetch_array( $result ) ) {
- $row['date_order'] = db_unixtimestamp( $row['date_order'] );
$g_cache_versions[(int) $row['id']] = $row;
$rows[ (int)$row[ 'project_id' ] ][] = $row['id'];
@@ -352,7 +350,6 @@ function version_get_all_rows( $p_project_id, $p_released = null, $p_obsolete =
$rows = array();
for( $i = 0;$i < $count;$i++ ) {
$row = db_fetch_array( $result );
- $row['date_order'] = db_unixtimestamp( $row['date_order'] );
$g_cache_versions[(int) $row['id']] = $row;
$rows[] = $row;
@@ -395,7 +392,6 @@ function version_get_all_rows_with_subs( $p_project_id, $p_released = null, $p_o
$rows = array();
for( $i = 0;$i < $count;$i++ ) {
$row = db_fetch_array( $result );
- $row['date_order'] = db_unixtimestamp( $row['date_order'] );
$rows[] = $row;
}
return $rows;
View
2  file_download.php
@@ -105,7 +105,7 @@
header( 'Content-Disposition:' . $t_disposition . ' filename="' . urlencode( $t_filename ) . '"' );
header( 'Content-Description: Download Data' );
- header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s \G\M\T', db_unixtimestamp( $v_date_added ) ) );
+ header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s \G\M\T', $v_date_added ) );
# To fix an IE bug which causes problems when downloading
# attached files via HTTPS, we disable the "Pragma: no-cache"
View
4 graphs/graph_by_cumulative.php
@@ -107,9 +107,9 @@ function get_closed_count_by_date( $p_date ) {
extract( $row );
if( $status < 80 ) {
- $date_str = date( 'm/d/Y', db_unixtimestamp( $date_submitted ) );
+ $date_str = date( 'm/d/Y', $date_submitted );
} else {
- $date_str = date( 'm/d/Y', db_unixtimestamp( $last_updated ) );
+ $date_str = date( 'm/d/Y', $last_updated );
}
$data_date_arr[] = $date_str;
View
4 graphs/graph_by_daily_delta.php
@@ -109,9 +109,9 @@ function get_closed_count_by_date( $p_date ) {
extract( $row );
if( $status < 80 ) {
- $date_str = date( 'm/d/Y', db_unixtimestamp( $date_submitted ) );
+ $date_str = date( 'm/d/Y', $date_submitted );
} else {
- $date_str = date( 'm/d/Y', db_unixtimestamp( $last_updated ) );
+ $date_str = date( 'm/d/Y', $last_updated );
}
$data_date_arr[] = $date_str;
View
2  main_page.php
@@ -64,7 +64,7 @@
echo '<div class="quick-summary-left">';
echo lang_get( 'last_visit' ) . ': ';
- echo print_date( config_get( 'normal_date_format' ), db_unixtimestamp( current_user_get_field( 'last_visit' ) ) );
+ echo print_date( config_get( 'normal_date_format' ), current_user_get_field( 'last_visit' ) );
echo '</div>';
}
View
2  manage_proj_ver_copy.php
@@ -58,7 +58,7 @@
foreach ( $t_rows as $t_row ) {
if ( version_is_unique( $t_row['version'], $t_dst_project_id ) ) {
- $t_version_id = version_add( $t_dst_project_id, $t_row['version'], $t_row['released'], $t_row['description'], db_date( $t_row['date_order'] ) );
+ $t_version_id = version_add( $t_dst_project_id, $t_row['version'], $t_row['released'], $t_row['description'], $t_row['date_order'] );
event_signal( 'EVENT_MANAGE_VERSION_CREATE', array( $t_version_id ) );
}
}
View
6 manage_tags_page.php
@@ -158,10 +158,8 @@
<td><?php echo $t_tag_name ?></td>
<?php } ?>
<td><?php echo user_get_name( $t_tag_row['user_id'] ) ?></td>
- <td><?php echo print_date( config_get( 'normal_date_format' ),
- db_unixtimestamp( $t_tag_row['date_created'] ) ) ?></td>
- <td><?php echo print_date( config_get( 'normal_date_format' ),
- db_unixtimestamp( $t_tag_row['date_updated'] ) ) ?></td>
+ <td><?php echo print_date( config_get( 'normal_date_format' ), $t_tag_row['date_created'] ) ?></td>
+ <td><?php echo print_date( config_get( 'normal_date_format' ), $t_tag_row['date_updated'] ) ?></td>
</tr>
<?php } ?>
View
14 manage_user_page.php
@@ -92,10 +92,10 @@
# New Accounts Form BEGIN
- $days_old = 7;
+ $days_old = 7 * 86400;
$query = "SELECT *
FROM $t_user_table
- WHERE ".db_helper_compare_days("'" . db_now() . "'","date_created","<= '$days_old'")."
+ WHERE ".db_helper_compare_days("" . db_now() . "","date_created","<= $days_old")."
ORDER BY date_created DESC";
$result = db_query_bound( $query );
$g_db->debug=false;
@@ -156,7 +156,7 @@
} else if ( $f_filter === 'UNUSED' ) {
$t_where = '(login_count = 0) AND ( date_created = last_visit )';
} else if ( $f_filter === 'NEW' ) {
- $t_where = db_helper_compare_days("'" . db_now() . "'","date_created","<= '$days_old'");
+ $t_where = db_helper_compare_days("" . db_now() . "","date_created","<= $days_old");
} else {
$c_prefix = db_prepare_string($f_filter);
$t_where = "(username like '$c_prefix%')";
@@ -180,7 +180,7 @@
} else {
$query = "SELECT count(*) as usercnt
FROM $t_user_table
- WHERE $t_where AND " . db_helper_compare_days("'" . db_now() . "'","last_visit","< '$days_old'");
+ WHERE $t_where AND " . db_helper_compare_days("" . db_now() . "","last_visit","< $days_old");
$result = db_query_bound($query, $t_where_params);
$row = db_fetch_array( $result );
$total_user_count = $row['usercnt'];
@@ -212,7 +212,7 @@
$query = "SELECT *
FROM $t_user_table
- WHERE $t_where AND " . db_helper_compare_days(0,"last_visit","< '$days_old'") . "
+ WHERE $t_where AND " . db_helper_compare_days(0,"last_visit","< $days_old") . "
ORDER BY $c_sort $c_dir";
/* db_now added to where params in count query above so not added here */
$result = db_query_bound($query, $t_where_params, $p_per_page, $t_offset );
@@ -295,8 +295,8 @@
$row = db_fetch_array($result);
extract( $row, EXTR_PREFIX_ALL, 'u' );
- $u_date_created = date( $t_date_format, db_unixtimestamp( $u_date_created ) );
- $u_last_visit = date( $t_date_format, db_unixtimestamp( $u_last_visit ) );
+ $u_date_created = date( $t_date_format, $u_date_created );
+ $u_last_visit = date( $t_date_format, $u_last_visit );
if( !isset( $t_access_level[$u_access_level] ) ) {
$t_access_level[$u_access_level] = get_enum_element( 'access_levels', $u_access_level );
View
2  manage_user_prune.php
@@ -34,7 +34,7 @@
$t_user_table = db_get_table( 'mantis_user_table' );
# Delete the users who have never logged in and are older than 1 week
- $days_old = (int)7;
+ $days_old = (int)7 * 86400;
$query = "SELECT id
FROM $t_user_table
View
4 print_bug_page.php
@@ -126,10 +126,10 @@
<?php echo get_enum_element( 'reproducibility', $v_reproducibility ) ?>
</td>
<td class="print">
- <?php print_date( config_get( 'normal_date_format' ), db_unixtimestamp( $v_date_submitted ) ) ?>
+ <?php print_date( config_get( 'normal_date_format' ), $v_date_submitted ) ?>
</td>
<td class="print">
- <?php print_date( config_get( 'normal_date_format' ), db_unixtimestamp( $v_last_updated ) ) ?>
+ <?php print_date( config_get( 'normal_date_format' ), $v_last_updated ) ?>
</td>
</tr>
<tr>
View
6 print_bugnote_inc.php
@@ -76,8 +76,8 @@
# prefix all bugnote data with v3_
$row = db_fetch_array( $result );
extract( $row, EXTR_PREFIX_ALL, 'v3' );
- $v3_date_submitted = date( config_get( 'normal_date_format' ), ( db_unixtimestamp( $v3_date_submitted ) ) );
- $v3_last_modified = date( config_get( 'normal_date_format' ), ( db_unixtimestamp( $v3_last_modified ) ) );
+ $v3_date_submitted = date( config_get( 'normal_date_format' ), $v3_date_submitted );
+ $v3_last_modified = date( config_get( 'normal_date_format' ), $v3_last_modified );
# grab the bugnote text and id and prefix with v3_
$query = "SELECT note, id
@@ -112,7 +112,7 @@
<tr>
<td class="print">
<?php echo $v3_date_submitted ?>&nbsp;&nbsp;&nbsp;
- <?php if ( db_unixtimestamp( $v3_date_submitted ) != db_unixtimestamp( $v3_last_modified ) ) {
+ <?php if ( $v3_date_submitted != $v3_last_modified ) {
echo '<br />(' . lang_get( 'edited_on') . lang_get( 'word_separator' ) . $v3_last_modified . ')';
} ?>
</td>
View
2  proj_doc_page.php
@@ -103,7 +103,7 @@
$v_filesize = number_format( $v_filesize );
$v_title = string_display( $v_title );
$v_description = string_display_links( $v_description );
- $v_date_added = date( config_get( 'normal_date_format' ), db_unixtimestamp( $v_date_added ) );
+ $v_date_added = date( config_get( 'normal_date_format' ), $v_date_added );
?>
<tr valign="top" <?php echo helper_alternate_class( $i ) ?>>
View
6 summary_page.php
@@ -62,13 +62,13 @@
$t_total_time = 0;
for ($i=0;$i<$bug_count;$i++) {
$row = db_fetch_array( $result );
- $t_date_submitted = db_unixtimestamp( $row['date_submitted'] );
+ $t_date_submitted = $row['date_submitted'];
$t_id = $row['id'];
$t_status = $row['status'];
if ( $row['hist_update'] !== NULL ) {
- $t_last_updated = db_unixtimestamp( $row['hist_update'] );
+ $t_last_updated = $row['hist_update'];
} else {
- $t_last_updated = db_unixtimestamp( $row['last_updated'] );
+ $t_last_updated = $row['last_updated'];
}
if ($t_last_updated < $t_date_submitted) {
View
4 tag_update_page.php
@@ -92,8 +92,8 @@
echo user_get_name($t_tag_row['user_id']);
}
?></td>
- <td><?php echo print_date( config_get( 'normal_date_format' ), db_unixtimestamp( $t_tag_row['date_created'] ) ) ?> </td>
- <td><?php echo print_date( config_get( 'normal_date_format' ), db_unixtimestamp( $t_tag_row['date_updated'] ) ) ?> </td>
+ <td><?php echo print_date( config_get( 'normal_date_format' ), $t_tag_row['date_created'] ) ?> </td>
+ <td><?php echo print_date( config_get( 'normal_date_format' ), $t_tag_row['date_updated'] ) ?> </td>
</tr>
<!-- spacer -->
View
4 tag_view_page.php
@@ -70,8 +70,8 @@
<td><?php echo $t_tag_row['id'] ?></td>
<td><?php echo $t_name ?></td>
<td><?php echo user_get_name($t_tag_row['user_id']) ?></td>
- <td><?php echo print_date( config_get( 'normal_date_format' ), db_unixtimestamp( $t_tag_row['date_created'] ) ) ?> </td>
- <td><?php echo print_date( config_get( 'normal_date_format' ), db_unixtimestamp( $t_tag_row['date_updated'] ) ) ?> </td>
+ <td><?php echo print_date( config_get( 'normal_date_format' ), $t_tag_row['date_created'] ) ?> </td>
+ <td><?php echo print_date( config_get( 'normal_date_format' ), $t_tag_row['date_updated'] ) ?> </td>
</tr>
<!-- spacer -->
Please sign in to comment.
Something went wrong with that request. Please try again.