diff options
author | redmatrix <mike@macgirvin.com> | 2016-09-26 18:16:43 -0700 |
---|---|---|
committer | redmatrix <mike@macgirvin.com> | 2016-09-26 18:16:43 -0700 |
commit | cacdac16aa104eb1308f69f24fef31f682934fca (patch) | |
tree | 02be2495ad66a7950e342b075144e2fc0958d79d | |
parent | fb9544badd66043bf7ee5a7566ba288ad7da29fa (diff) | |
download | volse-hubzilla-cacdac16aa104eb1308f69f24fef31f682934fca.tar.gz volse-hubzilla-cacdac16aa104eb1308f69f24fef31f682934fca.tar.bz2 volse-hubzilla-cacdac16aa104eb1308f69f24fef31f682934fca.zip |
next wave of nulldate fixes
-rw-r--r-- | include/datetime.php | 13 | ||||
-rwxr-xr-x | include/dba/dba_driver.php | 18 | ||||
-rw-r--r-- | install/schema_mysql.sql | 128 | ||||
-rw-r--r-- | install/update.php | 76 |
4 files changed, 117 insertions, 118 deletions
diff --git a/include/datetime.php b/include/datetime.php index c72e4bf83..cd08ab367 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -85,15 +85,20 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d if( ($s === '') || (! is_string($s)) ) $s = 'now'; + if(is_null_date($s)) { + $d = new DateTime('0001-01-01 00:00:00', new DateTimeZone('UTC')); + return $d->format($fmt); + } + // Slight hackish adjustment so that 'zero' datetime actually returns what is intended // otherwise we end up with -0001-11-30 ... // add 32 days so that we at least get year 00, and then hack around the fact that // months and days always start with 1. - if(substr($s,0,10) == '0000-00-00') { - $d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC')); - return str_replace('1', '0', $d->format($fmt)); - } +// if(substr($s,0,10) == '0000-00-00') { +// $d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC')); +// return str_replace('1', '0', $d->format($fmt)); +// } try { $from_obj = new DateTimeZone($from); diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php index 7225a9be2..2cbdd529d 100755 --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -86,7 +86,7 @@ class DBA { abstract class dba_driver { // legacy behavior const INSTALL_SCRIPT='install/schema_mysql.sql'; - const NULL_DATE = '0000-00-00 00:00:00'; + const NULL_DATE = '0001-01-01 00:00:00'; const UTC_NOW = 'UTC_TIMESTAMP()'; protected $db; @@ -276,12 +276,9 @@ function dbunescbin($str) { } function dbescdate($date) { - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES && $date == '0000-00-00 00:00:00') { - $date = NULL_DATE; - } else if(ACTIVE_DBTYPE != DBTYPE_POSTGRES && $date == '0001-01-01 00:00:00') { - $date = NULL_DATE; - } - return $date; + if(is_null_date($date)) + return $dba->escape(NULL_DATE); + return $dba->escape($date); } function db_quoteinterval($txt) { @@ -376,11 +373,8 @@ function dbq($sql) { function dbesc_array_cb(&$item, $key) { if(is_string($item)) { - if($item == '0000-00-00 00:00:00' && ACTIVE_DBTYPE == DBTYPE_POSTGRES) - $item = '0001-01-01 00:00:00'; - else if($item == '0001-01-01 00:00:00' && ACTIVE_DBTYPE == DBTYPE_MYSQL) - $item = '0000-00-00 00:00:00'; - + if(is_null_date($item)) + $item = NULL_DATE; $item = dbesc($item); } } diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql index 9a4f58880..d72684a90 100644 --- a/install/schema_mysql.sql +++ b/install/schema_mysql.sql @@ -21,10 +21,10 @@ CREATE TABLE IF NOT EXISTS `abook` ( `abook_my_perms` int(11) NOT NULL DEFAULT '0', `abook_their_perms` int(11) NOT NULL DEFAULT '0', `abook_closeness` tinyint(3) unsigned NOT NULL DEFAULT '99', - `abook_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `abook_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `abook_connected` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `abook_dob` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `abook_created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `abook_updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `abook_connected` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `abook_dob` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `abook_flags` int(11) NOT NULL DEFAULT '0', `abook_blocked` tinyint(4) NOT NULL DEFAULT '0', `abook_ignored` tinyint(4) NOT NULL DEFAULT '0', @@ -70,16 +70,16 @@ CREATE TABLE IF NOT EXISTS `account` ( `account_email` char(255) NOT NULL DEFAULT '', `account_external` char(255) NOT NULL DEFAULT '', `account_language` char(16) NOT NULL DEFAULT 'en', - `account_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `account_lastlog` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `account_created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `account_lastlog` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `account_flags` int(10) unsigned NOT NULL DEFAULT '0', `account_roles` int(10) unsigned NOT NULL DEFAULT '0', `account_reset` char(255) NOT NULL DEFAULT '', - `account_expires` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `account_expire_notified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `account_expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `account_expire_notified` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `account_service_class` char(32) NOT NULL DEFAULT '', `account_level` int(10) unsigned NOT NULL DEFAULT '0', - `account_password_changed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `account_password_changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY (`account_id`), KEY `account_email` (`account_email`), KEY `account_service_class` (`account_service_class`), @@ -125,8 +125,8 @@ CREATE TABLE IF NOT EXISTS `app` ( `app_requires` char(255) NOT NULL DEFAULT '', `app_deleted` int(11) NOT NULL DEFAULT '0', `app_system` int(11) NOT NULL DEFAULT '0', - `app_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `app_edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `app_created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `app_edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY (`id`), KEY `app_id` (`app_id`), KEY `app_name` (`app_name`), @@ -148,7 +148,7 @@ CREATE TABLE IF NOT EXISTS `atoken` ( `atoken_uid` int(11) NOT NULL DEFAULT 0, `atoken_name` char(255) NOT NULL DEFAULT '', `atoken_token` char(255) NOT NULL DEFAULT '', - `atoken_expires` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `atoken_expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY (`atoken_id`), KEY `atoken_aid` (`atoken_aid`), KEY `atoken_uid` (`atoken_uid`), @@ -176,8 +176,8 @@ CREATE TABLE IF NOT EXISTS `attach` ( `os_path` mediumtext NOT NULL, `display_path` mediumtext NOT NULL, `content` longblob NOT NULL, - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `allow_cid` mediumtext NOT NULL, `allow_gid` mediumtext NOT NULL, `deny_cid` mediumtext NOT NULL, @@ -212,7 +212,7 @@ CREATE TABLE IF NOT EXISTS `auth_codes` ( CREATE TABLE IF NOT EXISTS `cache` ( `k` char(255) NOT NULL DEFAULT '', `v` text NOT NULL, - `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY (`k`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; @@ -253,9 +253,9 @@ CREATE TABLE IF NOT EXISTS `channel` ( `channel_prvkey` text NOT NULL, `channel_notifyflags` int(10) unsigned NOT NULL DEFAULT '65535', `channel_pageflags` int(10) unsigned NOT NULL DEFAULT '0', - `channel_dirdate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `channel_lastpost` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `channel_deleted` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `channel_dirdate` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `channel_lastpost` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `channel_deleted` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `channel_max_anon_mail` int(10) unsigned NOT NULL DEFAULT '10', `channel_max_friend_req` int(10) unsigned NOT NULL DEFAULT '10', `channel_expire_days` int(11) NOT NULL DEFAULT '0', @@ -333,7 +333,7 @@ CREATE TABLE IF NOT EXISTS `chat` ( `chat_room` int(10) unsigned NOT NULL DEFAULT '0', `chat_xchan` char(255) NOT NULL DEFAULT '', `chat_text` mediumtext NOT NULL, - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY (`chat_id`), KEY `chat_room` (`chat_room`), KEY `chat_xchan` (`chat_xchan`), @@ -344,7 +344,7 @@ CREATE TABLE IF NOT EXISTS `chatpresence` ( `cp_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `cp_room` int(10) unsigned NOT NULL DEFAULT '0', `cp_xchan` char(255) NOT NULL DEFAULT '', - `cp_last` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `cp_last` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `cp_status` char(255) NOT NULL DEFAULT '', `cp_client` char(128) NOT NULL DEFAULT '', PRIMARY KEY (`cp_id`), @@ -359,8 +359,8 @@ CREATE TABLE IF NOT EXISTS `chatroom` ( `cr_aid` int(10) unsigned NOT NULL DEFAULT '0', `cr_uid` int(10) unsigned NOT NULL DEFAULT '0', `cr_name` char(255) NOT NULL DEFAULT '', - `cr_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `cr_edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `cr_created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `cr_edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `cr_expire` int(10) unsigned NOT NULL DEFAULT '0', `allow_cid` mediumtext NOT NULL, `allow_gid` mediumtext NOT NULL, @@ -400,8 +400,8 @@ CREATE TABLE IF NOT EXISTS `conv` ( `recips` mediumtext NOT NULL, `uid` int(11) NOT NULL DEFAULT '0', `creator` char(255) NOT NULL DEFAULT '', - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `subject` mediumtext NOT NULL, PRIMARY KEY (`id`), KEY `created` (`created`), @@ -415,7 +415,7 @@ CREATE TABLE IF NOT EXISTS `dreport` ( `dreport_site` char(255) NOT NULL DEFAULT '', `dreport_recip` char(255) NOT NULL DEFAULT '', `dreport_result` char(255) NOT NULL DEFAULT '', - `dreport_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `dreport_time` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `dreport_xchan` char(255) NOT NULL DEFAULT '', `dreport_queue` char(255) NOT NULL DEFAULT '', PRIMARY KEY (`dreport_id`), @@ -434,10 +434,10 @@ CREATE TABLE IF NOT EXISTS `event` ( `cal_id` int(11) unsigned NOT NULL DEFAULT '0', `event_xchan` char(255) NOT NULL DEFAULT '', `event_hash` char(255) NOT NULL DEFAULT '', - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `dtstart` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `dtend` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `dtstart` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `dtend` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `summary` text NOT NULL, `description` text NOT NULL, `location` text NOT NULL, @@ -450,7 +450,7 @@ CREATE TABLE IF NOT EXISTS `event` ( `deny_cid` mediumtext NOT NULL, `deny_gid` mediumtext NOT NULL, `event_status` char(255) NOT NULL DEFAULT '', - `event_status_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `event_status_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `event_percent` smallint(6) NOT NULL DEFAULT '0', `event_repeat` text NOT NULL, `event_sequence` smallint(6) NOT NULL DEFAULT '0', @@ -526,8 +526,8 @@ CREATE TABLE IF NOT EXISTS `hubloc` ( `hubloc_callback` char(255) NOT NULL DEFAULT '', `hubloc_connect` char(255) NOT NULL DEFAULT '', `hubloc_sitekey` text NOT NULL, - `hubloc_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `hubloc_connected` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `hubloc_updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `hubloc_connected` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `hubloc_primary` tinyint(1) NOT NULL DEFAULT '0', `hubloc_orphancheck` tinyint(1) NOT NULL DEFAULT '0', `hubloc_error` tinyint(1) NOT NULL DEFAULT '0', @@ -566,8 +566,8 @@ CREATE TABLE IF NOT EXISTS `iconfig` ( CREATE TABLE IF NOT EXISTS `issue` ( `issue_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `issue_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `issue_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `issue_created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `issue_updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `issue_assigned` char(255) NOT NULL DEFAULT '', `issue_priority` int(11) NOT NULL DEFAULT '0', `issue_status` int(11) NOT NULL DEFAULT '0', @@ -589,13 +589,13 @@ CREATE TABLE IF NOT EXISTS `item` ( `parent` int(10) unsigned NOT NULL DEFAULT '0', `parent_mid` char(255) CHARACTER SET ascii NOT NULL DEFAULT '', `thr_parent` char(255) NOT NULL DEFAULT '', - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `expires` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `received` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `changed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `comments_closed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `comments_closed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `owner_xchan` char(255) NOT NULL DEFAULT '', `author_xchan` char(255) NOT NULL DEFAULT '', `source_xchan` char(255) NOT NULL DEFAULT '', @@ -771,8 +771,8 @@ CREATE TABLE IF NOT EXISTS `mail` ( `mail_seen` tinyint(4) NOT NULL DEFAULT '0', `mail_recalled` tinyint(4) NOT NULL DEFAULT '0', `mail_obscured` smallint(6) NOT NULL DEFAULT '0', - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `expires` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY (`id`), KEY `created` (`created`), KEY `mail_flags` (`mail_flags`), @@ -799,8 +799,8 @@ CREATE TABLE IF NOT EXISTS `menu` ( `menu_name` char(255) NOT NULL DEFAULT '', `menu_desc` char(255) NOT NULL DEFAULT '', `menu_flags` int(11) NOT NULL DEFAULT '0', - `menu_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `menu_edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `menu_created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `menu_edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY (`menu_id`), KEY `menu_channel_id` (`menu_channel_id`), KEY `menu_name` (`menu_name`), @@ -833,7 +833,7 @@ CREATE TABLE IF NOT EXISTS `notify` ( `xname` char(255) NOT NULL DEFAULT '', `url` char(255) NOT NULL DEFAULT '', `photo` char(255) NOT NULL DEFAULT '', - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `msg` mediumtext NOT NULL, `aid` int(11) NOT NULL DEFAULT '0', `uid` int(11) NOT NULL DEFAULT '0', @@ -865,8 +865,8 @@ CREATE TABLE IF NOT EXISTS `obj` ( `obj_term` char(255) NOT NULL DEFAULT '', `obj_url` char(255) NOT NULL DEFAULT '', `obj_imgurl` char(255) NOT NULL DEFAULT '', - `obj_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `obj_edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `obj_created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `obj_edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `obj_quantity` int(11) NOT NULL DEFAULT '0', `allow_cid` mediumtext NOT NULL, `allow_gid` mediumtext NOT NULL, @@ -894,8 +894,8 @@ CREATE TABLE IF NOT EXISTS `outq` ( `outq_posturl` char(255) NOT NULL DEFAULT '', `outq_async` tinyint(1) NOT NULL DEFAULT '0', `outq_delivered` tinyint(1) NOT NULL DEFAULT '0', - `outq_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `outq_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `outq_created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `outq_updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `outq_notify` mediumtext NOT NULL, `outq_msg` mediumtext NOT NULL, `outq_priority` smallint(6) NOT NULL DEFAULT '0', @@ -927,8 +927,8 @@ CREATE TABLE IF NOT EXISTS `photo` ( `uid` int(10) unsigned NOT NULL DEFAULT '0', `xchan` char(255) NOT NULL DEFAULT '', `resource_id` char(255) NOT NULL DEFAULT '', - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `title` char(255) NOT NULL DEFAULT '', `description` text NOT NULL, `album` char(255) NOT NULL DEFAULT '', @@ -1034,7 +1034,7 @@ CREATE TABLE IF NOT EXISTS `profile` ( `gender` char(32) NOT NULL DEFAULT '', `marital` char(255) NOT NULL DEFAULT '', `partner` text NOT NULL, - `howlong` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `howlong` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `sexual` char(255) NOT NULL DEFAULT '', `politic` char(255) NOT NULL DEFAULT '', `religion` char(255) NOT NULL DEFAULT '', @@ -1092,7 +1092,7 @@ CREATE TABLE IF NOT EXISTS `profile_check` ( CREATE TABLE IF NOT EXISTS `register` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `hash` char(255) NOT NULL DEFAULT '', - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `uid` int(10) unsigned NOT NULL DEFAULT '0', `password` char(255) NOT NULL DEFAULT '', `lang` char(16) NOT NULL DEFAULT '', @@ -1139,9 +1139,9 @@ CREATE TABLE IF NOT EXISTS `site` ( `site_url` char(255) NOT NULL, `site_access` int(11) NOT NULL DEFAULT '0', `site_flags` int(11) NOT NULL DEFAULT '0', - `site_update` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `site_pull` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `site_sync` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `site_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `site_pull` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `site_sync` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `site_directory` char(255) NOT NULL DEFAULT '', `site_register` int(11) NOT NULL DEFAULT '0', `site_sellpage` char(255) NOT NULL DEFAULT '', @@ -1230,8 +1230,8 @@ CREATE TABLE IF NOT EXISTS `updates` ( `ud_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ud_hash` char(128) NOT NULL DEFAULT '', `ud_guid` char(255) NOT NULL DEFAULT '', - `ud_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `ud_last` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `ud_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `ud_last` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `ud_flags` int(11) NOT NULL DEFAULT '0', `ud_addr` char(255) NOT NULL DEFAULT '', PRIMARY KEY (`ud_id`), @@ -1249,7 +1249,7 @@ CREATE TABLE IF NOT EXISTS `verify` ( `vtype` char(32) NOT NULL DEFAULT '', `token` char(255) NOT NULL DEFAULT '', `meta` char(255) NOT NULL DEFAULT '', - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY (`id`), KEY `channel` (`channel`), KEY `vtype` (`vtype`), @@ -1288,8 +1288,8 @@ CREATE TABLE IF NOT EXISTS `xchan` ( `xchan_network` char(255) NOT NULL DEFAULT '', `xchan_instance_url` char(255) NOT NULL DEFAULT '', `xchan_flags` int(10) unsigned NOT NULL DEFAULT '0', - `xchan_photo_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `xchan_name_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `xchan_photo_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `xchan_name_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `xchan_hidden` tinyint(1) NOT NULL DEFAULT '0', `xchan_orphan` tinyint(1) NOT NULL DEFAULT '0', `xchan_censored` tinyint(1) NOT NULL DEFAULT '0', @@ -1321,7 +1321,7 @@ CREATE TABLE IF NOT EXISTS `xchat` ( `xchat_url` char(255) NOT NULL DEFAULT '', `xchat_desc` char(255) NOT NULL DEFAULT '', `xchat_xchan` char(255) NOT NULL DEFAULT '', - `xchat_edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `xchat_edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY (`xchat_id`), KEY `xchat_url` (`xchat_url`), KEY `xchat_desc` (`xchat_desc`), @@ -1356,7 +1356,7 @@ CREATE TABLE IF NOT EXISTS `xlink` ( `xlink_link` char(255) NOT NULL DEFAULT '', `xlink_rating` int(11) NOT NULL DEFAULT '0', `xlink_rating_text` text NOT NULL, - `xlink_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `xlink_updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `xlink_static` tinyint(1) NOT NULL DEFAULT '0', `xlink_sig` text NOT NULL, PRIMARY KEY (`xlink_id`), diff --git a/install/update.php b/install/update.php index 9fd362fff..0675de8ef 100644 --- a/install/update.php +++ b/install/update.php @@ -54,7 +54,7 @@ function update_r1001() { `type` CHAR( 32 ) NOT NULL DEFAULT '', `token` CHAR( 255 ) NOT NULL DEFAULT '', `meta` CHAR( 255 ) NOT NULL DEFAULT '', - `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY ( `id` ) ) ENGINE = MYISAM DEFAULT CHARSET=utf8"); @@ -92,7 +92,7 @@ function update_r1004() { $r = q("CREATE TABLE if not exists `site` ( `site_url` CHAR( 255 ) NOT NULL , `site_flags` INT NOT NULL DEFAULT '0', -`site_update` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', +`site_update` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', `site_directory` CHAR( 255 ) NOT NULL DEFAULT '', PRIMARY KEY ( `site_url` ) ) ENGINE = MYISAM DEFAULT CHARSET=utf8"); @@ -174,7 +174,7 @@ function update_r1009() { function update_r1010() { - $r = q("ALTER TABLE `abook` ADD `abook_dob` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `abook_connnected` , + $r = q("ALTER TABLE `abook` ADD `abook_dob` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `abook_connnected` , ADD INDEX ( `abook_dob` )"); $r2 = q("ALTER TABLE `profile` ADD `dob_tz` CHAR( 255 ) NOT NULL DEFAULT 'UTC' AFTER `dob`"); @@ -185,7 +185,7 @@ ADD INDEX ( `abook_dob` )"); } function update_r1011() { - $r = q("ALTER TABLE `item` ADD `expires` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `edited` , + $r = q("ALTER TABLE `item` ADD `expires` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `edited` , ADD INDEX ( `expires` )"); if($r) @@ -207,7 +207,7 @@ function update_r1013() { `xlink_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , `xlink_xchan` CHAR( 255 ) NOT NULL DEFAULT '', `xlink_link` CHAR( 255 ) NOT NULL DEFAULT '', -`xlink_updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' +`xlink_updated` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' ) ENGINE = MYISAM DEFAULT CHARSET=utf8"); $r2 = q("alter table xlink add index ( xlink_xchan ), add index ( xlink_link ), add index ( xlink_updated ) "); @@ -299,7 +299,7 @@ function update_r1020() { function update_r1021() { - $r = q("ALTER TABLE `abook` CHANGE `abook_connnected` `abook_connected` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + $r = q("ALTER TABLE `abook` CHANGE `abook_connnected` `abook_connected` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', drop index `abook_connnected`, add index ( `abook_connected` ) "); if($r) @@ -363,7 +363,7 @@ ADD INDEX ( `xlink_rating` ) "); } function update_r1029() { - $r = q("ALTER TABLE `channel` ADD `channel_deleted` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `channel_pageflags` , + $r = q("ALTER TABLE `channel` ADD `channel_deleted` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `channel_pageflags` , ADD INDEX ( `channel_deleted` ) "); if($r) return UPDATE_SUCCESS; @@ -373,8 +373,8 @@ ADD INDEX ( `channel_deleted` ) "); function update_r1030() { $r = q("CREATE TABLE IF NOT EXISTS `issue` ( `issue_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , -`issue_created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', -`issue_updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', +`issue_created` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', +`issue_updated` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', `issue_assigned` CHAR( 255 ) NOT NULL , `issue_priority` INT NOT NULL , `issue_status` INT NOT NULL , @@ -440,7 +440,7 @@ KEY `share_xchan` (`share_xchan`) function update_r1034() { $r = q("CREATE TABLE if not exists `updates` ( `ud_hash` CHAR( 128 ) NOT NULL , -`ud_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', +`ud_date` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY ( `ud_hash` ), KEY `ud_date` ( `ud_date` ) ) ENGINE = MYISAM DEFAULT CHARSET = utf8"); @@ -537,8 +537,8 @@ function update_r1041() { function update_r1042() { - $r = q("ALTER TABLE `hubloc` ADD `hubloc_updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', -ADD `hubloc_connected` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', ADD INDEX ( `hubloc_updated` ), ADD INDEX ( `hubloc_connected` )"); + $r = q("ALTER TABLE `hubloc` ADD `hubloc_updated` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', +ADD `hubloc_connected` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', ADD INDEX ( `hubloc_updated` ), ADD INDEX ( `hubloc_connected` )"); if($r) return UPDATE_SUCCESS; return UPDATE_FAILED; @@ -846,7 +846,7 @@ function update_r1073() { function update_r1074() { $r1 = q("ALTER TABLE `site` ADD `site_sync` DATETIME NOT NULL AFTER `site_update` "); - $r2 = q("ALTER TABLE `updates` ADD `ud_last` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `ud_date` , + $r2 = q("ALTER TABLE `updates` ADD `ud_last` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `ud_date` , ADD INDEX ( `ud_last` ) "); if($r1 && $r2) @@ -879,7 +879,7 @@ function update_r1077() { } function update_r1078() { - $r = q("ALTER TABLE `channel` ADD `channel_dirdate` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `channel_pageflags` , ADD INDEX ( `channel_dirdate` )"); + $r = q("ALTER TABLE `channel` ADD `channel_dirdate` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `channel_pageflags` , ADD INDEX ( `channel_dirdate` )"); if($r) return UPDATE_SUCCESS; @@ -894,7 +894,7 @@ function update_r1079() { } function update_r1080() { - $r = q("ALTER TABLE `mail` ADD `expires` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + $r = q("ALTER TABLE `mail` ADD `expires` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', ADD INDEX ( `expires` ) "); if($r) return UPDATE_SUCCESS; @@ -1010,7 +1010,7 @@ function update_r1092() { `chat_room` int(10) unsigned NOT NULL DEFAULT '0', `chat_xchan` char(255) NOT NULL DEFAULT '', `chat_text` mediumtext NOT NULL, - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY (`chat_id`), KEY `chat_room` (`chat_room`), KEY `chat_xchan` (`chat_xchan`), @@ -1021,7 +1021,7 @@ function update_r1092() { `cp_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `cp_room` int(10) unsigned NOT NULL DEFAULT '0', `cp_xchan` char(255) NOT NULL DEFAULT '', - `cp_last` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `cp_last` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `cp_status` char(255) NOT NULL, PRIMARY KEY (`cp_id`), KEY `cp_room` (`cp_room`), @@ -1035,8 +1035,8 @@ function update_r1092() { `cr_aid` int(10) unsigned NOT NULL DEFAULT '0', `cr_uid` int(10) unsigned NOT NULL DEFAULT '0', `cr_name` char(255) NOT NULL DEFAULT '', - `cr_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `cr_edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `cr_created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `cr_edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `allow_cid` mediumtext NOT NULL, `allow_gid` mediumtext NOT NULL, `deny_cid` mediumtext NOT NULL, @@ -1141,7 +1141,7 @@ function update_r1099() { } function update_r1100() { - $r = q("ALTER TABLE `xchat` ADD `xchat_edited` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + $r = q("ALTER TABLE `xchat` ADD `xchat_edited` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', ADD INDEX ( `xchat_edited` ) "); if($r) return UPDATE_SUCCESS; @@ -1179,8 +1179,8 @@ function update_r1104() { } function update_r1105() { - $r = q("ALTER TABLE `site` ADD `site_pull` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `site_update` , -CHANGE `site_sync` `site_sync` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', ADD INDEX ( `site_pull` ) "); + $r = q("ALTER TABLE `site` ADD `site_pull` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `site_update` , +CHANGE `site_sync` `site_sync` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', ADD INDEX ( `site_pull` ) "); if($r) return UPDATE_SUCCESS; return UPDATE_FAILED; @@ -1319,7 +1319,7 @@ DROP INDEX `channel_a_bookmark` , ADD INDEX `channel_w_like` ( `channel_w_like` } function update_r1118() { - $r = q("ALTER TABLE `account` ADD `account_password_changed` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + $r = q("ALTER TABLE `account` ADD `account_password_changed` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', ADD INDEX ( `account_password_changed` )"); if($r) return UPDATE_SUCCESS; @@ -1411,8 +1411,8 @@ function update_r1124() { `recips` mediumtext NOT NULL, `uid` int(11) NOT NULL, `creator` char(255) NOT NULL, - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `subject` mediumtext NOT NULL, PRIMARY KEY (`id`), KEY `created` (`created`), @@ -1445,7 +1445,7 @@ ADD INDEX ( `convid` )"); } function update_r1127() { - $r = q("ALTER TABLE `item` ADD `comments_closed` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `changed` , + $r = q("ALTER TABLE `item` ADD `comments_closed` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `changed` , ADD INDEX ( `comments_closed` ), ADD INDEX ( `changed` ) "); if($r) return UPDATE_SUCCESS; @@ -1597,7 +1597,7 @@ function update_r1139() { $r = $r1 && $r2; } else - $r = q("ALTER TABLE `channel` ADD `channel_lastpost` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `channel_dirdate` , ADD INDEX ( `channel_lastpost` ) "); + $r = q("ALTER TABLE `channel` ADD `channel_lastpost` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `channel_dirdate` , ADD INDEX ( `channel_lastpost` ) "); if($r) return UPDATE_SUCCESS; return UPDATE_FAILED; @@ -1632,7 +1632,7 @@ function update_r1141() { $r = $r1 && $r2; } else - $r = q("ALTER TABLE menu ADD menu_created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', ADD menu_edited DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', ADD INDEX ( menu_created ), ADD INDEX ( menu_edited ) "); + $r = q("ALTER TABLE menu ADD menu_created DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', ADD menu_edited DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', ADD INDEX ( menu_created ), ADD INDEX ( menu_edited ) "); $t = datetime_convert(); q("update menu set menu_created = '%s', menu_edited = '%s' where true", @@ -1700,7 +1700,7 @@ function update_r1145() { } else { $r = q("ALTER TABLE `event` ADD `event_status` CHAR( 255 ) NOT NULL DEFAULT '', - ADD `event_status_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + ADD `event_status_date` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', ADD `event_percent` SMALLINT NOT NULL DEFAULT '0', ADD `event_repeat` TEXT NOT NULL DEFAULT '', ADD INDEX ( `event_status` ) "); @@ -1751,8 +1751,8 @@ function update_r1149() { $r1 = q("ALTER TABLE obj ADD obj_term CHAR( 255 ) NOT NULL DEFAULT '', ADD obj_url CHAR( 255 ) NOT NULL DEFAULT '', ADD obj_imgurl CHAR( 255 ) NOT NULL DEFAULT '', - ADD obj_created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', - ADD obj_edited DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' "); + ADD obj_created DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', + ADD obj_edited DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' "); } $r2 = q("create index obj_term on obj ( obj_term ) "); @@ -1774,8 +1774,8 @@ function update_r1150() { ADD app_edited timestamp NOT NULL DEFAULT '0001-01-01 00:00:00' "); } else { - $r1 = q("ALTER TABLE app ADD app_created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', - ADD app_edited DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' "); + $r1 = q("ALTER TABLE app ADD app_created DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', + ADD app_edited DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' "); } $r2 = q("create index app_created on app ( app_created ) "); @@ -1837,7 +1837,7 @@ function update_r1152() { `dreport_site` char(255) NOT NULL DEFAULT '', `dreport_recip` char(255) NOT NULL DEFAULT '', `dreport_result` char(255) NOT NULL DEFAULT '', - `dreport_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `dreport_time` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `dreport_xchan` char(255) NOT NULL DEFAULT '', PRIMARY KEY (`dreport_id`), KEY `dreport_mid` (`dreport_mid`), @@ -2197,7 +2197,7 @@ function update_r1173() { } else { $r1 = q("ALTER TABLE notify CHANGE `name` `xname` char(255) NOT NULL DEFAULT '' "); - $r2 = q("ALTER TABLE notify CHANGE `date` `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' "); + $r2 = q("ALTER TABLE notify CHANGE `date` `created` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' "); $r3 = q("ALTER TABLE notify CHANGE `type` `ntype` smallint(3) NOT NULL DEFAULT '0' "); } @@ -2219,8 +2219,8 @@ function update_r1174() { } else { $r1 = q("ALTER TABLE event CHANGE `type` `etype` char(255) NOT NULL DEFAULT '' "); - $r2 = q("ALTER TABLE event CHANGE `start` `dtstart` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' "); - $r3 = q("ALTER TABLE event CHANGE `finish` `dtend` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' "); + $r2 = q("ALTER TABLE event CHANGE `start` `dtstart` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' "); + $r3 = q("ALTER TABLE event CHANGE `finish` `dtend` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' "); $r4 = q("ALTER TABLE event CHANGE `ignore` `dismissed` tinyint(1) NOT NULL DEFAULT '0' "); $r5 = q("ALTER TABLE attach CHANGE `data` `content` longblob NOT NULL "); $r6 = q("ALTER TABLE photo CHANGE `data` `content` mediumblob NOT NULL "); @@ -2389,7 +2389,7 @@ function update_r1179() { `atoken_uid` int(11) NOT NULL DEFAULT 0, `atoken_name` char(255) NOT NULL DEFAULT '', `atoken_token` char(255) NOT NULL DEFAULT '', - `atoken_expires` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `atoken_expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY (`atoken_id`), KEY `atoken_aid` (`atoken_aid`), KEY `atoken_uid` (`atoken_uid`), |