Skip to content

Commit 4a7130c

Browse files
authored
Convert invalid dates to NULL in modTransportPackage.installed (#16721)
### What does it do? Converts any invalid dates in the modTransportPackage.installed column to NULL. ### Why is it needed? Empty dates should have been saved as NULL in the column and their presence can cause errors when NO_ZERO_DATE/NO_ZERO_IN_DATE sql_modes are enabled in an environment. ### How to test In an environment with NO_ZERO_DATE/NO_ZERO_DATE sql_modes enabled, build the transport and run the upgrade process, confirming that the process completes and that any invalid dates in the modTransportPackage.installed column are now NULL. You will need to have invalid dates in that column before enabling the strict sql_modes if you want to verify that this works properly. ### Related issue(s)/PR(s) Required for #16717 to be merged.
1 parent 5cc431e commit 4a7130c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Diff for: setup/includes/upgrades/mysql/3.1.2-pl.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/**
4+
* Specific upgrades for Revolution 3.1.2-pl
5+
*
6+
* @var modX $modx
7+
* @var modInstallVersion $this
8+
* @package setup
9+
* @subpackage upgrades
10+
*/
11+
12+
/* Repair any datetime data that can trigger errors when
13+
NO_ZERO_DATE/NO_ZERO_IN_DATE sql_modes are enabled */
14+
15+
$updated = $modx->updateCollection(
16+
\MODX\Revolution\Transport\modTransportPackage::class,
17+
[
18+
'installed' => null
19+
],
20+
[
21+
'installed:<' => '1000-01-01 00:00:00.000000'
22+
]
23+
);
24+
if ($updated === false) {
25+
$this->runner->addResult(modInstallRunner::RESULT_FAILURE, $this->install->lexicon('transport_package_installed_update_invalid_dates_error'));
26+
} else {
27+
$this->runner->addResult(modInstallRunner::RESULT_SUCCESS, $this->install->lexicon('transport_package_installed_update_invalid_dates_success'));
28+
}

Diff for: setup/lang/en/upgrades.inc.php

+2
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,5 @@
6060
$_lang['system_setting_update_failed'] = 'System Setting `[[+key]]` could not be updated.';
6161
$_lang['system_setting_rename_key_success'] = 'Successfully renamed the System Setting key from `[[+old_key]]` to `[[+new_key]]`.';
6262
$_lang['system_setting_rename_key_failure'] = 'Failed to rename the System Setting key from `[[+old_key]]` to `[[+new_key]]`.';
63+
$_lang['transport_package_installed_update_invalid_dates_failure'] = 'Failed to repair invalid dates in the Transport Package installed column.';
64+
$_lang['transport_package_installed_update_invalid_dates_success'] = 'Successfully repaired invalid dates in the Transport Package installed column.';

0 commit comments

Comments
 (0)