Skip to content

Commit e33708b

Browse files
committed
5.8.2.2545 DB Checksums now normalise newer database engines
1 parent fba3413 commit e33708b

File tree

4 files changed

+91
-132
lines changed

4 files changed

+91
-132
lines changed

classes/class.backup.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?php
2-
define("VERSION_BACKUP","1.1.10");
2+
define("VERSION_BACKUP","1.1.11");
33
/*
44
Version History:
5-
1.1.10 (2015-03-23)
6-
1) Method get_version() renamed to getVersion() and made static
7-
5+
1.1.11 (2024-03-29)
6+
Backup::db_export_sql_structure() no longer normalises database create tables when exporting backup
87
*/
98

109
class Backup extends Record{
@@ -179,7 +178,7 @@ function db_export_sql_structure($noprint=false,$drop=true) {
179178
$Obj = new Table();
180179
$tables = $Obj->get_tables_names();
181180
for ($i=0; $i<count($tables); $i++) {
182-
$tables[$i]['Data'] = $Obj->get_table_create_sql($tables[$i]['Name']);
181+
$tables[$i]['Data'] = $Obj->get_table_create_sql($tables[$i]['Name'], false, false);
183182
}
184183
$out =
185184
"# ************************************\n"

classes/class.system.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?php
22
/*
33
Version History:
4-
1.0.188 (2019-01-06)
5-
1) System::get_stats() now properly merges in new stats with old when making a delta update
6-
2) System::updateAllVisitorStats() increased timeout
4+
1.0.189 (2024-03-28)
5+
1) System::do_commands() for get_table_structure now provide notice that the structure is normalised for debug purposes
76
*/
87
class System extends Record
98
{
10-
const VERSION = '1.0.188';
9+
const VERSION = '1.0.189';
1110
const FIELDS = 'ID, archive, textEnglish, debug, debug_no_internet, classes_cs_target, classes_detail, db_cs_target, db_detail, libraries_cs_target, libraries_detail, reports_cs_target, reports_detail, db_custom_tables, db_upgrade_flag, db_version, adminEmail, archiveID, deleted, adminName, akismet_api_key, bounce_email, bugs_password, bugs_username, bugs_url, cal_border, cal_current, cal_current_we, cal_days, cal_event, cal_head, cal_then, cal_then_we, cal_today, colour1, colour2, colour3, colour4, component_parameters, cron_job_heartbeat_last_run, custom_1, custom_2, defaultBgColor, defaultCurrencySuffix, defaultCurrencySymbol, defaultDateFormat, defaultLanguage, defaultLayoutID, defaultTaxZoneID, defaultThemeID, defaultTimeFormat, favicon, features, gatewayID, google_analytics_key, google_maps_key, installed_modules, languages, last_user_access, membership_expiry_type, membership_rules, notes, notify_email, notify_triggers, piwik_id, piwik_online, piwik_md5_password, piwik_token, piwik_user, posting_prefix, provider_list, qbwc_AssetAccountRef, qbwc_COGSAccountRef, qbwc_IncomeAccountRef, qbwc_export_orders, qbwc_export_orders_billing_addr, qbwc_export_orders_product_desc, qbwc_export_orders_taxcodes, qbwc_export_people, qbwc_export_products, qbwc_invoice_type, qbwc_user, qbwc_pass, smtp_authenticate, smtp_host, smtp_password, smtp_port, smtp_username, stats_cache, style, system_cancellation_days, system_signup, table_border, table_data, table_header, tax_benefit_1_name, tax_benefit_2_name, tax_benefit_3_name, tax_benefit_4_name, text_heading, timezone, URL, URL_aliases, history_created_by, history_created_date, history_created_IP, history_modified_by, history_modified_date, history_modified_IP';
1211
const TABLES = 'action, activity, address_substitution, block_layout, case_tasks, cases, category_assign, colour_scheme, comment, community, community_member, community_membership, component, content_block, custom_form, ecl_tags, field_templates, gateway_settings, gateway_type, geocode_cache, group_assign, group_members, groups, keyword_assign, keywords, language_assign, layout, listdata, listtype, mailidentity, mailqueue, mailqueue_item, mailtemplate, membership_rule, module_credits, navbuttons, navstyle, navsuite, order_items, orders, pages, payment_method, person, poll, poll_choice, postings, product, product_grouping, product_relationship, push_product_assign, qb_config, qb_connection, qb_ident, qb_import, qb_log, qb_notify, qb_queue, qb_recur, qb_ticket, qb_user, registerevent, report, report_columns, report_defaults, report_filter, report_filter_criteria, report_settings, scheduled_task, system, tax_code, tax_regime, tax_rule, tax_zone, theme, widget';
1312

@@ -291,8 +290,10 @@ public function do_commands()
291290
global $db;
292291
if (isset($_REQUEST['targetValue'])) {
293292
$Obj = new Table;
294-
print "<h1>".$_SERVER["HTTP_HOST"]." : ".$db." : ".$_REQUEST['targetValue']."</h1>";
295-
print "<pre>".$Obj->get_table_create_sql($_REQUEST['targetValue'], false)."</pre>";
293+
print
294+
"<h1>".$_SERVER["HTTP_HOST"]." : ".$db." : ".$_REQUEST['targetValue']."</h1>"
295+
. "<p>This code is normalised for all supported database versions to avoid false errors when comparing sites.</p>"
296+
. "<pre>".$Obj->get_table_create_sql($_REQUEST['targetValue'], true, true)."</pre>";
296297
die;
297298
}
298299
break;

classes/class.table.php

Lines changed: 64 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,80 @@
11
<?php
2-
define('VERSION_TABLE','1.0.5');
2+
define('VERSION_TABLE','1.0.6');
33
/*
44
Version History:
5-
1.0.5 (2012-09-08)
6-
1) Tweak to table::get_checksum() to no longer ignore fields prefixed with word
7-
'module' - new modules should from now on use XML fields instead of hacking
8-
database structure
9-
1.0.4 (2012-09-04)
10-
1) Removed Table::copy() - unused
11-
2) Removed Table::uniqID() - unused
12-
3) Removed Table::get_tables_and_fields() - unused
13-
1.0.3 (2010-10-04)
14-
1) Changes to setter and getter names for parent-based object properties
15-
1.0.2 (2009-11-13)
16-
1) Tweak to Table::get_table_create_sql() to be conformant with mysql 4.1.20(!)
17-
1.0.1 (2009-11-10)
18-
1) Table::get_table_create_sql() now makes three subtle changes to deal with
19-
differences in TABLE CREATE output between 5.0.68 and 5.1.36
20-
1.0.0 (2009-07-02)
21-
Initial release
5+
1.0.6 (2024-03-28)
6+
1) Updates to Table::get_table_create_sql() to normalise for newer database engines
227
*/
238
class Table extends Record{
24-
static $cache_create_table_array = array();
9+
static $cache_create_table_array = array();
2510

26-
function __construct($table="") {
27-
if ($table!="") {
28-
$this->_set_table_name($table);
29-
$this->_set_object_name('Table');
11+
function __construct($table="") {
12+
if ($table!="") {
13+
$this->_set_table_name($table);
14+
$this->_set_object_name('Table');
15+
}
3016
}
31-
}
3217

33-
function get_checksum($ignore_custom_fields = true) {
34-
$sql = $this->get_table_create_sql($this->table);
35-
if ($ignore_custom_fields) {
36-
$sql = preg_replace('/ `cus_([^\n])*\n/','',$sql);
18+
function get_checksum($ignore_custom_fields = true) {
19+
$sql = $this->get_table_create_sql($this->table, true, true);
20+
if ($ignore_custom_fields) {
21+
$sql = preg_replace('/ `cus_([^\n])*\n/','',$sql);
22+
}
23+
return crc32($sql);
3724
}
38-
return crc32($sql);
39-
}
4025

41-
function get_table_create_sql($name,$remove_autonum=true) {
42-
if (isset(Table::$cache_create_table_array[$name])) {
43-
return Table::$cache_create_table_array[$name];
44-
}
45-
$sql = "SHOW CREATE TABLE ".$name."";
46-
$record = $this->get_record_for_sql($sql);
47-
$out = $record['Create Table'];
48-
$out = str_replace('default','DEFAULT',$out);
49-
$out = str_replace('PRIMARY KEY ','PRIMARY KEY ',$out);
50-
$out = str_replace('auto_increment','AUTO_INCREMENT',$out);
51-
if ($remove_autonum) {
52-
$out = preg_replace('/ AUTO_INCREMENT=([0-9])*/','',$out);
26+
function get_table_create_sql($name, $remove_autonum=true, $normalise=true) {
27+
if (isset(Table::$cache_create_table_array[$name])) {
28+
return Table::$cache_create_table_array[$name];
29+
}
30+
$sql = "SHOW CREATE TABLE ".$name."";
31+
$record = $this->get_record_for_sql($sql);
32+
$out = $record['Create Table'];
33+
34+
if ($normalise) {
35+
$out = str_replace('default', 'DEFAULT', $out);
36+
$out = str_replace('PRIMARY KEY ', 'PRIMARY KEY ', $out);
37+
$out = str_replace('auto_increment', 'AUTO_INCREMENT', $out);
38+
$out = str_replace(' DEFAULT 0,', ' DEFAULT \'0\',', $out);
39+
$out = str_replace(' DEFAULT 0.25,', ' DEFAULT \'0.25\',', $out);
40+
$out = str_replace(' DEFAULT 1,', ' DEFAULT \'1\',', $out);
41+
$out = str_replace(' DEFAULT 3,', ' DEFAULT \'3\',', $out);
42+
$out = str_replace(' DEFAULT 25,', ' DEFAULT \'25\',', $out);
43+
$out = str_replace(' DEFAULT 110,', ' DEFAULT \'110\',', $out);
44+
$out = str_replace(' DEFAULT 0.00', ' DEFAULT \'0.00\'', $out);
45+
$out = str_replace(' text DEFAULT NULL,', ' text,', $out);
46+
$out = str_replace(' CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci', ' CHARSET=utf8', $out);
47+
}
48+
if ($remove_autonum) {
49+
$out = preg_replace('/ AUTO_INCREMENT=([0-9])*' . '/', '', $out);
50+
}
51+
Table::$cache_create_table_array[$name] = $out;
52+
// z($out);die;
53+
return $out;
5354
}
54-
Table::$cache_create_table_array[$name] = $out;
55-
// z($out);die;
56-
return $out;
57-
}
5855

59-
function get_tables_names() {
60-
$sql = "SHOW TABLE STATUS";
61-
$records = $this->get_records_for_sql($sql);
62-
$out = array();
63-
foreach ($records as $record) {
64-
$out[] = array('Name'=>$record['Name']);
56+
function get_tables_names() {
57+
$sql = "SHOW TABLE STATUS";
58+
$records = $this->get_records_for_sql($sql);
59+
$out = array();
60+
foreach ($records as $record) {
61+
$out[] = array('Name'=>$record['Name']);
62+
}
63+
return $out;
6564
}
66-
return $out;
67-
}
6865

69-
function hasSystemID($table){
70-
$sql =
71-
"SHOW COLUMNS FROM `".$table."`";
72-
$rows = $this->get_records_for_sql($sql);
73-
foreach ($rows as $row) {
74-
if ($row['Field'] == 'systemID') {
75-
return true;
76-
}
66+
function hasSystemID($table){
67+
$sql = "SHOW COLUMNS FROM `".$table."`";
68+
$rows = $this->get_records_for_sql($sql);
69+
foreach ($rows as $row) {
70+
if ($row['Field'] == 'systemID') {
71+
return true;
72+
}
73+
}
74+
return false;
7775
}
78-
return false;
79-
}
8076

81-
public static function getVersion(){
82-
return VERSION_TABLE;
83-
}
84-
}
85-
?>
77+
public static function getVersion(){
78+
return VERSION_TABLE;
79+
}
80+
}

codebase.php

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
define("CODEBASE_VERSION", "5.8.1");
2+
define("CODEBASE_VERSION", "5.8.2");
33
define('ECC_PHP_7_STRICT', 1);
44
define("DEBUG_FORM", 0);
55
define("DEBUG_REPORT", 0);
@@ -19,71 +19,35 @@
1919
//define("DOCTYPE", '<!DOCTYPE html SYSTEM "%HOST%/xhtml1-strict-with-iframe.dtd">');
2020
/*
2121
--------------------------------------------------------------------------------
22-
5.8.1.2544 (2022-08-15)
22+
5.8.2.2545 (2024-03-28)
2323
Summary:
24-
Improvements to Community Contacts View for admins
24+
DB Checksums now normalise newer database engines to consistent results
2525
2626
Final Checksums:
27-
Classes CS:4a02f26d
27+
Classes CS:868cd3f0
2828
Database CS:422e4761
29-
Libraries CS:101a9f28
29+
Libraries CS:a26e7dc0
3030
Reports CS:b6232c7
3131
3232
Code Changes:
33-
codebase.php 5.8.0 (2022-08-15)
33+
codebase.php 5.8.2 (2024-03-28)
3434
1) Updated version information
35-
classes/class.community_display.php 1.0.63 (2022-08-15)
36-
Community_Display::drawContact() updates
37-
classes/class.community_member.php 1.0.128 (2022-08-15)
38-
1) Changes to support admins-only community contact detail listings
39-
classes/class.community_member_display.php 1.0.64 (2022-08-15)
40-
1) Changes to Community_Member_Display functions for parameters to use in other places
41-
classes/class.portal.php 1.0.43 (2022-08-15)
42-
Portal::isDev() now extends to *.local sites
43-
style/community.css 1.0.8 (2022-08-15)
44-
1) Tweaks for Community Frame contact page - only available to admins
45-
46-
2543.sql
47-
1) Set version information
35+
classes/class.backup.php 1.1.11 (2024-03-29)
36+
Backup::db_export_sql_structure() no longer normalises database create tables when exporting backup
37+
classes/class.system.php 1.0.189 (Date not given!)
4838
49-
Promote:
50-
codebase.php 5.8.0
51-
classes/ (4 files changed)
52-
class.community_display.php 1.0.63 CS:9d125589
53-
class.community_member.php 1.0.128 CS:febf2890
54-
class.community_member_display.php 1.0.64 CS:603e9012
55-
class.portal.php 1.0.43 CS:e5ea2aed
56-
style/community.css 1.0.8 CS:29c13747
39+
classes/class.table.php 1.0.6 (2024-03-28)
40+
1) Updates to Table::get_table_create_sql() to normalise for newer database engines
5741
58-
Final Checksums:
59-
Classes CS:1882f681
60-
Database CS:422e4761
61-
Libraries CS:c5055fb1
62-
Reports CS:b6232c7
63-
64-
Code Changes:
65-
codebase.php 5.8.0 (2022-08-14)
66-
1) Updated version information
67-
classes/class.community.php 1.0.127 (2022-08-14)
68-
1) Code to prevent unset variable warnings
69-
classes/class.community_display.php 1.0.62 (2022-08-14)
70-
1) Added new Community Contacts View for admins and event planners
71-
classes/class.community_member.php 1.0.127 (2022-08-14)
72-
1) Community_Member::get_stats() tweak to prevent errors for unset variables
73-
style/community.css 1.0.7 (2022-08-14)
74-
1) Added support for Community Contact page
75-
76-
2543.sql
42+
2545.sql
7743
1) Set version information
7844
7945
Promote:
80-
codebase.php 5.8.0
46+
codebase.php 5.8.2
8147
classes/ (3 files changed)
82-
class.community.php 1.0.127 CS:91e8856b
83-
class.community_display.php 1.0.62 CS:758da5fd
84-
class.community_member.php 1.0.127 CS:4cf2c0aa
85-
style/community.css 1.0.7 CS:cafe49d5
86-
48+
class.backup.php 1.1.11 CS:cb917da8
49+
class.system.php 1.0.189 CS:c502c08f
50+
class.table.php 1.0.6 CS:ce871f7
8751
--------------------------------------------------------------------------------
8852
8953
Bug:

0 commit comments

Comments
 (0)